示例#1
0
        public void ConversationWithExactDuplicatesTest()
        {
            DummyContactId[]     dummyContactIds     = { DummyContactId.Davola, DummyContactId.Davola };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            MockLoadingProgressCallback progressCallbackUnmerged    = new MockLoadingProgressCallback();
            ConversationManager         conversationManagerUnmerged = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallbackUnmerged);

            Assert.AreEqual(2, conversationManagerUnmerged.ConversationCount);
            VerifySuccessfulCompletion(progressCallbackUnmerged);
        }
 public static void VerifySuccessfulCompletion(MockLoadingProgressCallback progressCallback)
 {
     Assert.AreEqual(false, progressCallback.IsCanceled);
     Assert.AreEqual(true, progressCallback.IsEnded);
     Assert.AreEqual(3, progressCallback.PhaseHistory.Count);
     Assert.AreEqual(0, progressCallback.Minimum);
     Assert.AreEqual(progressCallback.Maximum, progressCallback.LastIncrementedPosition);
     Assert.AreEqual(LoadingPhase.ReadingContacts, progressCallback.PhaseHistory[0]);
     Assert.AreEqual(LoadingPhase.ReadingChatInformation, progressCallback.PhaseHistory[1]);
     Assert.AreEqual(LoadingPhase.ReadingMessages, progressCallback.PhaseHistory[2]);
 }
        public void ConversationWithExactDuplicatesTest()
        {
            DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.Davola };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            MockLoadingProgressCallback progressCallbackUnmerged = new MockLoadingProgressCallback();
            ConversationManager conversationManagerUnmerged = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallbackUnmerged);

            Assert.AreEqual(2, conversationManagerUnmerged.ConversationCount);
            VerifySuccessfulCompletion(progressCallbackUnmerged);
        }
示例#4
0
 public static void VerifySuccessfulCompletion(MockLoadingProgressCallback progressCallback)
 {
     Assert.AreEqual(false, progressCallback.IsCanceled);
     Assert.AreEqual(true, progressCallback.IsEnded);
     Assert.AreEqual(3, progressCallback.PhaseHistory.Count);
     Assert.AreEqual(0, progressCallback.Minimum);
     Assert.AreEqual(progressCallback.Maximum, progressCallback.LastIncrementedPosition);
     Assert.AreEqual(LoadingPhase.ReadingContacts, progressCallback.PhaseHistory[0]);
     Assert.AreEqual(LoadingPhase.ReadingChatInformation, progressCallback.PhaseHistory[1]);
     Assert.AreEqual(LoadingPhase.ReadingMessages, progressCallback.PhaseHistory[2]);
 }
示例#5
0
        public void MergedConversationWithExactDuplicatesTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { DummyContactId.Davola, DummyContactId.Davola };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            MergingConversationManager mergingConversationManager = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(1, mergingConversationManager.ConversationCount);
            ConversationManagerTest.VerifySuccessfulCompletion(progressCallback);
        }
        public void MergedConversationWithExactDuplicatesTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.Davola };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            MergingConversationManager mergingConversationManager = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(1, mergingConversationManager.ConversationCount);
            ConversationManagerTest.VerifySuccessfulCompletion(progressCallback);
        }
示例#7
0
        public void EmptyTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { };

            ConversationManager   conversationManager   = DummyConversationDataGenerator.GetConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);
            AggregateConversation aggregateConversation = new AggregateConversation(new List <IConversation>());

            Assert.AreEqual(0, aggregateConversation.MessageCount);
        }
        public void EmptyTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { };

            ConversationManager conversationManager = DummyConversationDataGenerator.GetConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);
            AggregateConversation aggregateConversation = new AggregateConversation(new List<IConversation>());

            Assert.AreEqual(0, aggregateConversation.MessageCount);
        }
示例#9
0
        public void SingleContactTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { DummyContactId.Davola };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(2, conversationManager.ConversationCount);

            Assert.AreEqual(18, progressCallback.Maximum);
            VerifySuccessfulCompletion(progressCallback);
        }
示例#10
0
        public void EmptyTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(0, conversationManager.ConversationCount);

            Assert.AreEqual(0, progressCallback.Maximum);
            VerifySuccessfulCompletion(progressCallback);
        }
示例#11
0
        public void DoubleUnknownConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.UnknownLawnmower, DummyPhoneNumberId.UnknownEagle };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(2, conversationManager.ConversationCount);

            Assert.AreEqual(11, progressCallback.Maximum);
            VerifySuccessfulCompletion(progressCallback);
        }
        public void DoubleUnknownConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.UnknownLawnmower, DummyPhoneNumberId.UnknownEagle };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(2, conversationManager.ConversationCount);

            Assert.AreEqual(11, progressCallback.Maximum);
            VerifySuccessfulCompletion(progressCallback);
        }
示例#13
0
        public void UnmergedMultipleConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { DummyContactId.Davola, DummyContactId.Obama };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone, DummyPhoneNumberId.ObamaCell, DummyPhoneNumberId.UnknownLawnmower };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(4, conversationManager.ConversationCount);

            Assert.AreEqual(36, progressCallback.Maximum);
            VerifySuccessfulCompletion(progressCallback);
        }
        public void EmptyMergedConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { DummyContactId.NeverTexter };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { };

            MergingConversationManager mergingConversationManager = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(1, mergingConversationManager.ConversationCount);

            int expectedProgressMax = (DummyConversationDataGenerator.GetPhoneNumberCount(dummyContactIds) * 2) +
                                      DummyConversationDataGenerator.GetMessageCount(DummyPhoneNumberIds);
            Assert.AreEqual(expectedProgressMax, progressCallback.Maximum);
            ConversationManagerTest.VerifySuccessfulCompletion(progressCallback);
        }
        public void ConversationWithNumberDuplicatesTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.DavolaNumberDuplicate };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            MergingConversationManager conversationManagerMerged = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(1, conversationManagerMerged.ConversationCount);

            IConversation conversation = conversationManagerMerged.GetConversation(0);
            Assert.AreEqual(1, conversation.AssociatedContacts.Count);
            Assert.AreEqual((long)DummyContactId.Davola, conversation.AssociatedContacts[0].ContactId);

            ConversationManagerTest.VerifySuccessfulCompletion(progressCallback);
        }
示例#16
0
        public void EmptyMergedConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { DummyContactId.NeverTexter };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { };

            MergingConversationManager mergingConversationManager = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(1, mergingConversationManager.ConversationCount);

            int expectedProgressMax = (DummyConversationDataGenerator.GetPhoneNumberCount(dummyContactIds) * 2) +
                                      DummyConversationDataGenerator.GetMessageCount(DummyPhoneNumberIds);

            Assert.AreEqual(expectedProgressMax, progressCallback.Maximum);
            ConversationManagerTest.VerifySuccessfulCompletion(progressCallback);
        }
示例#17
0
        public void ConversationWithNumberDuplicatesTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { DummyContactId.Davola, DummyContactId.DavolaNumberDuplicate };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            MergingConversationManager conversationManagerMerged = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(1, conversationManagerMerged.ConversationCount);

            IConversation conversation = conversationManagerMerged.GetConversation(0);

            Assert.AreEqual(1, conversation.AssociatedContacts.Count);
            Assert.AreEqual((long)DummyContactId.Davola, conversation.AssociatedContacts[0].ContactId);

            ConversationManagerTest.VerifySuccessfulCompletion(progressCallback);
        }
示例#18
0
        public void UnknownConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.UnknownLawnmower };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(1, conversationManager.ConversationCount);
            foreach (IConversationMessage message in conversationManager.GetConversation(0))
            {
                Assert.IsNotNull(message.Contact);
                Assert.AreEqual(Contact.UnknownContactId, message.Contact.ContactId);
            }

            VerifySuccessfulCompletion(progressCallback);
        }
        public void ConversationWithNumberDuplicatesTest()
        {
            DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.DavolaNumberDuplicate };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            MockLoadingProgressCallback progressCallbackUnmerged = new MockLoadingProgressCallback();
            ConversationManager conversationManagerUnmerged = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallbackUnmerged);

            Assert.AreEqual(2, conversationManagerUnmerged.ConversationCount);
            VerifySuccessfulCompletion(progressCallbackUnmerged);

            IContact contactCellExpected = DummyConversationDataGenerator.GetContact(DummyPhoneNumberId.DavolaCell);
            IConversation conversationCellActual = conversationManagerUnmerged.GetConversation(0);
            Assert.AreEqual(1, conversationCellActual.AssociatedContacts.Count);
            Assert.AreEqual(contactCellExpected, conversationCellActual.AssociatedContacts[0]);

            IContact contactiPhoneExpected = DummyConversationDataGenerator.GetContact(DummyPhoneNumberId.DavolaiPhone);
            IConversation conversationiPhoneActual = conversationManagerUnmerged.GetConversation(1);
            Assert.AreEqual(1, conversationiPhoneActual.AssociatedContacts.Count);
            Assert.AreEqual(contactiPhoneExpected, conversationiPhoneActual.AssociatedContacts[0]);
        }
示例#20
0
        public void FindConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[]     dummyContactIds     = { DummyContactId.Davola, DummyContactId.Obama };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone, DummyPhoneNumberId.ObamaCell, DummyPhoneNumberId.UnknownLawnmower };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            VerifySuccessfulCompletion(progressCallback);

            int           conversationIndexExpected = 1;
            IConversation conversationToFind        = conversationManager.GetConversation(conversationIndexExpected);
            int           conversationIndexActual   = conversationManager.FindConversationIndex(conversationToFind);

            Assert.AreEqual(conversationIndexExpected, conversationIndexActual);

            IConversation missingConversation            = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.ReliableLarryOffice);
            int           missingConversationIndexActual = conversationManager.FindConversationIndex(missingConversation);

            Assert.AreEqual(-1, missingConversationIndexActual);
        }
示例#21
0
        public void ConversationWithNumberDuplicatesTest()
        {
            DummyContactId[]     dummyContactIds     = { DummyContactId.Davola, DummyContactId.DavolaNumberDuplicate };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            MockLoadingProgressCallback progressCallbackUnmerged    = new MockLoadingProgressCallback();
            ConversationManager         conversationManagerUnmerged = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallbackUnmerged);

            Assert.AreEqual(2, conversationManagerUnmerged.ConversationCount);
            VerifySuccessfulCompletion(progressCallbackUnmerged);

            IContact      contactCellExpected    = DummyConversationDataGenerator.GetContact(DummyPhoneNumberId.DavolaCell);
            IConversation conversationCellActual = conversationManagerUnmerged.GetConversation(0);

            Assert.AreEqual(1, conversationCellActual.AssociatedContacts.Count);
            Assert.AreEqual(contactCellExpected, conversationCellActual.AssociatedContacts[0]);

            IContact      contactiPhoneExpected    = DummyConversationDataGenerator.GetContact(DummyPhoneNumberId.DavolaiPhone);
            IConversation conversationiPhoneActual = conversationManagerUnmerged.GetConversation(1);

            Assert.AreEqual(1, conversationiPhoneActual.AssociatedContacts.Count);
            Assert.AreEqual(contactiPhoneExpected, conversationiPhoneActual.AssociatedContacts[0]);
        }
        public void EmptyTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(0, conversationManager.ConversationCount);

            Assert.AreEqual(0, progressCallback.Maximum);
            VerifySuccessfulCompletion(progressCallback);
        }
        public void UnmergedMultipleConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.Obama };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone, DummyPhoneNumberId.ObamaCell, DummyPhoneNumberId.UnknownLawnmower };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(4, conversationManager.ConversationCount);

            Assert.AreEqual(36, progressCallback.Maximum);
            VerifySuccessfulCompletion(progressCallback);
        }
        public void UnknownConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.UnknownLawnmower };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(1, conversationManager.ConversationCount);
            foreach (IConversationMessage message in conversationManager.GetConversation(0))
            {
                Assert.IsNotNull(message.Contact);
                Assert.AreEqual(Contact.UnknownContactId, message.Contact.ContactId);
            }

            VerifySuccessfulCompletion(progressCallback);
        }
        public void SingleContactTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { DummyContactId.Davola };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);

            Assert.AreEqual(2, conversationManager.ConversationCount);

            Assert.AreEqual(18, progressCallback.Maximum);
            VerifySuccessfulCompletion(progressCallback);
        }
        public void FindConversationTest()
        {
            MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback();

            DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.Obama };
            DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone, DummyPhoneNumberId.ObamaCell, DummyPhoneNumberId.UnknownLawnmower };

            ConversationManager conversationManager = CreateConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback);
            VerifySuccessfulCompletion(progressCallback);

            int conversationIndexExpected = 1;
            IConversation conversationToFind = conversationManager.GetConversation(conversationIndexExpected);
            int conversationIndexActual = conversationManager.FindConversationIndex(conversationToFind);
            Assert.AreEqual(conversationIndexExpected, conversationIndexActual);

            IConversation missingConversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.ReliableLarryOffice);
            int missingConversationIndexActual = conversationManager.FindConversationIndex(missingConversation);
            Assert.AreEqual(-1, missingConversationIndexActual);
        }