-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated dependencies
- Loading branch information
Showing
3 changed files
with
84 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/AleRoe.HomematicIPApi.Tests/HomematicClientDisposeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |