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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); } }