//Problem 12. Call history test //Write a class GSMCallHistoryTest to test the call history functionality of the GSM class. //Create an instance of the GSM class. //Add few calls. //Display the information about the calls. //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. //Remove the longest call from the history and calculate the total price again. //Finally clear the call history and print it. public static GSM CallHistory() { Console.WriteLine(new string('=' , 60)); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Now showing the call history!"); Console.ResetColor(); var phone = new GSM("Xperia Z2", "Sony", 1200.99M, "Rocho", new Battery(BatteryType.LiIon), new Display(5.1, 16000000), ColorOfPhones.Black); phone.AddCalls(new Call(DateTime.Parse("03/03/2003 12:00:44"), "0888454124", 154)); phone.AddCalls(new Call(DateTime.Parse("02/04/2003 13:00:44"), "0899975412", 647)); phone.AddCalls(new Call(DateTime.Parse("06/10/2003 23:40:44"), "0894526475", 345)); var callMoney = phone.TotalPriceOfCalls(); Console.WriteLine("Total calls price: {0:F2} лв.", callMoney); Call longestCall = new Call(DateTime.Parse("06/10/2003 23:40:44"), "", 0); foreach (var call in phone.CallHistory) { if (call.DurationInSeconds > longestCall.DurationInSeconds) { longestCall = call; } } phone.DeleteCalls(longestCall); callMoney = phone.TotalPriceOfCalls(); Console.WriteLine("Total calls price without the longest call: {0:F2} лв.", callMoney); phone.ClearCalls(); Console.WriteLine("Call histroy has been cleared!"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("This test was done on this device:"); Console.ResetColor(); return phone; }
public static void Main() { Battery bl5c = new Battery("BL-5C", 300, 33, BatteryType.NiMH); GSM nokia1100 = new GSM("1100", "NOKIA", 100, "Ivan Ivanov", bl5c, 1.3f); Console.WriteLine(nokia1100); GSM galayA5 = new GSM("Galaxy A5", "Samsung", 779.90f, "Penka Petkova", new Battery("2300mAh integrated", 100, 2300, BatteryType.LiPol), 4.5f); Console.WriteLine(galayA5); Battery iPhoneBat = new Battery("iPhone bat", 200, 2000, BatteryType.LiIon); GSM iPhone = new GSM("iPhone4S", "Apple", 1000f, "Happy Iphone Owner", iPhoneBat, 3.5f); Console.WriteLine(iPhone); GSM lgA390 = new GSM("A390-Dual SIM", "LG", 115, "Kirov", new Battery("1700 mAh", 800, 1700, BatteryType.LiIon), 2.1f); Call call1 = new Call("10.10.14", "10:05", "088812346", 18); Call cal2 = new Call(DateTime.Now, "0899999999", 150); Call cal3 = new Call(); lgA390.AddCall(call1); lgA390.AddCall(cal2); lgA390.AddCall(cal3); Console.WriteLine(lgA390); Console.WriteLine(lgA390.CalcCallsPrice(0.37f)); //new GSM(" ", " "); //call1.CallTime = null; //bl5c.Capacity = -1; //iPhone.DisplaySize = -1; }
public static void Main() { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("En-GB"); GSM applePhone = new GSM( "iPhone 6s", "Apple", 599.99m, "Ivan Petrov", new Battery("Non-removable Apple Battery", 240, 14, BatteryType.Li_Po), new Display(4.7, 16000000)); GSM samsungPhone = new GSM( "Galaxy 7", "Samsung", 569.99m, "Stamat Stamatov", new Battery("Non-removable Samsung Battery", 200, 14, BatteryType.Li_Ion), new Display(5.1, 16000000)); GSM huaweiPhone = new GSM( "Honor V8", "Huawei", 269.99m, "Stefan Georgiev", new Battery("Huawei Battery", 200, 14, BatteryType.NiCd), new Display(5.7, 15000000)); GSM[] phones = { applePhone, samsungPhone, huaweiPhone }; foreach (var phone in phones) { Console.WriteLine(phone); Console.WriteLine(); } Console.WriteLine(GSM.IPhone4S); Console.WriteLine(); Call callOne = new Call(new DateTime(2016, 12, 31, 4, 32, 10), "0899 753 123", 60); Call callTwo = new Call(new DateTime(2015, 02, 12, 14, 12, 43), "0894 771 423", 120); Call callThree = new Call(new DateTime(2016, 5, 3, 11, 38, 00), "0878 333 623", 30); applePhone.AddCall(callOne); applePhone.AddCall(callTwo); applePhone.AddCall(callThree); Console.WriteLine(applePhone.PrintCallHistory()); Console.WriteLine(); Console.WriteLine("Total price: {0:0.00} USD", applePhone.CalculateTotalPrice()); applePhone.DeleteCall(callTwo); Console.WriteLine(); Console.WriteLine("Total price without the longest call: {0:0.00} USD", applePhone.CalculateTotalPrice()); Console.WriteLine(); applePhone.ClearHistory(); Console.WriteLine(applePhone.PrintCallHistory()); }
public void GSMCalls_ShouldStoreZeroCallsAndCalculatePrice0() { Battery battery=new Battery("BL-5C", 200, 1700, BatteryType.LiIon); GSM phone = new GSM("Samsung", "Galaxy 4", 550.34f, "Dimitar", battery, 5.0f); phone.AddCall(new Call()); var result = phone.CalcCallsPrice(1.0f); float expected = 0.0f; Assert.AreEqual(expected, result, "Zero call should have price 0"); }
public void Testing() { GSM[] phones = new GSM[3]; phones[0] = new GSM("Galaxy S5", "Samsung", 950, "Vulcho", new Battery(BatteryType.LiIon), new Display(5.1, 16000000), ColorOfPhones.Gold); phones[1] = new GSM("Xperia Z3", "Sony", 1199, "Richerson", new Battery("Jundjun 3100 mAh", 890.0, 15.0), new Display(5.2, 16000000), ColorOfPhones.Black); phones[2] = new GSM("M9", "HTC", 1575, "Morerich Thanricherson", new Battery("Banzai 2840 mAh", 391.0, 25.20), new Display(5.0, 16000000), ColorOfPhones.White); foreach (var phone in phones) { Console.WriteLine(phone); } var iPhone = GSM.iPhone4S; Console.WriteLine(iPhone); }
public void MyTestMethod() { Battery battery = new Battery("BL-5C", 200, 1700, BatteryType.LiIon); GSM phone = new GSM("Nokia", "1100", 100f, "Dimitar", battery, 1.5f); float callPrice = 2f; float expected = 0f; CallsGenerator calls=new CallsGenerator(); for (int i = 0; i < calls.Calls.Length ; i++) { phone.AddCall(calls.Calls[i]); expected += calls.Calls[i].CallDuration / 60f; } expected *= callPrice; float result = phone.CalcCallsPrice(callPrice); Assert.AreEqual(expected, result, "All calls price should be correct "+expected); }
public void GSM_ShouldThrowIfPriceIsNegative() { GSM phone = new GSM("Samsung", "Galaxy 4", -1, null, null, 0); }
public void GSM_ShouldThrowIfDisplaySizeIsNegative() { GSM phone = new GSM("Apple", "iPhone6"); phone.DisplaySize = -1; }
public void GSMCreate_ShouldThrowIfModelIsWhiteSpace() { GSM phone = new GSM(" ", "LG"); }
public void GSMCreate_shouldThrowIfModelIsNull() { GSM phone=new GSM(null, "Nokia"); }
public void GSMCreate_ShouldThrowIfManufacturerIsWhiteSpace() { GSM phone = new GSM("1100", " "); }
public void GSMCreate_ShouldThrowIfManufacturerIsNull() { GSM phone = new GSM("1100", null); }