コード例 #1
0
        public void PopulatedModelTest()
        {
            GraphWindowModel_Accessor model = GetPopulatedGraphWindowModel();

            Assert.AreEqual(GraphWindowModel_Accessor.DefaultGraphType, model._selectedGraphType);
            Assert.AreEqual(GraphWindowModel_Accessor.DefaultConversationIndex, model.SelectedConversationIndex);

            IConversation conversation = model.SelectedConversation;

            Assert.IsInstanceOfType(conversation, typeof(AggregateConversation));
            IConversationStatistics statsExpected = ConversationStatisticsGenerator.CalculateStatistics(conversation);

            Assert.AreEqual(statsExpected, model.ConversationStatistics);
            Assert.AreEqual(conversation, model.DefaultConversation);
            Assert.IsNotNull(model.DisplayOptions);
            Assert.IsNotNull(model.PhoneSelectOptions);

            //
            // Nothing should be calculated until the graph data is demanded.
            //

            Assert.IsNull(model._cachedCurrentGraphData);
            Assert.IsNotNull(model.CurrentGraphDataCollection);
            Assert.IsNotNull(model._cachedCurrentGraphData);
        }
コード例 #2
0
 public static void VerifyStatisticsAllZero(IConversationStatistics stats)
 {
     Assert.AreEqual(0, stats.DayCount);
     Assert.AreEqual(0, stats.MessagesExchanged);
     Assert.AreEqual(0, stats.MessagesPerDay);
     Assert.AreEqual(0, stats.MessagesReceived);
     Assert.AreEqual(0, stats.MessagesSent);
 }
コード例 #3
0
 public static void VerifyStatisticsAllZero(IConversationStatistics stats)
 {
     Assert.AreEqual(0, stats.DayCount);
     Assert.AreEqual(0, stats.MessagesExchanged);
     Assert.AreEqual(0, stats.MessagesPerDay);
     Assert.AreEqual(0, stats.MessagesReceived);
     Assert.AreEqual(0, stats.MessagesSent);
 }
コード例 #4
0
        public void CalculateEmptyStatisticsTest()
        {
            Contact                 dummyContact = DummyConversationDataGenerator.GetContacts(DummyContactId.NeverTexter)[0];
            IConversation           conversation = new SingleNumberConversation(dummyContact);
            IConversationStatistics statsActual  = ConversationStatisticsGenerator.CalculateStatistics(conversation);

            Assert.AreEqual(0, statsActual.MessagesSent);
            Assert.AreEqual(0, statsActual.MessagesReceived);
            Assert.AreEqual(0, statsActual.MessagesExchanged);
            Assert.AreEqual(0, statsActual.DayCount);
            Assert.AreEqual(0, statsActual.MessagesPerDay);
        }
コード例 #5
0
        private void UpdateStatistics(IConversationStatistics stats)
        {
            if (stats == null)
            {
                return;
            }

            textsSentValueLabel.Content     = stats.MessagesSent.ToString();
            textsReceivedValueLabel.Content = stats.MessagesReceived.ToString();
            textsTotalValueLabel.Content    = stats.MessagesExchanged.ToString();
            daysValueLabel.Content          = stats.DayCount.ToString();
            textsPerDayValueLabel.Content   = string.Format("{0:0.0}", stats.MessagesPerDay);
        }
コード例 #6
0
        public void PopulatedConversationWindowModelTest()
        {
            ConversationWindowModel model = GetPopulatedConversationWindowModel();

            VerifyDefaultConversationModelSettings(model);

            List <IConversationListItem> conversationListItems = new List <IConversationListItem>(model.ConversationListItems);

            VerifyConversationListSortedAlphabetically(conversationListItems);

            IConversation           conversation       = conversationListItems[2].Conversation;
            IConversationStatistics expectedStatistics = ConversationStatisticsGenerator.CalculateStatistics(conversation);

            model.SelectedConversation = conversation;
            Assert.AreEqual(expectedStatistics, model.ConversationStatistics);
        }
コード例 #7
0
        public void CalculateAggregateConversationStatisticsTest()
        {
            IConversation[] conversations =
            {
                DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.TonyWolfCell),
                DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.VictoriaWolfCell),
            };
            AggregateConversation   aggregate   = new AggregateConversation(conversations);
            IConversationStatistics statsActual = ConversationStatisticsGenerator.CalculateStatistics(aggregate);

            int messagesSentExpected     = 31;
            int messagesReceivedExpected = aggregate.MessageCount - messagesSentExpected;
            int messagesTotalExpected    = aggregate.MessageCount;
            int daysTotalExpected        = 7;

            Assert.AreEqual(messagesSentExpected, statsActual.MessagesSent);
            Assert.AreEqual(messagesReceivedExpected, statsActual.MessagesReceived);
            Assert.AreEqual(messagesTotalExpected, statsActual.MessagesExchanged);
            Assert.AreEqual(daysTotalExpected, statsActual.DayCount);
        }
コード例 #8
0
        public void CalculateMultiDayStatisticsTest()
        {
            DummyContactId[] contactIds = { DummyContactId.ReliableLarry };
            List <Contact>   contacts   = DummyConversationDataGenerator.GetContacts(contactIds);

            DummyPhoneNumberId[]       messageSetIds = { DummyPhoneNumberId.ReliableLarryOffice };
            List <TextMessage>         messages      = DummyConversationDataGenerator.GetMessages(messageSetIds);
            List <ChatRoomInformation> chatInfoItems = new List <ChatRoomInformation>();

            ConversationManager conversationManager = new ConversationManager(contacts, messages, chatInfoItems, _attachments, null);

            IConversation           conversation = conversationManager.GetConversation(0);
            IConversationStatistics statsActual  = ConversationStatisticsGenerator.CalculateStatistics(conversation);

            int messagesSentExpected     = 5;
            int messagesReceivedExpected = messages.Count - messagesSentExpected;
            int messagesTotalExpected    = messages.Count;

            Assert.AreEqual(messagesSentExpected, statsActual.MessagesSent);
            Assert.AreEqual(messagesReceivedExpected, statsActual.MessagesReceived);
            Assert.AreEqual(messagesTotalExpected, statsActual.MessagesExchanged);
            Assert.AreEqual(5, statsActual.DayCount);
        }
コード例 #9
0
        public void SwitchConversationTest()
        {
            foreach (MainWindowModelBase_Accessor model in GetImplementations())
            {
                model.ConversationManager = CreateConversationManager();
                List <IConversationListItem> conversationListItems = new List <IConversationListItem>(model.ConversationListItems);

                Assert.AreEqual(model.DefaultConversation, model.SelectedConversation);

                IConversation           conversation2 = conversationListItems[2].Conversation;
                IConversationStatistics stats2        = ConversationStatisticsGenerator.CalculateStatistics(conversation2);
                IConversation           conversation4 = conversationListItems[3].Conversation;
                IConversationStatistics stats3        = ConversationStatisticsGenerator.CalculateStatistics(conversation4);

                model.SelectedConversation = conversation2;
                Assert.AreEqual(conversation2, model.SelectedConversation);
                Assert.AreEqual(stats2, model.ConversationStatistics);

                model.SelectedConversation = conversation4;
                Assert.AreEqual(conversation4, model.SelectedConversation);
                Assert.AreEqual(stats3, model.ConversationStatistics);

                model.SelectedConversation = conversation2;
                Assert.AreEqual(conversation2, model.SelectedConversation);

                model.SelectedConversation = null;
                Assert.AreEqual(model.DefaultConversation, model.SelectedConversation);

                model.SelectedConversation = conversation2;
                Assert.AreEqual(conversation2, model.SelectedConversation);

                IConversation missingConversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.TonyWolfCell);
                model.SelectedConversation = missingConversation;
                Assert.AreEqual(model.DefaultConversation, model.SelectedConversation);
            }
        }
コード例 #10
0
        private void UpdateStatistics(IConversationStatistics stats)
        {
            if (stats == null)
            {
                return;
            }

            textsSentValueLabel.Content = stats.MessagesSent.ToString();
            textsReceivedValueLabel.Content = stats.MessagesReceived.ToString();
            textsTotalValueLabel.Content = stats.MessagesExchanged.ToString();
            daysValueLabel.Content = stats.DayCount.ToString();
            textsPerDayValueLabel.Content = string.Format("{0:0.0}", stats.MessagesPerDay);
        }