-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix high CPU load issues when closing the client.
- Loading branch information
Showing
13 changed files
with
145 additions
and
51 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
Binary file not shown.
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
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
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
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,66 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using CoAPnet.Client; | ||
using CoAPnet.Exceptions; | ||
using CoAPnet.Extensions.DTLS; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace CoAPnet.Tests | ||
{ | ||
[TestClass] | ||
public class CoapClient_Tests | ||
{ | ||
[TestMethod] | ||
[ExpectedException(typeof(CoapCommunicationException))] | ||
public async Task Connect_Invalid_Host() | ||
{ | ||
using (var coapClient = new CoapFactory().CreateClient()) | ||
{ | ||
await coapClient.ConnectAsync(new CoapClientConnectOptions() | ||
{ | ||
Host = "invalid_host" | ||
}, CancellationToken.None); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(CoapCommunicationException))] | ||
public async Task Connect_Valid_Host_With_Invalid_Port_Dtls() | ||
{ | ||
using (var coapClient = new CoapFactory().CreateClient()) | ||
{ | ||
var options = new CoapClientConnectOptionsBuilder() | ||
.WithHost("127.0.0.1") | ||
.WithPort(5555) | ||
.WithDtlsTransportLayer(o => | ||
{ | ||
o.WithPreSharedKey("a", "b"); | ||
}) | ||
.Build(); | ||
|
||
await coapClient.ConnectAsync(options, CancellationToken.None); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(CoapCommunicationTimedOutException))] | ||
public async Task Timeout_When_No_Response_Received() | ||
{ | ||
using (var coapClient = new CoapFactory().CreateClient()) | ||
{ | ||
var options = new CoapClientConnectOptionsBuilder() | ||
.WithHost("127.0.0.1") | ||
.WithPort(5555) | ||
.Build(); | ||
|
||
await coapClient.ConnectAsync(options, CancellationToken.None); | ||
|
||
var request = new CoapRequestBuilder() | ||
.WithMethod(CoapRequestMethod.Get) | ||
.Build(); | ||
|
||
await coapClient.RequestAsync(request, CancellationToken.None); | ||
} | ||
} | ||
} | ||
} |
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
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