From 3960f24f9977046778fb580a007690114606040b Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sat, 16 Apr 2022 22:04:57 -0500 Subject: [PATCH] test: Update some tests to use async/await --- .../Processors/PersistenceProcessorTest.cs | 14 ++++++------ .../QualityProfileApiPersistenceStepTest.cs | 22 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/TrashLib.Tests/Radarr/CustomFormat/Processors/PersistenceProcessorTest.cs b/src/TrashLib.Tests/Radarr/CustomFormat/Processors/PersistenceProcessorTest.cs index 37718e4c..fee8d628 100644 --- a/src/TrashLib.Tests/Radarr/CustomFormat/Processors/PersistenceProcessorTest.cs +++ b/src/TrashLib.Tests/Radarr/CustomFormat/Processors/PersistenceProcessorTest.cs @@ -16,7 +16,7 @@ namespace TrashLib.Tests.Radarr.CustomFormat.Processors; public class PersistenceProcessorTest { [Test] - public void Custom_formats_are_deleted_if_deletion_option_is_enabled_in_config() + public async Task Custom_formats_are_deleted_if_deletion_option_is_enabled_in_config() { var steps = Substitute.For(); var cfApi = Substitute.For(); @@ -30,13 +30,13 @@ public class PersistenceProcessorTest var profileScores = new Dictionary(); var processor = new PersistenceProcessor(cfApi, qpApi, configProvider, () => steps); - processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores); + await processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores); steps.JsonTransactionStep.Received().RecordDeletions(Arg.Is(deletedCfsInCache), Arg.Any>()); } [Test] - public void Custom_formats_are_not_deleted_if_deletion_option_is_disabled_in_config() + public async Task Custom_formats_are_not_deleted_if_deletion_option_is_disabled_in_config() { var steps = Substitute.For(); var cfApi = Substitute.For(); @@ -50,14 +50,14 @@ public class PersistenceProcessorTest var profileScores = new Dictionary(); var processor = new PersistenceProcessor(cfApi, qpApi, configProvider, () => steps); - processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores); + await processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores); steps.JsonTransactionStep.DidNotReceive() .RecordDeletions(Arg.Any>(), Arg.Any>()); } [Test] - public void Different_active_configuration_is_properly_used() + public async Task Different_active_configuration_is_properly_used() { var steps = Substitute.For(); var cfApi = Substitute.For(); @@ -71,10 +71,10 @@ public class PersistenceProcessorTest var processor = new PersistenceProcessor(cfApi, qpApi, configProvider, () => steps); configProvider.ActiveConfiguration = new RadarrConfiguration {DeleteOldCustomFormats = false}; - processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores); + await processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores); configProvider.ActiveConfiguration = new RadarrConfiguration {DeleteOldCustomFormats = true}; - processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores); + await processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores); steps.JsonTransactionStep.Received(1) .RecordDeletions(Arg.Any>(), Arg.Any>()); diff --git a/src/TrashLib.Tests/Radarr/CustomFormat/Processors/PersistenceSteps/QualityProfileApiPersistenceStepTest.cs b/src/TrashLib.Tests/Radarr/CustomFormat/Processors/PersistenceSteps/QualityProfileApiPersistenceStepTest.cs index 7fb0f9df..ad795c71 100644 --- a/src/TrashLib.Tests/Radarr/CustomFormat/Processors/PersistenceSteps/QualityProfileApiPersistenceStepTest.cs +++ b/src/TrashLib.Tests/Radarr/CustomFormat/Processors/PersistenceSteps/QualityProfileApiPersistenceStepTest.cs @@ -18,7 +18,7 @@ namespace TrashLib.Tests.Radarr.CustomFormat.Processors.PersistenceSteps; public class QualityProfileApiPersistenceStepTest { [Test] - public void Do_not_invoke_api_if_no_scores_to_update() + public async Task Do_not_invoke_api_if_no_scores_to_update() { const string radarrQualityProfileData = @"[{ 'name': 'profile1', @@ -56,13 +56,13 @@ public class QualityProfileApiPersistenceStepTest }; var processor = new QualityProfileApiPersistenceStep(); - processor.Process(api, cfScores); + await processor.Process(api, cfScores); - api.DidNotReceive().UpdateQualityProfile(Arg.Any(), Arg.Any()); + await api.DidNotReceive().UpdateQualityProfile(Arg.Any(), Arg.Any()); } [Test] - public void Invalid_quality_profile_names_are_reported() + public async Task Invalid_quality_profile_names_are_reported() { const string radarrQualityProfileData = @"[{'name': 'profile1'}]"; @@ -75,14 +75,14 @@ public class QualityProfileApiPersistenceStepTest }; var processor = new QualityProfileApiPersistenceStep(); - processor.Process(api, cfScores); + await processor.Process(api, cfScores); processor.InvalidProfileNames.Should().Equal("wrong_profile_name"); processor.UpdatedScores.Should().BeEmpty(); } [Test] - public void Reset_scores_for_unmatched_cfs_if_enabled() + public async Task Reset_scores_for_unmatched_cfs_if_enabled() { const string radarrQualityProfileData = @"[{ 'name': 'profile1', @@ -120,7 +120,7 @@ public class QualityProfileApiPersistenceStepTest }; var processor = new QualityProfileApiPersistenceStep(); - processor.Process(api, cfScores); + await processor.Process(api, cfScores); processor.InvalidProfileNames.Should().BeEmpty(); processor.UpdatedScores.Should() @@ -132,13 +132,13 @@ public class QualityProfileApiPersistenceStepTest new("cf3", 0, FormatScoreUpdateReason.Reset) }); - api.Received().UpdateQualityProfile( + await api.Received().UpdateQualityProfile( Verify.That(j => j["formatItems"]!.Children().Should().HaveCount(3)), Arg.Any()); } [Test] - public void Scores_are_set_in_quality_profile() + public async Task Scores_are_set_in_quality_profile() { const string radarrQualityProfileData = @"[{ 'name': 'profile1', @@ -207,7 +207,7 @@ public class QualityProfileApiPersistenceStepTest }; var processor = new QualityProfileApiPersistenceStep(); - processor.Process(api, cfScores); + await processor.Process(api, cfScores); var expectedProfileJson = JObject.Parse(@"{ 'name': 'profile1', @@ -250,7 +250,7 @@ public class QualityProfileApiPersistenceStepTest 'id': 1 }"); - api.Received() + await api.Received() .UpdateQualityProfile(Verify.That(a => a.Should().BeEquivalentTo(expectedProfileJson)), 1); processor.InvalidProfileNames.Should().BeEmpty(); processor.UpdatedScores.Should()