public void RemoveDuplicatedMessage_AllSame_RemoveTheDuplicated() { var combiner = new MsnHistoryCombiner(); combiner.MergedMsnLog = new MsnLog(); combiner.MergedMsnLog.Messages.Add(new MsnMessage(null) { From = new MsnDirection(null, MsnDirectionType.From) { User = new List<MsnUser> { new MsnUser(null) { FriendlyName = "Jerry" } } }, SessionID = 1, UniversalTime = DateTime.Now, Text = new MsnText(null) { Style = "bold", Value = "Test the unit" }, }); combiner.MergedMsnLog.Messages.Add(new MsnMessage(null) { From = new MsnDirection(null, MsnDirectionType.From) { User = new List<MsnUser> { new MsnUser(null) { FriendlyName = "Jerry" } } }, SessionID = 1, UniversalTime = DateTime.Now.AddMilliseconds(20), Text = new MsnText(null) { Style = "bold", Value = "Test the unit" }, }); combiner.MergedMsnLog.Messages.Add(new MsnMessage(null) { From = new MsnDirection(null, MsnDirectionType.From) { User = new List<MsnUser> { new MsnUser(null) { FriendlyName = "Jerry" } } }, SessionID = 1, UniversalTime = DateTime.Now.AddMilliseconds(400), Text = new MsnText(null) { Style = "bold", Value = "Test the unit" }, }); combiner.RemoveDuplicatedMessage(); Assert.AreEqual(1, combiner.MergedMsnLog.Messages.Count); }
public void RemoveDuplicatedMessage_TextAllSameButTheDiffOfTimeOfFirstAndSecondIsTooBig_JustRemoveTheThird() { var combiner = new MsnHistoryCombiner(); combiner.MergedMsnLog = new MsnLog(); combiner.MergedMsnLog.Messages.Add(new MsnMessage(null) { From = new MsnDirection(null, MsnDirectionType.From) { User = new List<MsnUser> { new MsnUser(null) { FriendlyName = "Jerry" } } }, SessionID = 1, UniversalTime = DateTime.Now, Text = new MsnText(null) { Style = "bold", Value = "Test the unit" }, }); // This time diff is very big (great than 10 seconds) combiner.MergedMsnLog.Messages.Add(new MsnMessage(null) { From = new MsnDirection(null, MsnDirectionType.From) { User = new List<MsnUser> { new MsnUser(null) { FriendlyName = "Jerry" } } }, SessionID = 1, UniversalTime = DateTime.Now.AddSeconds(11), Text = new MsnText(null) { Style = "bold", Value = "Test the unit" }, }); combiner.MergedMsnLog.Messages.Add(new MsnMessage(null) { From = new MsnDirection(null, MsnDirectionType.From) { User = new List<MsnUser> { new MsnUser(null) { FriendlyName = "Jerry" } } }, SessionID = 1, UniversalTime = DateTime.Now.AddSeconds(12), Text = new MsnText(null) { Style = "bold", Value = "Test the unit" }, }); combiner.RemoveDuplicatedMessage(); Assert.AreEqual(2, combiner.MergedMsnLog.Messages.Count); }