//===================================================================== public bool runTest(TestCase aTest) { //map from TestCase to InterfaceToBLL object InterfaceToBLL aCase = new InterfaceToBLL(); aCase.Count_4_6_Gloss_Day = aTest.inputs[0]; aCase.Count_4_6_Gloss_Hour = aTest.inputs[3]; aCase.Count_4_6_Matte_Day = aTest.inputs[6]; aCase.Count_4_6_Matte_Hour = aTest.inputs[9]; aCase.Count_5_7_Gloss_Day = aTest.inputs[1]; aCase.Count_5_7_Gloss_Hour = aTest.inputs[4]; aCase.Count_5_7_Matte_Day = aTest.inputs[7]; aCase.Count_5_7_Matte_Hour = aTest.inputs[10]; aCase.Count_8_10_Gloss_Day = aTest.inputs[2]; aCase.Count_8_10_Gloss_Hour = aTest.inputs[5]; aCase.Count_8_10_Matte_Day = aTest.inputs[8]; aCase.Count_8_10_Matte_Hour = aTest.inputs[11]; aCase.Discount_Code = aTest.discountCode; //process the BLL object. Console.WriteLine("~~~~~~~~~~~~~~~~~~~~ Starting Test ~~~~~~~~~~~~~~~~"); Console.WriteLine("Test id: " + aTest.id); var returnedBLL = new BLL_Final().Calculate(aCase); //now check for the results.. //check total price is equal to expected if (!(returnedBLL.Total_Price == aTest.expectTotalPrice)) { Console.WriteLine("****************Failed Test***************"); Console.WriteLine("Test id: " + aTest.id); Console.WriteLine("Expected final price: " + aTest.expectTotalPrice.ToString("0.00")); Console.WriteLine("Resulted final price: " + returnedBLL.Total_Price); Console.WriteLine("Receipt: " + returnedBLL.Receipt); Console.WriteLine("************** End of Message ************"); return(false); } else { Console.WriteLine("---------------Passed Test----------------"); Console.WriteLine("Test id: " + aTest.id); Console.WriteLine("------------- End of Message--------------"); return(true); } }
private void b_Calculate_Click(object sender, RoutedEventArgs e) { Int32 totalcount = 0; /// Create the object that will be passed to Business Logic BLL.InterfaceToBLL iBLL = new BLL.InterfaceToBLL(); /// Populate business logic iBLL.Count_4_6_Gloss_Day = ValidateInput(t_Count_4_6_Gloss_Day); iBLL.Count_4_6_Gloss_Hour = ValidateInput(t_Count_4_6_Gloss_Hour); iBLL.Count_4_6_Matte_Day = ValidateInput(t_Count_4_6_Matte_Day); iBLL.Count_4_6_Matte_Hour = ValidateInput(t_Count_4_6_Matte_Hour); iBLL.Count_5_7_Gloss_Day = ValidateInput(t_Count_5_7_Gloss_Day); iBLL.Count_5_7_Gloss_Hour = ValidateInput(t_Count_5_7_Gloss_Hour); iBLL.Count_5_7_Matte_Day = ValidateInput(t_Count_5_7_Matte_Day); iBLL.Count_5_7_Matte_Hour = ValidateInput(t_Count_5_7_Matte_Hour); iBLL.Count_8_10_Gloss_Day = ValidateInput(t_Count_8_10_Gloss_Day); iBLL.Count_8_10_Gloss_Hour = ValidateInput(t_Count_8_10_Gloss_Hour); iBLL.Count_8_10_Matte_Day = ValidateInput(t_Count_8_10_Matte_Day); iBLL.Count_8_10_Matte_Hour = ValidateInput(t_Count_8_10_Matte_Hour); iBLL.Discount_Code = t_Discount_Code.Text; totalcount = 0; totalcount = totalcount + iBLL.Count_4_6_Gloss_Day; totalcount = totalcount + iBLL.Count_4_6_Gloss_Hour; totalcount = totalcount + iBLL.Count_4_6_Matte_Day; totalcount = totalcount + iBLL.Count_4_6_Matte_Hour; totalcount = totalcount + iBLL.Count_5_7_Gloss_Day; totalcount = totalcount + iBLL.Count_5_7_Gloss_Hour; totalcount = totalcount + iBLL.Count_5_7_Matte_Day; totalcount = totalcount + iBLL.Count_5_7_Matte_Hour; totalcount = totalcount + iBLL.Count_8_10_Gloss_Day; totalcount = totalcount + iBLL.Count_8_10_Gloss_Hour; totalcount = totalcount + iBLL.Count_8_10_Matte_Day; totalcount = totalcount + iBLL.Count_8_10_Matte_Hour; /// If checked then perform calculations with Debug Version of Business Logic /// if ((totalcount > 0) & (totalcount <= 100)) { if (c_Debug_Mode.IsChecked == true) { BLL.InterfaceToBLL returnIBLL = new BLL.InterfaceToBLL(); BLL.BLL_Debug testBLL = new BLL.BLL_Debug(); try { returnIBLL = testBLL.Calculate(iBLL); t_Receipt_Area.Document = new FlowDocument(); t_Receipt_Area.AppendText(returnIBLL.Receipt); t_Total_Count.Text = returnIBLL.Total_Count.ToString(); t_Total_Price.Text = returnIBLL.Total_Price.ToString(); } catch (Exception ex) { t_log_area.Document = new FlowDocument(); t_log_area.AppendText(ex.Message); } } else { BLL.InterfaceToBLL returnIBLL = new BLL.InterfaceToBLL(); BLL.BLL_Final testBLL = new BLL.BLL_Final(); try { returnIBLL = testBLL.Calculate(iBLL); /// t_Receipt_Area.Document = new FlowDocument(); t_Receipt_Area.AppendText(returnIBLL.Receipt); t_Total_Count.Text = returnIBLL.Total_Count.ToString(); t_Total_Price.Text = returnIBLL.Total_Price.ToString(); } catch (Exception ex) { t_log_area.Document = new FlowDocument(); t_log_area.AppendText(ex.Message); } } } }