Exemple #1
0
        public void CallsSortTest()
        {
            //Arrange
            CallsStorage callStorage    = new CallsStorage();
            DateTime     dateTimeNow    = DateTime.Now;
            List <Call>  expectedResult = new List <Call>()
            {
                new Call("+3809703", CallType.Incoming, dateTimeNow),
                new Call("+3809701", CallType.Incoming, dateTimeNow)
            };

            //Act
            callStorage.AddCall(new Call("+3809701", CallType.Incoming, dateTimeNow));
            callStorage.AddCall(new Call("+3809703", CallType.Incoming, dateTimeNow));
            callStorage.AddCall(new Call("+3809702", CallType.Outgoing, dateTimeNow));
            callStorage.AddCall(new Call("+3809702", CallType.Incoming, dateTimeNow));
            callStorage.RemoveCallsByNumber("+3809702");
            List <Call> allCalls = callStorage.AllCalls;

            allCalls.Sort();
            List <Call> actualResult = allCalls;

            //Assert
            CollectionAssert.AreEqual(expectedResult, actualResult, new CallsComparer());
        }
Exemple #2
0
        public void Test_CallsAreSortedByDate()
        {
            //Act
            CallsStorage.AddCall(new Call()
            {
                contact = contact1, callTimeDate = new DateTime(2020, 1, 3, 16, 32, 7), Direction = "incoming"
            });
            CallsStorage.AddCall(new Call()
            {
                contact = contact2, callTimeDate = new DateTime(2018, 8, 31, 20, 48, 45), Direction = "incoming"
            });
            CallsStorage.AddCall(new Call()
            {
                contact = contact3, callTimeDate = new DateTime(2020, 2, 5, 12, 15, 16), Direction = "outgoing"
            });
            CallsStorage.AddCall(new Call()
            {
                contact = contact1, callTimeDate = new DateTime(2019, 12, 15, 9, 20, 3), Direction = "incoming"
            });
            var calls = CallsStorage.callsList;

            //Assert
            Assert.AreEqual(new DateTime(2018, 8, 31, 20, 48, 45), calls[3].callTimeDate);
            Assert.AreEqual(new DateTime(2019, 12, 15, 9, 20, 3), calls[2].callTimeDate);
            Assert.AreEqual(new DateTime(2020, 1, 3, 16, 32, 7), calls[1].callTimeDate);
            Assert.AreEqual(new DateTime(2020, 2, 5, 12, 15, 16), calls[0].callTimeDate);

            CallsStorage.RemoveCall(2);
            calls = CallsStorage.callsList;

            Assert.AreEqual(new DateTime(2018, 8, 31, 20, 48, 45), calls[2].callTimeDate);
            Assert.AreEqual(new DateTime(2020, 1, 3, 16, 32, 7), calls[1].callTimeDate);
            Assert.AreEqual(new DateTime(2020, 2, 5, 12, 15, 16), calls[0].callTimeDate);
        }
Exemple #3
0
 private void InitCallsStorage()
 {
     CallsStorage = new CallsStorage();
     CallsStorage.AddCall(new Call("+38097 01", CallType.Incoming, DateTime.Now));
     CallsStorage.AddCall(new Call("+38097 02", CallType.Incoming, DateTime.Now));
     CallsStorage.AddCall(new Call("+38097 01", CallType.Incoming, DateTime.Now));
     CallsStorage.AddCall(new Call("+38097 01", CallType.Incoming, DateTime.Now));
     CallsStorage.AddCall(new Call("+38097 02", CallType.Incoming, DateTime.Now));
     CallsStorage.AddCall(new Call("+38097 02", CallType.Incoming, DateTime.Now));
     CallsStorage.AddCall(new Call("+38097 02", CallType.Incoming, DateTime.Now));
     CallsStorage.AddCall(new Call("+38097 03", CallType.Incoming, DateTime.Now));
 }
Exemple #4
0
 public void AddCall()
 {
     while (true)
     {
         if (Token.IsCancellationRequested)
         {
             break;
         }
         lock (thisLock) {
             // Do the work...
             Call call = GenerateCall();
             CallStorage.AddCall(call);
             Thread.Sleep(1000);
         };
     }
 }
Exemple #5
0
        public void Test_SimilarCallsHandling()
        {
            CallsStorage.AddCall(new Call()
            {
                contact = contact3, callTimeDate = new DateTime(2020, 03, 01, 9, 20, 3), Direction = "incoming"
            });
            var n = CallsStorage.callsList.Count;

            //Add similar call
            CallsStorage.AddCall(new Call()
            {
                contact = contact3, callTimeDate = new DateTime(2020, 03, 02, 9, 20, 3), Direction = "incoming"
            });

            //the number of call records must not be changed
            Assert.AreEqual(n, CallsStorage.callsList.Count);
            Assert.AreEqual(n, CallsStorage.callLog.Count);

            //two records in the call log for the last calling contact
            Assert.AreEqual(2, CallsStorage.callLog[0].Count);

            //Add new different call
            CallsStorage.AddCall(new Call()
            {
                contact = contact3, callTimeDate = new DateTime(2020, 03, 02, 9, 20, 3), Direction = "outgoing"
            });
            Assert.AreEqual(n + 1, CallsStorage.callsList.Count);
            Assert.AreEqual(n + 1, CallsStorage.callLog.Count);
            //for new calls there is only one timestamp in the last log record
            Assert.AreEqual(1, CallsStorage.callLog[0].Count);

            //remove the last call info
            CallsStorage.RemoveCall(0);
            n = CallsStorage.callsList.Count;

            Assert.AreEqual(n, CallsStorage.callLog.Count);
            Assert.AreEqual(2, CallsStorage.callLog[0].Count);
        }
Exemple #6
0
 public CallsForm()
 {
     InitializeComponent();
     CallsStorage.AddCall(new Call()
     {
         contact = contact1, callTimeDate = new DateTime(2018, 8, 31, 20, 48, 45), Direction = "incoming"
     });
     CallsStorage.AddCall(new Call()
     {
         contact = contact3, callTimeDate = new DateTime(2019, 12, 15, 9, 20, 3), Direction = "incoming"
     });
     CallsStorage.AddCall(new Call()
     {
         contact = contact1, callTimeDate = new DateTime(2020, 1, 3, 16, 32, 7), Direction = "incoming"
     });
     CallsStorage.AddCall(new Call()
     {
         contact = contact2, callTimeDate = new DateTime(2020, 2, 5, 12, 15, 16), Direction = "outgoing"
     });
     CallsStorage.AddCall(new Call()
     {
         contact = contact2, callTimeDate = new DateTime(2020, 2, 5, 12, 17, 16), Direction = "outgoing"
     });
 }