Exemple #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());
        }