Skip to content

Commit

Permalink
Basic timing session test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbl4 committed Aug 16, 2023
1 parent 98d5754 commit 4b6c2cd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Tests/IntegrationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ public ServiceRunner<Startup> CreateCheckpointService(int pauseStartupMs = 0, in
var svc = new ServiceRunner<Race.DataService.Startup>();
svc.Start(new[]
{
$"--ServiceOptions:StorageConnectionString={storageConnectionString}",
$"--StorageServiceOptions:StorageConnectionString={storageConnectionString}",
$"--ServiceOptions:PauseInStartupMs={pauseStartupMs}",
$"--SeedDataLoaderOptions:SeedDataDirectory=.",
$"--Environment={Environments.Development}",
"--Urls=http://127.0.0.1:0"
}).Wait(0);
Expand Down
33 changes: 33 additions & 0 deletions Tests/Logic/EventModel/Runtime/TimingSessionServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using FluentAssertions;
using maxbl4.Infrastructure.MessageHub;
using maxbl4.Race.Logic.AutoMapper;
using maxbl4.Race.Logic.Checkpoints;
using maxbl4.Race.Logic.CheckpointService;
using maxbl4.Race.Logic.CheckpointService.Client;
using maxbl4.Race.Logic.EventModel.Runtime;
Expand Down Expand Up @@ -83,5 +84,37 @@ public async Task Create_and_start_timing_session()
//recordingService.StopRecording();
//recordingRepository.GetActiveRecordingSession().Should().BeNull();
}

[Fact]
public async Task Create_and_start_timing_session2()
{
using var storageService = new StorageService(Options.Create(new StorageServiceOptions{StorageConnectionString = storageConnectionString}), MessageHub);
var upstreamDataStorage = new UpstreamDataRepository(storageService);
var checkpointRepository = new CheckpointRepository(Options.Create(new ServiceOptions()), storageService, MessageHub, SystemClock);
var eventRepository = new EventRepository(storageService, upstreamDataStorage, new AutoMapperProvider());
var upstreamDataSyncService = new UpstreamDataSyncService(Options.Create(upstreamDataSyncServiceOptions), new FakeMainClient(),
upstreamDataStorage, MessageHub);
var downloadResult = await upstreamDataSyncService.Download(true);
downloadResult.Should().BeTrue();
upstreamDataStorage.ListSeries().Should().HaveCount(4);

storageService.Repo.Query<CheckpointDto>().Count().Should().Be(0);

var timingSessionService = new TimingSessionService(checkpointRepository, eventRepository, MessageHub, new AutoMapperProvider(),
new DefaultSystemClock());

var ev = upstreamDataStorage.ListEvents().First(x => x.Name == "Тучково кантри 12.09.2020");

var session = upstreamDataStorage.ListSessions(ev.Id).First(x => x.Name == "Эксперт и Опен");
var tsId = timingSessionService.StartNewSession("timing sess", session.Id);

MessageHub.Publish(new Checkpoint("11", DateTime.UtcNow));
await Task.Delay(100);

var update = timingSessionService.GetTimingSessionRating(tsId);
update.Rating.Should().HaveCount(1);

//storageService.Repo.Query<Checkpoint>().Count().Should().Be(1);
}
}
}

0 comments on commit 4b6c2cd

Please sign in to comment.