CardShop.Controllers.BaseballCardController.Index C# (CSharp) Méthode

Index() public méthode

public Index ( ) : System.Web.Mvc.ActionResult
Résultat System.Web.Mvc.ActionResult
        public ActionResult Index()
        {
            return View(baseballCardService.GetAllCards());
        }

Usage Example

        public void TestIndexHasListOfBaseballCards()
        {
            BaseballCardController controller = new BaseballCardController(mockCardRepository.Object);

            ViewResult result = controller.Index() as ViewResult;
            List<BaseballCard> cards = (List<BaseballCard>)result.ViewData.Model;

            // Test the view model contains a list of fish
            Assert.IsNotNull(cards, "The list of cards does not exist");
            Assert.IsTrue(cards.Count == mockCards.Count);
        }