public void CleanResultsInEmptyDiff() { Log<ChatMessage> chatMsgLog = new Log<ChatMessage>(); chatMsgLog.Add(new ChatMessage() { ClientName = "1", Message = "beef" }); chatMsgLog.Add(new ChatMessage() { ClientName = "2", Message = "stick" }); chatMsgLog.Clean(); Assert.AreEqual(0, chatMsgLog.GetDiff().Count); }
public void BuildsDiffCorrectly() { Log<ChatMessage> chatMsgLog = new Log<ChatMessage>(); chatMsgLog.Add(new ChatMessage() { ClientName = "1", Message = "beef" }); chatMsgLog.Add(new ChatMessage() { ClientName = "2", Message = "stick" }); Assert.AreEqual(2, chatMsgLog.GetDiff().Count); Assert.AreEqual("stick", chatMsgLog.GetDiff()[0].Message); Assert.AreEqual("beef", chatMsgLog.GetDiff()[1].Message); }
public void LogReturnsMessagesWithNewestFirst() { Log<string> chatMsgLog = new Log<string>(); chatMsgLog.Add("1"); chatMsgLog.Add("2"); chatMsgLog.Add("3"); foreach (string message in chatMsgLog) { Assert.AreEqual("3", message); break; } }
public void CanIterateThroughLog() { Log<string> chatMsgLog = new Log<string>(); chatMsgLog.Add("hello there"); chatMsgLog.Add("you suck"); chatMsgLog.Add("i'm just kidding, you're pretty cool."); int count = 0; foreach (string message in chatMsgLog) { count++; } Assert.AreEqual(3, count); }
public void CanBuildALogOfChatMessages() { Log<ChatMessage> chatMsgLog = new Log<ChatMessage>(); chatMsgLog.Add(new ChatMessage() { ClientName = "Zak", Message = "yo" }); Assert.AreEqual(1, chatMsgLog.Count); }
public void AddingMessagesSetsIsDirty() { Log<ChatMessage> chatMsgLog = new Log<ChatMessage>(); Assert.IsFalse(chatMsgLog.IsDirty); chatMsgLog.Add(new ChatMessage() { ClientName = "zak", Message = "h**o" }); Assert.IsTrue(chatMsgLog.IsDirty); }
public void CanIterateThroughLogFromOldestToNewest() { Log<string> chatLog = new Log<string>(); chatLog.Add("old"); chatLog.Add("new"); int count = 1; foreach (string msg in chatLog.OldestToNewest) { if (count == 1) Assert.AreEqual("old", msg); if (count == 2) Assert.AreEqual("new", msg); count++; } }
public void CanStripOldestMessage() { Log<string> log = new Log<string>(); log.Add("old msg"); log.Add("newer msg"); Assert.AreEqual("old msg", log.StripOldestMessage()); Assert.AreEqual("newer msg", log.StripOldestMessage()); }
public void KeepsCount() { Log<string> chatMsgLog = new Log<string>(); chatMsgLog.Add("1"); chatMsgLog.Add("2"); Assert.AreEqual(2, chatMsgLog.Count); }
public void CanAccessElementsMoreThanOnce() { Log<string> chatMsgLog = new Log<string>(); chatMsgLog.Add("hey"); foreach (string message in chatMsgLog) Assert.AreEqual("hey", message); foreach (string message in chatMsgLog) Assert.AreEqual("hey", message); }
public void LogIndexesMessagesWithNewestAtZero() { Log<string> chatMsgLog = new Log<string>(); chatMsgLog.Add("1"); chatMsgLog.Add("2"); chatMsgLog.Add("3"); Assert.AreEqual("3", chatMsgLog[0]); Assert.AreEqual("1", chatMsgLog[2]); }