From c734bf4e6cefbfa2c2d28832aab9f3051126ba03 Mon Sep 17 00:00:00 2001 From: snixtho Date: Sat, 5 Oct 2024 10:58:19 +0200 Subject: [PATCH 1/2] Don't start manual tracking if automatic tracking is enabled. --- .../Controllers/MatchTrackerEventController.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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(); From 7c90bdff58ff98da14be31f0a11dac02b7c7d898 Mon Sep 17 00:00:00 2001 From: snixtho Date: Sat, 5 Oct 2024 11:02:20 +0200 Subject: [PATCH 2/2] add tests --- .../MatchTrackerEventControllerTests.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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); + } }