public void TimelineStream_Receiver_Cleanup() { var receiveSpan = TimeSpan.FromMinutes(15); var segmentSpan = TimeSpan.FromMinutes(30); var now = DateTime.UtcNow - receiveSpan; var segments = new TimelineStream(receiveSpan, segmentSpan); var target = new[] { new Fragment { Arg1 = now.RoundLower(1) + segmentSpan * 2, Include1 = true, Arg2 = now.RoundLower(1) + segmentSpan * 2 + receiveSpan, Include2 = false, Entries = ToReference(Enumerable.Range(60, 15).Select(x => now + TimeSpan.FromMinutes(x)).ToArray()) }, new Fragment { Arg1 = now.RoundLower(1) + segmentSpan * 2 + receiveSpan, Include1 = true, Arg2 = null, Include2 = true, Entries = ToReference(Enumerable.Range(75, 15).Select(x => now + TimeSpan.FromMinutes(x)).ToArray()) } }; for (var i = 0; i < 90; i++) { segments.Create(now + TimeSpan.FromMinutes(i)); } segments.CleanupExpired(segments.GetItems().Skip(1).Select(x => x.ExpiresOn).First().Value); AssertFragments(target, segments.GetItems()); }
public void TimelineStream_Receiver_SetSegment_LX() { var receiveSpan = TimeSpan.FromMinutes(15); var segmentSpan = TimeSpan.FromMinutes(30); var now = DateTime.UtcNow - receiveSpan; var segments = new TimelineStream(receiveSpan, segmentSpan); var target = new[] { new Fragment { Arg1 = now.RoundLower(1), Include1 = true, Arg2 = now.RoundLower(1) + segmentSpan * 2 + receiveSpan, Include2 = false, Entries = ToReference(Enumerable.Range(0, 75).Select(x => now + TimeSpan.FromMinutes(x)).ToArray()) }, new Fragment { Arg1 = now.RoundLower(1) + segmentSpan * 2 + receiveSpan, Include1 = true, Arg2 = null, Include2 = true, Entries = ToReference(Enumerable.Range(75, 15).Select(x => now + TimeSpan.FromMinutes(x)).ToArray()) } }; for (var i = 0; i < 90; i++) { segments.Create(now + TimeSpan.FromMinutes(i)); } var result = segments.Set(Array.Empty <Reference>(), now.RoundLower(1), now.RoundLower(1) + TimeSpan.FromDays(1)); AssertFragments(target, segments.GetItems()); AssertSamples(result.ToArray(), ToReference(Enumerable.Range(0, 90).Select(x => now + TimeSpan.FromMinutes(x)).ToArray())); }
public void TimelineStream_Receiver_Clear() { var receiveSpan = TimeSpan.FromMinutes(15); var segmentSpan = TimeSpan.FromMinutes(30); var now = DateTime.UtcNow - receiveSpan; var segments = new TimelineStream(receiveSpan, segmentSpan); var target = new[] { new Fragment { Arg1 = now.RoundLower(1) + segmentSpan * 2 + receiveSpan, Include1 = true, Arg2 = null, Include2 = true, Entries = Array.Empty <Reference>().ToArray() } }; for (var i = 0; i < 90; i++) { segments.Create(now + TimeSpan.FromMinutes(i)); } segments.Clear(); AssertFragments(target, segments.GetItems()); }