public void ProductDetailsPage_AuthenticatedAsCustomerTriesToRemoveOwnReview_CanOnlyRemoveOwnReview() { Dictionary <string, object> parameters = new Dictionary <string, object>() { ["ProductID"] = "1" }; ParameterView parameterView = AuthenticationStateService.PageParametersCreator(parameters, new Claim(ClaimTypes.Name, "Bob"), new Claim(ClaimTypes.Role, "Customer")); RenderedComponent <ProductDetailsWrapperTestComponent> component = _testHost.AddComponent <ProductDetailsWrapperTestComponent>(parameterView); IEnumerable <HtmlNode> tableRows = component.FindAll("tr").Where(tableRow => tableRow.Id.Contains("ReviewRow")); Assert.AreEqual(2, tableRows.Count()); foreach (HtmlNode tableRow in tableRows) { if (tableRow.InnerText.Contains("Bob")) { Assert.IsTrue(tableRow.InnerText.Contains("Delete")); } else if (tableRow.InnerText.Contains("Bill")) { Assert.IsFalse(tableRow.InnerText.Contains("Delete")); } } component.Find("#ReviewDeleteButton").Click(); tableRows = component.FindAll("tr").Where(tableRow => tableRow.Id.Contains("ReviewRow")); Assert.AreEqual(1, tableRows.Count()); }
public void ProductDetailsPage_AuthenticatedAsStaffTriesToRemoveAllReviews_CanRemoveAllReviews() { Dictionary <string, object> parameters = new Dictionary <string, object>() { ["ProductID"] = "1" }; ParameterView parameterView = AuthenticationStateService.PageParametersCreator(parameters, new Claim(ClaimTypes.Name, "Lewis"), new Claim(ClaimTypes.Role, "Staff")); RenderedComponent <ProductDetailsWrapperTestComponent> component = _testHost.AddComponent <ProductDetailsWrapperTestComponent>(parameterView); IEnumerable <HtmlNode> tableRows = component.FindAll("tr").Where(tableRow => tableRow.Id.Contains("ReviewRow")); Assert.AreEqual(2, tableRows.Count()); for (int x = 0; x < 2; x++) { ICollection <HtmlNode> deleteButtons = component.FindAll("#ReviewDeleteButton"); deleteButtons.First().Click(); } tableRows = component.FindAll("tr").Where(tableRow => tableRow.Id.Contains("ReviewRow")); Assert.AreEqual(0, tableRows.Count()); }
public void ProductListPage_BrandSelectValueChosen_ProductListOnlyShowsRelevantRows([Values("1", "2")] string brandID, [Values("Pablo's Farm", "Marge's Farm")] string brandName) { ParameterView parameterView = AuthenticationStateService.PageParametersCreator(); RenderedComponent <ProductListWrapperTestComponent> component = _testHost.AddComponent <ProductListWrapperTestComponent>(parameterView); component.Find("#BrandSelect").Change(brandID); IEnumerable <HtmlNode> tableNameCells = component.FindAll("#ProductRowBrand"); Assert.IsTrue(tableNameCells.All(tableNameCell => tableNameCell.InnerText.Contains(brandName))); }
public void ProductListPage_CategorySelectValueChosen_ProductListOnlyShowsRelevantRows([Values("1", "2")] string categoryID, [Values("Fruit", "Vegetables")] string categoryName) { ParameterView parameterView = AuthenticationStateService.PageParametersCreator(); RenderedComponent <ProductListWrapperTestComponent> component = _testHost.AddComponent <ProductListWrapperTestComponent>(parameterView); component.Find("#CategorySelect").Change(categoryID); IEnumerable <HtmlNode> tableNameCells = component.FindAll("#ProductRowCategory"); Assert.IsTrue(tableNameCells.All(tableNameCell => tableNameCell.InnerText.Contains(categoryName))); }
public void ProductListPage_SearchInputGaveString_ProductListOnlyShowsRelevantRows([Values("Orange", "Banana", "Broccoli")] string searchString) { ParameterView parameterView = AuthenticationStateService.PageParametersCreator(); RenderedComponent <ProductListWrapperTestComponent> component = _testHost.AddComponent <ProductListWrapperTestComponent>(parameterView); component.Find("#SearchStringInput").Input(searchString); IEnumerable <HtmlNode> tableNameCells = component.FindAll("#ProductRowName"); Assert.IsTrue(tableNameCells.All(tableNameCell => tableNameCell.InnerText.Contains(searchString))); }
public void ProductListPage_WhenExecuted_ProductListPageLoads() { ParameterView parameterView = AuthenticationStateService.PageParametersCreator(); RenderedComponent <ProductListWrapperTestComponent> component = _testHost.AddComponent <ProductListWrapperTestComponent>(parameterView); IEnumerable <HtmlNode> tableRows = component.FindAll("tr").Where(row => row.Id.Contains("ProductRow")); Assert.IsTrue(tableRows.Any()); Assert.AreEqual("Products", component.Find("h1").InnerText); }
public void ProductDetailsPage_WhenExecuted_ProductDetailsPageLoads([Values("1", "2", "3", "4")] string productID, [Values("Banana", "Orange", "Banana", "Broccoli")] string productName) { Dictionary <string, object> parameters = new Dictionary <string, object>() { ["ProductID"] = productID }; ParameterView parameterView = AuthenticationStateService.PageParametersCreator(parameters); RenderedComponent <ProductDetailsWrapperTestComponent> component = _testHost.AddComponent <ProductDetailsWrapperTestComponent>(parameterView); Assert.AreEqual(productName, component.Find("h1").InnerText); }
public void ProductListPage_AuthenticatedAsStaff_CanSeeStockQuantity() { ParameterView parameterView = AuthenticationStateService.PageParametersCreator(null, new Claim(ClaimTypes.Role, "Staff")); RenderedComponent <ProductListWrapperTestComponent> component = _testHost.AddComponent <ProductListWrapperTestComponent>(parameterView); HtmlNode tableHeader = component.Find("#ProductTableHeaderQuantity"); Assert.IsNotNull(tableHeader); IEnumerable <HtmlNode> tableNameCells = component.FindAll("#ProductRowQuantity"); Assert.IsTrue(tableNameCells.All(tableNameCell => tableNameCell.InnerText.All(char.IsDigit))); }
public void ProductListPage_NotAuthenticated_CantSeeStock() { ParameterView parameterView = AuthenticationStateService.PageParametersCreator(); RenderedComponent <ProductListWrapperTestComponent> component = _testHost.AddComponent <ProductListWrapperTestComponent>(parameterView); HtmlNode tableHeader = component.Find("#ProductTableHeaderQuantity"); Assert.IsNull(tableHeader); IEnumerable <HtmlNode> tableNameCells = component.FindAll("#ProductRowQuantity"); Assert.IsFalse(tableNameCells.Any()); }
public void ProductDetailsPage_AuthenticatedAsCustomerOnPageWhereTheyHaveReview_CantSeeReviewForm() { Dictionary <string, object> parameters = new Dictionary <string, object>() { ["ProductID"] = "1" }; ParameterView parameterView = AuthenticationStateService.PageParametersCreator(parameters, new Claim(ClaimTypes.Name, "Bob"), new Claim(ClaimTypes.Role, "Customer")); RenderedComponent <ProductDetailsWrapperTestComponent> component = _testHost.AddComponent <ProductDetailsWrapperTestComponent>(parameterView); Assert.AreEqual("Bill", component.Find("#ReviewCustomerName").InnerText); HtmlNode reviewForm = component.Find("#ReviewForm"); Assert.IsNull(reviewForm); }
public void ProductDetailsPage_AuthenticatedAsCustomer_CanSeeStockText() { Dictionary <string, object> parameters = new Dictionary <string, object>() { ["ProductID"] = "1" }; ParameterView parameterView = AuthenticationStateService.PageParametersCreator(parameters, new Claim(ClaimTypes.Name, "Bill"), new Claim(ClaimTypes.Role, "Customer")); RenderedComponent <ProductDetailsWrapperTestComponent> component = _testHost.AddComponent <ProductDetailsWrapperTestComponent>(parameterView); HtmlNode tableHeader = component.Find("#ProductHeaderQuantity"); Assert.IsNotNull(tableHeader); IEnumerable <HtmlNode> tableNameCells = component.FindAll("#ProductQuantity"); Assert.IsTrue(tableNameCells.All(tableNameCell => tableNameCell.InnerText.Contains("Stock"))); }
public void ProductDetailsPage_NotAuthenticated_CantSeeStock() { Dictionary <string, object> parameters = new Dictionary <string, object>() { ["ProductID"] = "1" }; ParameterView parameterView = AuthenticationStateService.PageParametersCreator(parameters); RenderedComponent <ProductDetailsWrapperTestComponent> component = _testHost.AddComponent <ProductDetailsWrapperTestComponent>(parameterView); HtmlNode tableHeader = component.Find("#ProductHeaderQuantity"); Assert.IsNull(tableHeader); IEnumerable <HtmlNode> tableNameCells = component.FindAll("#ProductQuantity"); Assert.IsFalse(tableNameCells.Any()); }
public void ProductDetailsPage_CustomerReviewsProductTheyHaveBought_ReviewIsAddedToList() { Dictionary <string, object> parameters = new Dictionary <string, object>() { ["ProductID"] = "2" }; ParameterView parameterView = AuthenticationStateService.PageParametersCreator(parameters, new Claim(ClaimTypes.Name, "Bill"), new Claim(ClaimTypes.Role, "Customer")); RenderedComponent <ProductDetailsWrapperTestComponent> component = _testHost.AddComponent <ProductDetailsWrapperTestComponent>(parameterView); component.Find("#ReviewFormRatingInput").Change("3"); component.Find("#ReviewFormTextInput").Change("This is a test review."); component.Find("#ReviewForm").Submit(); Assert.AreEqual("Bill", component.Find("#ReviewCustomerName").InnerText); Assert.AreEqual("3", component.Find("#ReviewRating").InnerText); Assert.AreEqual("This is a test review.", component.Find("#ReviewText").InnerText); }
public void ProductDetailsPage_NotAuthenticated_CantSeeReviewFormOrDeleteButtons() { Dictionary <string, object> parameters = new Dictionary <string, object>() { ["ProductID"] = "1" }; ParameterView parameterView = AuthenticationStateService.PageParametersCreator(parameters); RenderedComponent <ProductDetailsWrapperTestComponent> component = _testHost.AddComponent <ProductDetailsWrapperTestComponent>(parameterView); HtmlNode reviewForm = component.Find("#ReviewForm"); Assert.IsNull(reviewForm); HtmlNode reviewDeleteButton = component.Find("#ReviewDeleteButton"); Assert.IsNull(reviewDeleteButton); }