Skip to content

Commit 0dc1cb2

Browse files
committed
Stabilizing utility tests
1 parent 326ae7a commit 0dc1cb2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/UnitTests/UtilityTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public class UtilityTests
1414
public void LongestConsecutiveDecreasingSubset()
1515
{
1616
var numberOfDays = 10;
17-
var now = DateTimeOffset.UtcNow;
17+
var date = new DateTimeOffset(new DateTime(2025, 1, 1, 12, 0, 0, 0, DateTimeKind.Utc));
1818
var marketChartPoints = new List<MarketChartPoint>();
1919

2020
var price = new Random().Next(0, int.MaxValue);
2121

2222
marketChartPoints.Add(new MarketChartPoint
2323
{
24-
Date = now,
24+
Date = date,
2525
Price = price,
2626
MarketCap = new Random().Next(),
2727
TotalVolume = new Random().Next(),
@@ -31,7 +31,7 @@ public void LongestConsecutiveDecreasingSubset()
3131
{
3232
marketChartPoints.Add(new MarketChartPoint
3333
{
34-
Date = now.AddDays(i),
34+
Date = date.AddDays(i),
3535
Price = price - i,
3636
MarketCap = new Random().Next(),
3737
TotalVolume = new Random().Next(),
@@ -40,7 +40,7 @@ public void LongestConsecutiveDecreasingSubset()
4040

4141
marketChartPoints.Add(new MarketChartPoint
4242
{
43-
Date = now.AddDays(numberOfDays + 1),
43+
Date = date.AddDays(numberOfDays + 1),
4444
Price = price + 1,
4545
MarketCap = new Random().Next(),
4646
TotalVolume = new Random().Next(),
@@ -58,13 +58,13 @@ public void LongestConsecutiveDecreasingSubset()
5858
public void EarliestMarketChartPoints_Found()
5959
{
6060
var numberOfDays = 10;
61-
var now = DateTimeOffset.UtcNow;
61+
var date = new DateTimeOffset(new DateTime(2025, 1, 1, 12, 0, 0, 0, DateTimeKind.Utc));
6262
var marketChartPoints = new List<MarketChartPoint>();
6363
for (var i = 1; i < 24 * numberOfDays; i++)
6464
{
6565
marketChartPoints.Add(new MarketChartPoint
6666
{
67-
Date = now.AddHours(i),
67+
Date = date.AddHours(i),
6868
Price = new Random().Next(),
6969
MarketCap = new Random().Next(),
7070
TotalVolume = new Random().Next(),
@@ -74,7 +74,7 @@ public void EarliestMarketChartPoints_Found()
7474
var result = MarketChartHelper.GetEarliestMarketChartPointsByDate(marketChartPoints);
7575

7676
result.ShouldNotBeEmpty();
77-
if (now.TimeOfDay.Ticks == 0)
77+
if (date.TimeOfDay.Ticks == 0)
7878
{
7979
result.Count.ShouldBe(numberOfDays);
8080
}
@@ -92,17 +92,17 @@ public void MapMarketChartToMarketChartPoints_ShouldMapCorrectly()
9292
Prices =
9393
[
9494
[1629811200000, 45000],
95-
[1629897600000, 46000]
95+
[1629897600000, 46000]
9696
],
9797
MarketCaps =
9898
[
9999
[1629811200000, 850000000000],
100-
[1629897600000, 860000000000]
100+
[1629897600000, 860000000000]
101101
],
102102
TotalVolumes =
103103
[
104104
[1629811200000, 35000000000],
105-
[1629897600000, 36000000000]
105+
[1629897600000, 36000000000]
106106
]
107107
};
108108

0 commit comments

Comments
 (0)