From 350fc6bc7758feb379f1f84bf583b40856229f7b Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Sat, 1 Aug 2020 17:55:24 +0300 Subject: [PATCH] Refactor Tests structure; Move HttpClient to it's own folder --- NucuCar.Domain.Telemetry/TelemetryPublisherFirestore.cs | 1 + NucuCar.Domain/{ => Http}/HttpClient.cs | 2 +- .../Http}/MockHttpClient.cs | 5 ++--- .../ConnectionStringParserTest.cs | 0 .../TelemetryPublisherFirestoreTest.cs | 6 +++--- NucuCar.sln.DotSettings.user | 5 +++++ 6 files changed, 12 insertions(+), 7 deletions(-) rename NucuCar.Domain/{ => Http}/HttpClient.cs (99%) rename {NucuCar.UnitTests/NucuCar.Common.Tests => NucuCar.Domain/Http}/MockHttpClient.cs (85%) rename NucuCar.UnitTests/{NucuCar.Common.Tests => NucuCar.Domain.Tests}/ConnectionStringParserTest.cs (100%) diff --git a/NucuCar.Domain.Telemetry/TelemetryPublisherFirestore.cs b/NucuCar.Domain.Telemetry/TelemetryPublisherFirestore.cs index 25ebc00..f76ed12 100644 --- a/NucuCar.Domain.Telemetry/TelemetryPublisherFirestore.cs +++ b/NucuCar.Domain.Telemetry/TelemetryPublisherFirestore.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using NucuCar.Domain; +using NucuCar.Domain.Http; using NucuCar.Domain.Telemetry; using NucuCar.Domain.Utilities; diff --git a/NucuCar.Domain/HttpClient.cs b/NucuCar.Domain/Http/HttpClient.cs similarity index 99% rename from NucuCar.Domain/HttpClient.cs rename to NucuCar.Domain/Http/HttpClient.cs index 94797d4..7e9541e 100644 --- a/NucuCar.Domain/HttpClient.cs +++ b/NucuCar.Domain/Http/HttpClient.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.Logging; using sNetHttp = System.Net.Http; using sNetHttpHeaders = System.Net.Http.Headers; -namespace NucuCar.Domain +namespace NucuCar.Domain.Http { /// /// A simple HttpClient wrapper designed to make it easier to work with web requests with media type application/json. diff --git a/NucuCar.UnitTests/NucuCar.Common.Tests/MockHttpClient.cs b/NucuCar.Domain/Http/MockHttpClient.cs similarity index 85% rename from NucuCar.UnitTests/NucuCar.Common.Tests/MockHttpClient.cs rename to NucuCar.Domain/Http/MockHttpClient.cs index 131a193..e0fe7a5 100644 --- a/NucuCar.UnitTests/NucuCar.Common.Tests/MockHttpClient.cs +++ b/NucuCar.Domain/Http/MockHttpClient.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; -using HttpClient = NucuCar.Domain.HttpClient; -namespace NucuCar.UnitTests.NucuCar.Common.Tests +namespace NucuCar.Domain.Http { - public class MockHttpClient : Domain.HttpClient + public class MockHttpClient : Domain.Http.HttpClient { public List SendAsyncArgCalls; public List SendAsyncResponses; diff --git a/NucuCar.UnitTests/NucuCar.Common.Tests/ConnectionStringParserTest.cs b/NucuCar.UnitTests/NucuCar.Domain.Tests/ConnectionStringParserTest.cs similarity index 100% rename from NucuCar.UnitTests/NucuCar.Common.Tests/ConnectionStringParserTest.cs rename to NucuCar.UnitTests/NucuCar.Domain.Tests/ConnectionStringParserTest.cs diff --git a/NucuCar.UnitTests/NucuCar.Telemetry.Tests/TelemetryPublisherFirestoreTest.cs b/NucuCar.UnitTests/NucuCar.Telemetry.Tests/TelemetryPublisherFirestoreTest.cs index 0dce70c..bbc95de 100644 --- a/NucuCar.UnitTests/NucuCar.Telemetry.Tests/TelemetryPublisherFirestoreTest.cs +++ b/NucuCar.UnitTests/NucuCar.Telemetry.Tests/TelemetryPublisherFirestoreTest.cs @@ -5,11 +5,11 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; +using NucuCar.Domain.Http; using NucuCar.Domain.Telemetry; using NucuCar.Telemetry; -using NucuCar.UnitTests.NucuCar.Common.Tests; using Xunit; -using HttpClient = NucuCar.Domain.HttpClient; +using HttpClient = NucuCar.Domain.Http.HttpClient; namespace NucuCar.UnitTests.NucuCar.Telemetry.Tests { @@ -115,7 +115,7 @@ namespace NucuCar.UnitTests.NucuCar.Telemetry.Tests await publisher.PublishAsync(cts.Token); // Assert - Assert.Equal(mockHttpClient.SendAsyncArgCalls.Count, 0); + Assert.Empty(mockHttpClient.SendAsyncArgCalls); } [Fact] diff --git a/NucuCar.sln.DotSettings.user b/NucuCar.sln.DotSettings.user index 215653b..be70b0e 100644 --- a/NucuCar.sln.DotSettings.user +++ b/NucuCar.sln.DotSettings.user @@ -3,6 +3,11 @@ <Assembly Path="/home/denis/.nuget/packages/iot.device.bindings/1.0.0/lib/netcoreapp2.1/Iot.Device.Bindings.dll" /> <Assembly Path="/home/denis/.nuget/packages/firebaseresttranslator/0.1.1/lib/netcoreapp3.0/FirebaseRestTranslator.dll" /> </AssemblyExplorer> + <SessionState ContinuousTestingMode="0" Name="Test_PublishAsync_Cancel" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <TestAncestor> + <TestId>xUnit::C6F07921-1052-4945-911E-F328A622F229::.NETCoreApp,Version=v3.1::NucuCar.UnitTests.NucuCar.Telemetry.Tests.TelemetryPublisherFirestoreTest.Test_PublishAsync_Cancel</TestId> + </TestAncestor> +</SessionState> <SessionState ContinuousTestingMode="0" Name="Test_PublishAsync_Authorization_OK" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <TestAncestor> <TestId>xUnit::C6F07921-1052-4945-911E-F328A622F229::.NETCoreApp,Version=v3.1::NucuCar.UnitTests.NucuCar.Telemetry.Tests.TelemetryPublisherFirestoreTest.Test_PublishAsync_Authorization_OK</TestId>