Ejemplo n.º 1
0
        public void DisposeCoapClient_With_NonDisposableEndpoint()
        {
            // Arrange
            var endpoint = new NonDisposableEndpoint();
            var client   = new CoapClient(endpoint);

            Task receiveTask;
            var  ct = new CancellationTokenSource(MaxTaskTimeout);

            // Ack
            receiveTask = client.ReceiveAsync(ct.Token);
            client.Dispose();

            // Assert
            Assert.ThrowsAsync <CoapEndpointException>(async() => await receiveTask, $"{nameof(CoapClient.ReceiveAsync)} did not throw an {nameof(CoapEndpointException)} when {nameof(CoapClient)} was disposed.");
            Assert.That(ct.IsCancellationRequested, Is.False, "The test's safety CancellationToken timed out");
        }