diff --git a/src/AleRoe.HomematicIPApi.Tests/AleRoe.HomematicIpApi.Tests.csproj b/src/AleRoe.HomematicIPApi.Tests/AleRoe.HomematicIpApi.Tests.csproj
index 5468ba3..577d7c4 100644
--- a/src/AleRoe.HomematicIPApi.Tests/AleRoe.HomematicIpApi.Tests.csproj
+++ b/src/AleRoe.HomematicIPApi.Tests/AleRoe.HomematicIpApi.Tests.csproj
@@ -17,7 +17,7 @@
-
+
@@ -25,7 +25,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/src/AleRoe.HomematicIPApi.Tests/HomematicClientCtorTests.cs b/src/AleRoe.HomematicIPApi.Tests/HomematicClientCtorTests.cs
index 1ecc5fa..d1f3612 100644
--- a/src/AleRoe.HomematicIPApi.Tests/HomematicClientCtorTests.cs
+++ b/src/AleRoe.HomematicIPApi.Tests/HomematicClientCtorTests.cs
@@ -1,4 +1,5 @@
-using NUnit.Framework;
+using Microsoft.Extensions.Logging.Abstractions;
+using NUnit.Framework;
using System;
using System.Net.Http;
using System.Threading;
@@ -45,36 +46,30 @@ public async Task CtorWithHttpClientTest()
}
[Test()]
- public async Task DisposeTest()
+ public async Task CtorWithLoggerTest()
{
- var config = new HomematicIpConfiguration() { AccessPointId = AccessPoint, AuthToken = AuthToken };
- var client = new HomematicIpClient(config);
- await client.InitializeAsync(CancellationToken.None);
- var events = client.PushEventReceived.Subscribe(msg => { });
- Assert.DoesNotThrow(client.Dispose);
- await Task.CompletedTask;
- }
-
- [Test()]
- public async Task DisposeWithoutInitializeTest()
- {
- var config = new HomematicIpConfiguration() {AccessPointId = AccessPoint, AuthToken = AuthToken };
- var client = new HomematicIpClient(config);
- Assert.DoesNotThrow(client.Dispose);
+ Assert.DoesNotThrow(() =>
+ {
+ using var loggerFactory = new NullLoggerFactory();
+ var config = new HomematicIpConfiguration() { AccessPointId = AccessPoint, AuthToken = AuthToken };
+ using var client = new HomematicIpClient(config, loggerFactory);
+ Assert.AreSame(loggerFactory, client.loggerFactory);
+ });
await Task.CompletedTask;
}
[Test()]
- public async Task DisposeWithCustomHttpClientTest()
+ public async Task CtorWithHttpClientAndLoggerTest()
{
- var config = new HomematicIpConfiguration() {AccessPointId = AccessPoint, AuthToken = AuthToken };
- using var httpClient = new HttpClient();
- var client = new HomematicIpClient(config, httpClient);
- await client.InitializeAsync(CancellationToken.None);
- var events = client.PushEventReceived.Subscribe(msg => { });
-
- Assert.DoesNotThrow(client.Dispose);
- Assert.IsNotNull(client.httpClient);
+ Assert.DoesNotThrow(() =>
+ {
+ using var loggerFactory = new NullLoggerFactory();
+ using var httpClient = new HttpClient();
+ var config = new HomematicIpConfiguration() { AccessPointId = AccessPoint, AuthToken = AuthToken };
+ using var client = new HomematicIpClient(config, httpClient, loggerFactory);
+ Assert.AreSame(loggerFactory, client.loggerFactory);
+ Assert.AreSame(httpClient, client.httpClient);
+ });
await Task.CompletedTask;
}
}
diff --git a/src/AleRoe.HomematicIPApi.Tests/HomematicClientDisposeTests.cs b/src/AleRoe.HomematicIPApi.Tests/HomematicClientDisposeTests.cs
new file mode 100644
index 0000000..c0f4bd0
--- /dev/null
+++ b/src/AleRoe.HomematicIPApi.Tests/HomematicClientDisposeTests.cs
@@ -0,0 +1,62 @@
+using Microsoft.Extensions.Logging.Abstractions;
+using NUnit.Framework;
+using System;
+using System.Net.Http;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace AleRoe.HomematicIpApi.Tests
+{
+ [TestFixture()]
+ public class HomematicClientDisposeTests : HomematicClientTestsBase
+ {
+ [Test()]
+ public async Task DisposeTest()
+ {
+ var config = new HomematicIpConfiguration() { AccessPointId = AccessPoint, AuthToken = AuthToken };
+ var client = new HomematicIpClient(config);
+ await client.InitializeAsync(CancellationToken.None);
+ var events = client.PushEventReceived.Subscribe(msg => { });
+ Assert.DoesNotThrow(client.Dispose);
+ await Task.CompletedTask;
+ }
+
+ [Test()]
+ public async Task DisposeWithoutInitializeTest()
+ {
+ var config = new HomematicIpConfiguration() { AccessPointId = AccessPoint, AuthToken = AuthToken };
+ var client = new HomematicIpClient(config);
+ Assert.DoesNotThrow(client.Dispose);
+ await Task.CompletedTask;
+ }
+
+ [Test()]
+ public async Task DisposeWithCustomHttpClientTest()
+ {
+ var config = new HomematicIpConfiguration() { AccessPointId = AccessPoint, AuthToken = AuthToken };
+ using var httpClient = new HttpClient();
+ var client = new HomematicIpClient(config, httpClient);
+ await client.InitializeAsync(CancellationToken.None);
+ var events = client.PushEventReceived.Subscribe(msg => { });
+
+ Assert.DoesNotThrow(client.Dispose);
+ Assert.IsNotNull(client.httpClient);
+ await Task.CompletedTask;
+ }
+
+
+ [Test()]
+ public async Task DisposeWithCustomLoggerFactoryTest()
+ {
+ var config = new HomematicIpConfiguration() { AccessPointId = AccessPoint, AuthToken = AuthToken };
+ using var loggerFactory = new NullLoggerFactory();
+ var client = new HomematicIpClient(config, loggerFactory);
+ await client.InitializeAsync(CancellationToken.None);
+ var events = client.PushEventReceived.Subscribe(msg => { });
+
+ Assert.DoesNotThrow(client.Dispose);
+ Assert.IsNotNull(client.loggerFactory);
+ await Task.CompletedTask;
+ }
+ }
+}