-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathEventDisplayServiceTests.cs
More file actions
63 lines (49 loc) · 1.73 KB
/
EventDisplayServiceTests.cs
File metadata and controls
63 lines (49 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using SgfDevs.Dev;
using Xunit;
namespace SgfDevs.Tests;
public class EventDisplayServiceTests
{
private readonly EventDisplayService _service = new();
[Fact]
public void IsCurrentOrUpcoming_ReturnsTrueBeforeGracePeriodEnds()
{
var startsAtLocal = new DateTime(2026, 5, 6, 18, 30, 0);
var result = _service.IsCurrentOrUpcoming(startsAtLocal, new DateTime(2026, 5, 6, 19, 29, 59));
Assert.True(result);
}
[Fact]
public void IsCurrentOrUpcoming_ReturnsFalseOnceGracePeriodEnds()
{
var startsAtLocal = new DateTime(2026, 5, 6, 18, 30, 0);
var result = _service.IsCurrentOrUpcoming(startsAtLocal, new DateTime(2026, 5, 6, 19, 30, 0));
Assert.False(result);
}
[Fact]
public void GetCurrentOrNextEvent_SkipsExpiredEvents()
{
var now = new DateTime(2026, 5, 6, 20, 0, 0);
var events = new[]
{
new DateTime(2026, 5, 6, 18, 30, 0),
new DateTime(2026, 6, 3, 18, 30, 0)
};
var result = _service.GetCurrentOrNextEvent(events, static item => item, now);
Assert.Equal(new DateTime(2026, 6, 3, 18, 30, 0), result);
}
[Fact]
public void GetCurrentAndUpcomingEvents_ReturnsOnlyVisibleWindow()
{
var now = new DateTime(2026, 5, 6, 19, 0, 0);
var events = new[]
{
new DateTime(2026, 4, 1, 18, 30, 0),
new DateTime(2026, 5, 6, 18, 30, 0),
new DateTime(2026, 6, 3, 18, 30, 0)
};
var result = _service.GetCurrentAndUpcomingEvents(events, static item => item, now);
Assert.Equal(
[new DateTime(2026, 5, 6, 18, 30, 0), new DateTime(2026, 6, 3, 18, 30, 0)],
result);
}
}