public void Invoke_Should_Display_SummaryItem_View() { //arrange var vc = new BasketItemViewComponent(); BasketItem item = new BasketItem { Id = 2, ProductId = 5, Name = "Green Grapes", UnitPrice = 59.90m, Quantity = 3 }; //act var result = vc.Invoke(item, true); //assert ViewViewComponentResult vvcResult = Assert.IsAssignableFrom <ViewViewComponentResult>(result); Assert.Equal("SummaryItem", vvcResult.ViewName); BasketItem resultModel = Assert.IsAssignableFrom <BasketItem>(vvcResult.ViewData.Model); Assert.Equal(item.ProductId, resultModel.ProductId); }
public void Invoke_Should_Display_Default_View() { //arrange var vc = new BasketItemViewComponent(); BasketItem item = new BasketItem { Id = 1, ProductId = 1, Name = "Broccoli", UnitPrice = 59.90m, Quantity = 2 }; //act var result = vc.Invoke(item); //assert ViewViewComponentResult vvcResult = Assert.IsAssignableFrom <ViewViewComponentResult>(result); Assert.Equal("Default", vvcResult.ViewName); BasketItem resultModel = Assert.IsAssignableFrom <BasketItem>(vvcResult.ViewData.Model); Assert.Equal(item.ProductId, resultModel.ProductId); }