public void IsProductTypeTest(string productType) { var result = ProductTypeOperations.IsProductType(productType); Assert.IsTrue(result); }
private static ProductType PromptForValidProductType(string prompt, bool extraInfo = false) { ProductType productType = null; List <ProductType> productTypes = ProductTypeOperations.GetAllProductTypes(); string userInput = ""; bool validProduct = false; bool error = false; bool displayedAllProducts = false; while (!validProduct) { if (!displayedAllProducts && (!extraInfo || error)) { OffsetTop(); } //display 10 current products and give them the chance to see all of them if (!displayedAllProducts) { DisplayProductTypes(false); } //if there was an error in the last time through the loop if (error) { Console.ForegroundColor = ErrorColor; Console.WriteLine("\tInvalid Product."); Console.WriteLine(); } //get the user input Console.ForegroundColor = PromptColor; Console.Write("\t" + prompt); Console.ForegroundColor = EmphasisColor; userInput = Console.ReadLine().Trim(); Console.ResetColor(); Console.Clear(); if (userInput == "") //they want to display all product types { OffsetTop(); DisplayProductTypes(true); displayedAllProducts = true; } else if (ProductTypeOperations.IsProductType(userInput)) { productType = ProductTypeOperations.GetProductType(userInput); Console.Clear(); if (extraInfo) { OffsetTop(); Console.WriteLine("\t{0} cost per square foot: {1:C}", productType.Type, productType.CostPerSquareFoot); Console.WriteLine("\t{0} labor cost per square foot: {1:C}", productType.Type, productType.LaborCostPerSquareFoot); Console.WriteLine("\t----------------------------------------"); Console.WriteLine(); } validProduct = true; } else { error = true; if (displayedAllProducts) //the console was just cleared, so we don't want the error list to go away { OffsetTop(); DisplayProductTypes(true); } } } return(productType); }