From a7b1ab2599b55a881241c9126dbc8e8dfec46acc Mon Sep 17 00:00:00 2001 From: Manan Habib Date: Tue, 15 Aug 2023 17:53:36 +0500 Subject: [PATCH 1/3] Added unit tests and restructured folders (#1) 1. Moved projects to dedicated projects' folder. 2. Updated gitignore 3. Added unit tests --- .gitignore | 50 ++++++++++++++++--- ...heus.Client.MetricPusher.HostedService.sln | 25 +++++++--- .../GlobalUsings.cs | 2 + .../MetricPusherServiceTests.cs | 26 ++++++++++ ...nt.MetricPusher.HostedService.Tests.csproj | 32 ++++++++++++ .../ServiceCollecttionExtensionsTests.cs | 42 ++++++++++++++++ .../MetricPusherService.cs | 0 ...s.Client.MetricPusher.HostedService.csproj | 0 .../ServiceCollectionExtensions.cs | 0 9 files changed, 163 insertions(+), 14 deletions(-) create mode 100644 src/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs create mode 100644 src/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs create mode 100644 src/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj create mode 100644 src/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs rename src/{ => Prometheus.Client.MetricPusher.HostedService}/MetricPusherService.cs (100%) rename src/{ => Prometheus.Client.MetricPusher.HostedService}/Prometheus.Client.MetricPusher.HostedService.csproj (100%) rename src/{ => Prometheus.Client.MetricPusher.HostedService}/ServiceCollectionExtensions.cs (100%) diff --git a/.gitignore b/.gitignore index 7921d33..f8771ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,43 @@ +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode/ + +# Rider +.idea/ + +# Visual Studio +.vs/ + +# Fleet +.fleet/ + +# Code Rush +.cr/ + +# User-specific files +*.suo *.user -*.opencover.xml -*.orig -*.nupkg -*.snupkg -.idea -bin -obj -BenchmarkDotNet.Artifacts +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn \ No newline at end of file diff --git a/Prometheus.Client.MetricPusher.HostedService.sln b/Prometheus.Client.MetricPusher.HostedService.sln index 38629b5..4d164fc 100644 --- a/Prometheus.Client.MetricPusher.HostedService.sln +++ b/Prometheus.Client.MetricPusher.HostedService.sln @@ -1,6 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prometheus.Client.MetricPusher.HostedService", "src\Prometheus.Client.MetricPusher.HostedService.csproj", "{C77EB3BB-08D7-4B18-9833-6D5486AA42C8}" +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34003.232 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prometheus.Client.MetricPusher.HostedService", "src\Prometheus.Client.MetricPusher.HostedService\Prometheus.Client.MetricPusher.HostedService.csproj", "{CD73BF99-211A-496F-983B-A55A22DE4FEE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prometheus.Client.MetricPusher.HostedService.Tests", "src\Prometheus.Client.MetricPusher.HostedService.Tests\Prometheus.Client.MetricPusher.HostedService.Tests.csproj", "{33C6BDD1-6FAF-4EBC-83DE-B10895F69848}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -8,11 +13,19 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C77EB3BB-08D7-4B18-9833-6D5486AA42C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C77EB3BB-08D7-4B18-9833-6D5486AA42C8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C77EB3BB-08D7-4B18-9833-6D5486AA42C8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C77EB3BB-08D7-4B18-9833-6D5486AA42C8}.Release|Any CPU.Build.0 = Release|Any CPU + {CD73BF99-211A-496F-983B-A55A22DE4FEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD73BF99-211A-496F-983B-A55A22DE4FEE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD73BF99-211A-496F-983B-A55A22DE4FEE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD73BF99-211A-496F-983B-A55A22DE4FEE}.Release|Any CPU.Build.0 = Release|Any CPU + {33C6BDD1-6FAF-4EBC-83DE-B10895F69848}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {33C6BDD1-6FAF-4EBC-83DE-B10895F69848}.Debug|Any CPU.Build.0 = Debug|Any CPU + {33C6BDD1-6FAF-4EBC-83DE-B10895F69848}.Release|Any CPU.ActiveCfg = Release|Any CPU + {33C6BDD1-6FAF-4EBC-83DE-B10895F69848}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2A144989-FB17-400D-A3E8-78C7534AF12F} EndGlobalSection EndGlobal diff --git a/src/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs b/src/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs new file mode 100644 index 0000000..91743bb --- /dev/null +++ b/src/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using Xunit; +global using FluentAssertions; diff --git a/src/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs b/src/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs new file mode 100644 index 0000000..15644ad --- /dev/null +++ b/src/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Moq; + +namespace Prometheus.Client.MetricPusher.HostedService.Tests +{ + public class MetricPusherServiceTests + { + [Fact] + public async Task WithGivenInterval_PushMetricPeriodically() + { + var metricPusherMock = new Moq.Mock(); + var metricPusherService = new MetricPusherService(metricPusherMock.Object, TimeSpan.FromSeconds(1)); + var canellationToken = It.IsAny(); + + await metricPusherService.StartAsync(canellationToken); + await Task.Delay(TimeSpan.FromSeconds(1)); + await metricPusherService.StopAsync(canellationToken); + + metricPusherMock.Verify(o => o.PushAsync(), Moq.Times.AtLeast(2)); + } + } +} diff --git a/src/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj b/src/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj new file mode 100644 index 0000000..0efe4ae --- /dev/null +++ b/src/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj @@ -0,0 +1,32 @@ + + + + net6.0 + enable + enable + + false + true + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/src/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs b/src/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs new file mode 100644 index 0000000..99c4e93 --- /dev/null +++ b/src/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs @@ -0,0 +1,42 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Prometheus.Client.MetricPusher.HostedService.Tests +{ + public class ServiceCollecttionExtensionsTests + { + [Fact] + public void AddMetricPusherService_WithNullMetricPusher_ThrowsArgumentNullException() + { + IServiceCollection servicesCollection = Moq.Mock.Of(); + + Action act = () => ServiceCollectionExtensions.AddMetricPusherService(servicesCollection, null, TimeSpan.FromSeconds(1)); + + act.Should().Throw(); + } + + [Fact] + public void AddMetricPusherService_WithZeroTimeInterval_ThrowsArgumentOutOfRangeException() + { + IServiceCollection servicesCollection = Moq.Mock.Of(); + IMetricPusher metricPusher = Moq.Mock.Of(); + + Action act = () => ServiceCollectionExtensions.AddMetricPusherService(servicesCollection, metricPusher, TimeSpan.Zero); + + act.Should().Throw(); + } + + [Fact] + public void AddMetricPusherService_WithValidParameterValues_AddsMetricPusherServiceInServiceCollection() + { + IServiceCollection servicesCollection = new ServiceCollection(); + IMetricPusher metricPusher = Moq.Mock.Of(); + + ServiceCollectionExtensions.AddMetricPusherService(servicesCollection, metricPusher, TimeSpan.FromSeconds(1)); + var provider = servicesCollection.BuildServiceProvider(); + var service = provider.GetRequiredService(); + + service.Should().BeOfType(); + } + } +} diff --git a/src/MetricPusherService.cs b/src/Prometheus.Client.MetricPusher.HostedService/MetricPusherService.cs similarity index 100% rename from src/MetricPusherService.cs rename to src/Prometheus.Client.MetricPusher.HostedService/MetricPusherService.cs diff --git a/src/Prometheus.Client.MetricPusher.HostedService.csproj b/src/Prometheus.Client.MetricPusher.HostedService/Prometheus.Client.MetricPusher.HostedService.csproj similarity index 100% rename from src/Prometheus.Client.MetricPusher.HostedService.csproj rename to src/Prometheus.Client.MetricPusher.HostedService/Prometheus.Client.MetricPusher.HostedService.csproj diff --git a/src/ServiceCollectionExtensions.cs b/src/Prometheus.Client.MetricPusher.HostedService/ServiceCollectionExtensions.cs similarity index 100% rename from src/ServiceCollectionExtensions.cs rename to src/Prometheus.Client.MetricPusher.HostedService/ServiceCollectionExtensions.cs From c5f2afd053dca8c36782ad7e236248c7ed57aa2c Mon Sep 17 00:00:00 2001 From: Manan Habib Date: Wed, 16 Aug 2023 14:07:26 +0500 Subject: [PATCH 2/3] PR comments changes (#2) * Added unit tests and restructured folders 1. Moved projects to dedicated projects' folder. 2. Updated gitignore 3. Added unit tests * PR comments changes 1. Changed project structure 2. Updated package references 3. Replaced Moq with NSubstitute 4. Refactoring --- .gitignore | 35 +------------ ...heus.Client.MetricPusher.HostedService.sln | 12 ++--- .../GlobalUsings.cs | 4 ++ .../MetricPusherServiceTests.cs | 22 ++++++++ ...nt.MetricPusher.HostedService.Tests.csproj | 50 +++++++++++++++++++ .../ServiceCollecttionExtensionsTests.cs | 42 ++++++++++++++++ 6 files changed, 125 insertions(+), 40 deletions(-) create mode 100644 tests/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs create mode 100644 tests/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs create mode 100644 tests/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj create mode 100644 tests/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs diff --git a/.gitignore b/.gitignore index f8771ad..f614603 100644 --- a/.gitignore +++ b/.gitignore @@ -1,43 +1,10 @@ -*.swp -*.*~ -project.lock.json -.DS_Store -*.pyc -nupkg/ - -# Visual Studio Code -.vscode/ - # Rider .idea/ # Visual Studio .vs/ -# Fleet -.fleet/ - -# Code Rush -.cr/ - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - # Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ [Bb]in/ [Oo]bj/ -[Oo]ut/ -msbuild.log -msbuild.err -msbuild.wrn \ No newline at end of file + diff --git a/Prometheus.Client.MetricPusher.HostedService.sln b/Prometheus.Client.MetricPusher.HostedService.sln index 4d164fc..a153e82 100644 --- a/Prometheus.Client.MetricPusher.HostedService.sln +++ b/Prometheus.Client.MetricPusher.HostedService.sln @@ -1,11 +1,11 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.34003.232 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prometheus.Client.MetricPusher.HostedService", "src\Prometheus.Client.MetricPusher.HostedService\Prometheus.Client.MetricPusher.HostedService.csproj", "{CD73BF99-211A-496F-983B-A55A22DE4FEE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prometheus.Client.MetricPusher.HostedService.Tests", "src\Prometheus.Client.MetricPusher.HostedService.Tests\Prometheus.Client.MetricPusher.HostedService.Tests.csproj", "{33C6BDD1-6FAF-4EBC-83DE-B10895F69848}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prometheus.Client.MetricPusher.HostedService.Tests", "tests\Prometheus.Client.MetricPusher.HostedService.Tests\Prometheus.Client.MetricPusher.HostedService.Tests.csproj", "{2CC30054-6E22-4112-9DB1-7FFA154B92FD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,10 +17,10 @@ Global {CD73BF99-211A-496F-983B-A55A22DE4FEE}.Debug|Any CPU.Build.0 = Debug|Any CPU {CD73BF99-211A-496F-983B-A55A22DE4FEE}.Release|Any CPU.ActiveCfg = Release|Any CPU {CD73BF99-211A-496F-983B-A55A22DE4FEE}.Release|Any CPU.Build.0 = Release|Any CPU - {33C6BDD1-6FAF-4EBC-83DE-B10895F69848}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {33C6BDD1-6FAF-4EBC-83DE-B10895F69848}.Debug|Any CPU.Build.0 = Debug|Any CPU - {33C6BDD1-6FAF-4EBC-83DE-B10895F69848}.Release|Any CPU.ActiveCfg = Release|Any CPU - {33C6BDD1-6FAF-4EBC-83DE-B10895F69848}.Release|Any CPU.Build.0 = Release|Any CPU + {2CC30054-6E22-4112-9DB1-7FFA154B92FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CC30054-6E22-4112-9DB1-7FFA154B92FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CC30054-6E22-4112-9DB1-7FFA154B92FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CC30054-6E22-4112-9DB1-7FFA154B92FD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tests/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs b/tests/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs new file mode 100644 index 0000000..3c3d664 --- /dev/null +++ b/tests/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs @@ -0,0 +1,4 @@ +global using Xunit; +global using FluentAssertions; +global using NSubstitute; +global using System; diff --git a/tests/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs b/tests/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs new file mode 100644 index 0000000..974008d --- /dev/null +++ b/tests/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs @@ -0,0 +1,22 @@ +using System.Threading; +using System.Threading.Tasks; + +namespace Prometheus.Client.MetricPusher.HostedService.Tests +{ + public class MetricPusherServiceTests + { + [Fact] + public async Task WithGivenInterval_PushMetricPeriodically() + { + var metricPusherMock = Substitute.For(); + var metricPusherService = new MetricPusherService(metricPusherMock, TimeSpan.FromSeconds(1)); + var canellationToken = Arg.Any(); + + await metricPusherService.StartAsync(canellationToken); + await Task.Delay(TimeSpan.FromSeconds(1), canellationToken); + await metricPusherService.StopAsync(canellationToken); + + await metricPusherMock.Received(3).PushAsync(); + } + } +} diff --git a/tests/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj b/tests/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj new file mode 100644 index 0000000..953757a --- /dev/null +++ b/tests/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj @@ -0,0 +1,50 @@ + + + + netcoreapp3.1;net6.0;net7.0 + false + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + + + + + + diff --git a/tests/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs b/tests/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs new file mode 100644 index 0000000..7e6f8e1 --- /dev/null +++ b/tests/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs @@ -0,0 +1,42 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Prometheus.Client.MetricPusher.HostedService.Tests +{ + public class ServiceCollecttionExtensionsTests + { + [Fact] + public void AddMetricPusherService_WithNullMetricPusher_ThrowsArgumentNullException() + { + var servicesCollection = Substitute.For(); + + Action act = () => servicesCollection.AddMetricPusherService(null, TimeSpan.FromSeconds(1)); + + act.Should().Throw(); + } + + [Fact] + public void AddMetricPusherService_WithZeroTimeInterval_ThrowsArgumentOutOfRangeException() + { + var servicesCollection = Substitute.For(); + var metricPusher = Substitute.For(); + + Action act = () => servicesCollection.AddMetricPusherService(metricPusher, TimeSpan.Zero); + + act.Should().Throw(); + } + + [Fact] + public void AddMetricPusherService_WithValidParameterValues_AddsMetricPusherServiceInServiceCollection() + { + var servicesCollection = new ServiceCollection(); + var metricPusher = Substitute.For(); + + servicesCollection.AddMetricPusherService(metricPusher, TimeSpan.FromSeconds(1)); + var provider = servicesCollection.BuildServiceProvider(); + var service = provider.GetRequiredService(); + + service.Should().BeOfType(); + } + } +} From 6b0261a3ccbb3d19ca4d2e63cc84aa009109ba18 Mon Sep 17 00:00:00 2001 From: Manan Habib Date: Wed, 16 Aug 2023 14:23:55 +0500 Subject: [PATCH 3/3] Deleted folder --- .../GlobalUsings.cs | 2 - .../MetricPusherServiceTests.cs | 26 ------------ ...nt.MetricPusher.HostedService.Tests.csproj | 32 -------------- .../ServiceCollecttionExtensionsTests.cs | 42 ------------------- 4 files changed, 102 deletions(-) delete mode 100644 src/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs delete mode 100644 src/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs delete mode 100644 src/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj delete mode 100644 src/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs diff --git a/src/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs b/src/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs deleted file mode 100644 index 91743bb..0000000 --- a/src/Prometheus.Client.MetricPusher.HostedService.Tests/GlobalUsings.cs +++ /dev/null @@ -1,2 +0,0 @@ -global using Xunit; -global using FluentAssertions; diff --git a/src/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs b/src/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs deleted file mode 100644 index 15644ad..0000000 --- a/src/Prometheus.Client.MetricPusher.HostedService.Tests/MetricPusherServiceTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Moq; - -namespace Prometheus.Client.MetricPusher.HostedService.Tests -{ - public class MetricPusherServiceTests - { - [Fact] - public async Task WithGivenInterval_PushMetricPeriodically() - { - var metricPusherMock = new Moq.Mock(); - var metricPusherService = new MetricPusherService(metricPusherMock.Object, TimeSpan.FromSeconds(1)); - var canellationToken = It.IsAny(); - - await metricPusherService.StartAsync(canellationToken); - await Task.Delay(TimeSpan.FromSeconds(1)); - await metricPusherService.StopAsync(canellationToken); - - metricPusherMock.Verify(o => o.PushAsync(), Moq.Times.AtLeast(2)); - } - } -} diff --git a/src/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj b/src/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj deleted file mode 100644 index 0efe4ae..0000000 --- a/src/Prometheus.Client.MetricPusher.HostedService.Tests/Prometheus.Client.MetricPusher.HostedService.Tests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - net6.0 - enable - enable - - false - true - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/src/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs b/src/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs deleted file mode 100644 index 99c4e93..0000000 --- a/src/Prometheus.Client.MetricPusher.HostedService.Tests/ServiceCollecttionExtensionsTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace Prometheus.Client.MetricPusher.HostedService.Tests -{ - public class ServiceCollecttionExtensionsTests - { - [Fact] - public void AddMetricPusherService_WithNullMetricPusher_ThrowsArgumentNullException() - { - IServiceCollection servicesCollection = Moq.Mock.Of(); - - Action act = () => ServiceCollectionExtensions.AddMetricPusherService(servicesCollection, null, TimeSpan.FromSeconds(1)); - - act.Should().Throw(); - } - - [Fact] - public void AddMetricPusherService_WithZeroTimeInterval_ThrowsArgumentOutOfRangeException() - { - IServiceCollection servicesCollection = Moq.Mock.Of(); - IMetricPusher metricPusher = Moq.Mock.Of(); - - Action act = () => ServiceCollectionExtensions.AddMetricPusherService(servicesCollection, metricPusher, TimeSpan.Zero); - - act.Should().Throw(); - } - - [Fact] - public void AddMetricPusherService_WithValidParameterValues_AddsMetricPusherServiceInServiceCollection() - { - IServiceCollection servicesCollection = new ServiceCollection(); - IMetricPusher metricPusher = Moq.Mock.Of(); - - ServiceCollectionExtensions.AddMetricPusherService(servicesCollection, metricPusher, TimeSpan.FromSeconds(1)); - var provider = servicesCollection.BuildServiceProvider(); - var service = provider.GetRequiredService(); - - service.Should().BeOfType(); - } - } -}