Refactor Tests structure; Move HttpClient to it's own folder

This commit is contained in:
Denis-Cosmin Nutiu 2020-08-01 17:55:24 +03:00
parent dcd51ecd3d
commit 350fc6bc77
6 changed files with 12 additions and 7 deletions

View file

@ -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;

View file

@ -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
{
/// <summary>
/// A simple HttpClient wrapper designed to make it easier to work with web requests with media type application/json.

View file

@ -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<HttpRequestMessage> SendAsyncArgCalls;
public List<HttpResponseMessage> SendAsyncResponses;

View file

@ -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]

View file

@ -3,6 +3,11 @@
&lt;Assembly Path="/home/denis/.nuget/packages/iot.device.bindings/1.0.0/lib/netcoreapp2.1/Iot.Device.Bindings.dll" /&gt;
&lt;Assembly Path="/home/denis/.nuget/packages/firebaseresttranslator/0.1.1/lib/netcoreapp3.0/FirebaseRestTranslator.dll" /&gt;
&lt;/AssemblyExplorer&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=271bcc38_002D67df_002D4a50_002D94ca_002D524c78a6d97e/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="Test_PublishAsync_Cancel" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;TestAncestor&gt;&#xD;
&lt;TestId&gt;xUnit::C6F07921-1052-4945-911E-F328A622F229::.NETCoreApp,Version=v3.1::NucuCar.UnitTests.NucuCar.Telemetry.Tests.TelemetryPublisherFirestoreTest.Test_PublishAsync_Cancel&lt;/TestId&gt;&#xD;
&lt;/TestAncestor&gt;&#xD;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=59acec6f_002Dda48_002D4e34_002Dbf2a_002D5b52d718278a/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="Test_PublishAsync_Authorization_OK" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;TestAncestor&gt;&#xD;
&lt;TestId&gt;xUnit::C6F07921-1052-4945-911E-F328A622F229::.NETCoreApp,Version=v3.1::NucuCar.UnitTests.NucuCar.Telemetry.Tests.TelemetryPublisherFirestoreTest.Test_PublishAsync_Authorization_OK&lt;/TestId&gt;&#xD;