public void Test_Ordering() { var t0 = DateTime.Now; var t1 = t0 + TimeSpan.FromSeconds(1); var t2 = t1 + TimeSpan.FromSeconds(1); var t3 = t2 + TimeSpan.FromSeconds(1); var sourceA = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t0)) }; var sourceB = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t1)) }; var sourceC = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t2)) }; var sourceD = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t3)) }; var result = ActivityTools.Merge( sourceA.Concat(sourceC), sourceB.Concat(sourceD) ).ToList(); Assert.IsTrue(result.SequenceEqual( sourceA.Concat(sourceB).Concat(sourceC).Concat(sourceD) )); }
public void Test_Chronological_Dual() { var t0 = DateTime.UtcNow; var t1 = t0 + TimeSpan.FromSeconds(1); var t2 = t1 + TimeSpan.FromSeconds(1); var t3 = t2 + TimeSpan.FromSeconds(1); var a0 = LivingLogger.GetSync(new Timestamp(t0)); var a1 = LivingLogger.GetSync(new Timestamp(t1)); var a2 = LivingLogger.GetSync(new Timestamp(t2)); var a3 = LivingLogger.GetSync(new Timestamp(t3)); var actA = new List <Activity>() { a0, a2 }; var actB = new List <Activity>() { a1, a3 }; var activities = actA.Concat(actB); var result = ActivityTools.PartitionChronological(activities); var expected = new List <List <Activity> >() { actA, actB }; Assert.IsTrue(PartitionEqual(expected, result)); }
public void Test_Chronological_AntiChrono() { var t0 = DateTime.UtcNow; var t1 = t0 + TimeSpan.FromSeconds(1); var t2 = t1 + TimeSpan.FromSeconds(1); var t3 = t2 + TimeSpan.FromSeconds(1); var a0 = LivingLogger.GetSync(new Timestamp(t0)); var a1 = LivingLogger.GetSync(new Timestamp(t1)); var a2 = LivingLogger.GetSync(new Timestamp(t2)); var a3 = LivingLogger.GetSync(new Timestamp(t3)); var act0 = Enumerable.Repeat(a0, 1); var act1 = Enumerable.Repeat(a1, 1); var act2 = Enumerable.Repeat(a2, 1); var act3 = Enumerable.Repeat(a3, 1); var activities = act3.Concat(act2).Concat(act1).Concat(act0); var result = ActivityTools.PartitionChronological(activities); var expected = new List <IEnumerable <Activity> >() { act3, act2, act1, act0 }; Assert.IsTrue(PartitionEqual(expected, result)); }
public void Test_Chronological_Single() { var a = LivingLogger.GetSync(); var activities = Enumerable.Repeat(a, 1); var result = ActivityTools.PartitionChronological(activities); var expected = Enumerable.Repeat(activities, 1); Assert.IsTrue(PartitionEqual(expected, result)); }
public void Test_HasNull() { var activities = new List <Activity>(); activities.Add(LivingLogger.GetSync()); activities.Add(null); Assert.IsFalse(ActivityTools.IsValid(activities)); }
public void Test_Empty_2() { var sourceA = new List <Activity>() { LivingLogger.GetSync() }; var sourceB = Enumerable.Empty <Activity>(); var result = ActivityTools.Merge(sourceA, sourceB).ToList(); Assert.IsTrue(result.SequenceEqual(sourceA)); }
public void Test_NonChronological() { var t0 = DateTime.UtcNow; var t1 = t0 - TimeSpan.FromSeconds(1); var activities = new List <Activity>(); activities.Add(LivingLogger.GetSync(new Timestamp(t0))); activities.Add(LivingLogger.GetSync(new Timestamp(t1))); Assert.IsFalse(ActivityTools.IsValid(activities)); }
public void Test_Unknown() { var t0 = DateTime.UtcNow; var t1 = t0 + TimeSpan.FromSeconds(1); var activities = new List <Activity>(); activities.Add(LivingLogger.GetSync(new Timestamp(t0))); activities.Add(new Activity() { Timestamp = new Timestamp(t1), Type = Category.Unknown, }); Assert.IsFalse(ActivityTools.IsValid(activities)); }
public void Test_First_2() { var t0 = DateTime.Now; var t1 = t0 + TimeSpan.FromSeconds(1); var sourceA = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t1)) }; var sourceB = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t0)) }; var result = ActivityTools.Merge(sourceA, sourceB).ToList(); Assert.IsTrue(result.SequenceEqual(sourceB.Concat(sourceA))); }