Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 public void BatteryToString_ExpectToBeCorrect()
 {
     Battery battery = new Battery("BL-5C", 170, 1700, BatteryType.LiPol);
     string result = battery.ToString();
     string expected = "Battery BL-5C LiPol 1700mAh 170h";
     Assert.AreEqual(expected, result, "The output string should contain all values divided with interval");
 }
Ejemplo n.º 3
0
 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");
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates instance of GSM
 /// </summary>
 /// <param name="model">Model of the mobile phone. Obligatory</param>
 /// <param name="manufacturer">Brand of the mobile phone. Obligatory</param>
 /// <param name="price">Price of the mobile phone</param>
 /// <param name="owner">Owner's name</param>
 /// <param name="battery">Battery instance representing the battery installed in the phone</param>
 /// <param name="displaySize">The size of the display in inches</param>
 public GSM(string model, string manufacturer, float price, string owner, Battery battery, float displaySize)
 {
     this.Model = model;
     this.Manufacturer = manufacturer;
     this.Price = price;
     this.PhoneOwner = owner;
     this.BatteryData = battery;
     this.DisplaySize = displaySize;
     this.callHistory = new List<Call>();
     log4net.Config.XmlConfigurator.Configure();
 }
Ejemplo n.º 5
0
 public GSM(string model, string manufacturer, decimal price, string owner, Battery batteryInfo, Display displayInfo, ColorOfPhones colorPhone)
 {
     this.model = model;
     this.manufacturer = manufacturer;
     this.price = price;
     this.owner = owner;
     this.batteryInfo = batteryInfo;
     this.displayInfo = displayInfo;
     this.colorPhone = colorPhone;
     this.CallHistory = new List<Call>();
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public void CreateBattery_ExpectNegativeCapacityTalkToThrow()
 {
     Battery bat = new Battery(null, 0, -1, BatteryType.LiIon);
 }
Ejemplo n.º 8
0
 public void CreateBattery_ExpectHoursIdleToThrowIfNegative()
 {
     Battery bat = new Battery(null, -2, 0, BatteryType.LiIon);
 }
Ejemplo n.º 9
0
 public MobilePhone(string model, string manufacturer, decimal price, string owner, Battery battery, Display display) : this(model, manufacturer, price, owner)
 {
     this.Battery = battery;
     this.Display = display;
 }