Skip to content

Commit

Permalink
Don't start manual tracking if automatic tracking is enabled. (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
snixtho authored Oct 5, 2024
1 parent af73895 commit e9ad8ea
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ public Task OnBeginMatchAsync(object sender, EventArgs args)
}

[Subscribe(FlowControlEvent.MatchStarted)]
public Task OnMatchStarted(object sender, EventArgs args) => tracker.BeginMatchAsync();
public Task OnMatchStarted(object sender, EventArgs args)
{
if (settings.AutomaticTracking)
{
return Task.CompletedTask;
}

return tracker.BeginMatchAsync();
}

[Subscribe(FlowControlEvent.MatchEnded)]
public Task OnMatchEnded(object sender, EventArgs args) => tracker.EndMatchAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,24 @@ public async Task Begin_Match_Is_Tracked_Depending_On_Settings(bool automaticTra

_tracker.Verify(m => m.BeginMatchAsync(), timesCalled);
}

[Fact]
public async Task Manual_Match_Tracking_Is_Disabled_If_Automatic_Tracking_Is_Enabled()
{
_settings.Setup(m => m.AutomaticTracking).Returns(true);

await Controller.OnMatchStarted(null, null);

Check warning on line 58 in tests/Modules/MatchTrackerModule.Tests/Controllers/MatchTrackerEventControllerTests.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot convert null literal to non-nullable reference type.

Cannot convert null literal to non-nullable reference type

Check warning on line 58 in tests/Modules/MatchTrackerModule.Tests/Controllers/MatchTrackerEventControllerTests.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot convert null literal to non-nullable reference type.

Cannot convert null literal to non-nullable reference type

_tracker.Verify(m => m.BeginMatchAsync(), Times.Never);
}

[Fact]
public async Task Manual_Match_Tracking_Is_Triggered_If_Automatic_Tracking_Is_Disabled()
{
_settings.Setup(m => m.AutomaticTracking).Returns(false);

await Controller.OnMatchStarted(null, null);

Check warning on line 68 in tests/Modules/MatchTrackerModule.Tests/Controllers/MatchTrackerEventControllerTests.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot convert null literal to non-nullable reference type.

Cannot convert null literal to non-nullable reference type

Check warning on line 68 in tests/Modules/MatchTrackerModule.Tests/Controllers/MatchTrackerEventControllerTests.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot convert null literal to non-nullable reference type.

Cannot convert null literal to non-nullable reference type

_tracker.Verify(m => m.BeginMatchAsync(), Times.Once);
}
}

0 comments on commit e9ad8ea

Please sign in to comment.