예제 #1
0
        public void TestMethod2()
        {
            GSM testGSM = GSMCallHistoryTest.FillGSMCalls(new GSM("1000", "Nokia"));

            string testResultString = "";

            //Check all calls display
            testResultString = String.Format("1 : To 0888 888 888 at {0} for 40 seconds\r\n2 : To 0888 888 888 at {0} for 190 seconds\r\n3 : To 0888 888 888 at {0} for 130 seconds\r\n", DateTime.Now);
            Assert.AreEqual(testResultString, testGSM.ListAllCalls());

            //Check all calls price
            Assert.AreEqual((decimal)2.96, testGSM.CalcAllCallPrice((decimal)0.37));

            //Check all calls price withoud the longest call
            int indexMaxCall = 0;

            for (int i = 1; i < testGSM.CallHistory.Count; i++)
            {
                if (testGSM.CallHistory[indexMaxCall].Duration < testGSM.CallHistory[i].Duration)
                {
                    indexMaxCall = i;
                }
            }
            testGSM.RemoveCall(indexMaxCall);

            Assert.AreEqual((decimal)1.48, testGSM.CalcAllCallPrice((decimal)0.37));

            //Check all calls list when empty
            testGSM.RemoveAllCalls();
            Assert.AreEqual("", testGSM.ListAllCalls());
        }
예제 #2
0
        static void Main(string[] args)
        {
            GSM testGSM = new GSM("1000", "Nokia");

            testGSM = FillGSMCalls(testGSM);

            Console.WriteLine(new String('*', 20));
            Console.WriteLine("List all calls:");
            Console.WriteLine(testGSM.ListAllCalls());

            Console.WriteLine(new String('*', 20));
            Console.WriteLine("The price of all calls is: {0}", testGSM.CalcAllCallPrice((decimal)0.37));

            int indexMaxCall = 0;

            for (int i = 1; i < testGSM.CallHistory.Count; i++)
            {
                if (testGSM.CallHistory[indexMaxCall].Duration < testGSM.CallHistory[i].Duration)
                {
                    indexMaxCall = i;
                }
            }

            testGSM.RemoveCall(indexMaxCall);
            Console.WriteLine(new String('*', 20));
            Console.WriteLine("The new price of all calls is: {0}", testGSM.CalcAllCallPrice((decimal)0.37));

            testGSM.RemoveAllCalls();
            Console.WriteLine(new String('*', 20));
            Console.WriteLine("List all calls:");
            Console.WriteLine(testGSM.ListAllCalls());
        }