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
        public Mobile()
        {
            _callsProvider = new CallsProvider();
            _callsProvider.CallReceived += OnCallReceived;

            CallsStorage = new CallsStorage();
        }
        public void TestInitialize()
        {
            _callsStorage = new CallsStorage();
            var phoneNumbers = new List <string>()
            {
                "063-0000101", "063-0000102", "063-0000102", "063-0000101",
                "063-0000103", "063-0000102", "063-0000101", "063-0000104", "063-0000104", "063-0000104"
            };

            _contactService = new ContactService();
            _contactService.AddContact(new Contact("Contact 1", new List <string>()
            {
                "063-0000101", "063-0000104"
            }));
            _contactService.AddContact(new Contact("Contact 2", "063-0000102"));
            _contactService.AddContact(new Contact("Contact 3", "063-0000103"));

            var outgoings = new List <bool>()
            {
                true, true, false, true, false, true, false, false, true, true
            };

            Debug.Assert(phoneNumbers.Count > 0 && phoneNumbers.Count == outgoings.Count && phoneNumbers.Count < 60);
            for (int i = 0; i < phoneNumbers.Count; i++)
            {
                var phoneNumber = phoneNumbers[i];
                var call        = new Call(Guid.NewGuid(), phoneNumber, "Test message", new DateTime(2015, 12, 1, 10, 30, i), outgoings[i]);
                call.Contact = _contactService.GetContactByPhone(phoneNumber);
                _callsStorage.SaveCall(call);
            }
            Assert.AreEqual(5, _callsStorage.GetCalls().Count);
        }
Exemple #5
0
 public MobilePhoneCallsForm()
 {
     InitializeComponent();
     CallsStorage            = new CallsStorage();
     CallsTask               = new CallsTask(CallsStorage);
     CallsStorage.CallAdded += ShowAddedCall;
     CallsTask.Start();
 }
Exemple #6
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));
 }
        public void CallEqualNumberTest()
        {
            //Arrange
            CallsStorage callStorage    = new CallsStorage();
            DateTime     dateTimeNow    = DateTime.Now;
            Call         callFirst      = new Call("+38097 01", CallType.Incoming, dateTimeNow);
            Call         callSecond     = new Call("+38097 01", CallType.Incoming, dateTimeNow);
            bool         expectedResult = true;
            bool         actualResult;

            //Act
            actualResult = callFirst.Equals(callSecond);
            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #8
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);
        }
        private void CallsForm_Load(object sender, EventArgs e)
        {
            var phoneNumbers = new List <string>()
            {
                "063-0000101", "063-0000102", "063-0000102", "063-0000101",
                "063-0000103", "063-0000102", "063-0000101", "063-0000104", "063-0000104", "063-0000104"
            };

            _callStorage    = new CallsStorage();
            _contactService = new ContactService();
            _contactService.AddContact(new Contact("Contact 1", new List <string>()
            {
                "063-0000101", "063-0000104"
            }));
            _contactService.AddContact(new Contact("Contact 2", "063-0000102"));
            _contactService.AddContact(new Contact("Contact 3", "063-0000103"));
            var outgoings = new List <bool>()
            {
                true, true, false, true, false, true, false, false, true, true
            };

            _callsGenerator = new CallsGenerator(phoneNumbers, outgoings);
            _callsGenerator.CallGenerated += CallGeneratedHandler;
        }
Exemple #10
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"
     });
 }
Exemple #11
0
 //private Task Task;
 public CallsTask(CallsStorage callStorage)
 {
     CallStorage = callStorage;
 }
Exemple #12
0
        public TestBilling()
        {
            callsStorage                        = new CallsStorage();
            tariffPlansStorage                  = new TariffPlansStorage();
            userStorage                         = new UserStorage();
            contractTreatment                   = new ContractTreatment();
            callProcessing                      = new CallProcessing(callsStorage.CallStorage, contractTreatment.Contracts);
            station                             = new Station(new List <ITerminal>(), new List <IPort>(), contractTreatment.Contracts);
            station.CallInfoPrepared           += Station_CallInfoPrepared;
            contractTreatment.TerminalIssue    += ContractTreatment_TerminalIssue;
            contractTreatment.TerminalWriteOff += ContractTreatment_TerminalWriteOff;
            tariffPlansStorage.Addtariff(2, true, 500, "Tarif_1");
            tariffPlansStorage.Addtariff(5, false, 0, "Tarif_2");
            User user1 = new User("User_1");
            User user2 = new User("User_2");
            User user3 = new User("User_3");

            contractTreatment.AgreementCreation(user1, tariffPlansStorage.TariffPlans[0], new PhoneNumber("1111"));
            contractTreatment.AgreementCreation(user2, tariffPlansStorage.TariffPlans[0], new PhoneNumber("2222"));
            contractTreatment.AgreementCreation(user2, tariffPlansStorage.TariffPlans[1], new PhoneNumber("3333"));
            var term1 = contractTreatment.IssueTerminal(contractTreatment.Contracts[0]);
            var term2 = contractTreatment.IssueTerminal(contractTreatment.Contracts[1]);
            var term3 = contractTreatment.IssueTerminal(contractTreatment.Contracts[2]);

            contractTreatment.Contracts[2].Account.Balance = 800;
            Console.WriteLine("________");

            term1.Plug();

            Console.WriteLine("________");

            term2.Plug();

            Console.WriteLine("________");

            term1.Call(new PhoneNumber("2222"));

            Console.WriteLine("________");

            term2.Answer();
            Console.WriteLine("________");

            term1.Drop();
            Console.WriteLine("________");
            term3.Call(new PhoneNumber("2222"));
            term2.Answer();
            term2.Drop();
            Console.WriteLine("________");
            term3.Call(new PhoneNumber("1111"));
            term1.Answer();
            //Thread.Sleep(200000);
            Console.WriteLine("@@@@");
            term3.Drop();
            Console.WriteLine("________");
            term1.Call(new PhoneNumber("2222"));
            term2.Answer();
            term2.Drop();
            term1.Call(new PhoneNumber("3333"));
            term3.Answer();
            term3.Drop();

            foreach (var item in callsStorage.CallStorage)
            {
                Console.WriteLine(" cost " + item.Cost + " date " + item.Started + " source " + item.Source.Value + " target " + item.Target.Value);
            }
            Console.WriteLine("________");
            foreach (var item in callsStorage.FindCallsByDate(DateTime.Now, new PhoneNumber("1111"), callsStorage.CallStorage))
            {
                Console.WriteLine(" cost " + item.Cost + " date " + item.Started + " source " + item.Source.Value + " target " + item.Target.Value);
            }
            Console.WriteLine("________");

            Console.ReadLine();
        }