public async Task CatalogProduct() { // Arrange CatalogController controller = new CatalogController(catalogService.Object, settingsService.Object); // Act ViewResult result = await controller.Product("15") as ViewResult; // Assert Assert.IsNotNull(result); Product product = result.Model as Product; Assert.IsNotNull(product); Assert.AreEqual("15", product.Name); }
public async Task CatalogIndex() { // Arrange CatalogController controller = new CatalogController(catalogService.Object, settingsService.Object); // Act ViewResult result = await controller.Index(null) as ViewResult; // Assert IPagedList<Product> pagedList = result.Model as IPagedList<Product>; Assert.IsNotNull(pagedList); Assert.AreEqual(pageSize, pagedList.Count); Assert.AreEqual(Math.Ceiling((float)totalProducts / (float)pageSize), pagedList.PageCount); Assert.AreEqual(1, pagedList.PageNumber); Assert.AreEqual(totalProducts, pagedList.TotalItemCount); }