diff --git a/src/Modules/MatchTrackerModule/Controllers/MatchTrackerEventController.cs b/src/Modules/MatchTrackerModule/Controllers/MatchTrackerEventController.cs index 5ba23a519..ffa353ba7 100644 --- a/src/Modules/MatchTrackerModule/Controllers/MatchTrackerEventController.cs +++ b/src/Modules/MatchTrackerModule/Controllers/MatchTrackerEventController.cs @@ -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(); diff --git a/tests/Modules/MatchTrackerModule.Tests/Controllers/MatchTrackerEventControllerTests.cs b/tests/Modules/MatchTrackerModule.Tests/Controllers/MatchTrackerEventControllerTests.cs index 0dcfaaed3..da20eaf4d 100644 --- a/tests/Modules/MatchTrackerModule.Tests/Controllers/MatchTrackerEventControllerTests.cs +++ b/tests/Modules/MatchTrackerModule.Tests/Controllers/MatchTrackerEventControllerTests.cs @@ -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); + + _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); + + _tracker.Verify(m => m.BeginMatchAsync(), Times.Once); + } }