Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

30 rader
963 B

  1. using Microsoft.AspNetCore.Connections;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using MQTTnet.AspNetCore.Tests.Mockups;
  4. using MQTTnet.Exceptions;
  5. using MQTTnet.Serializer;
  6. using System;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. namespace MQTTnet.AspNetCore.Tests
  10. {
  11. [TestClass]
  12. public class MqttConnectionContextTest
  13. {
  14. [TestMethod]
  15. public async Task TestReceivePacketAsyncThrowsWhenReaderCompleted()
  16. {
  17. var serializer = new MqttPacketSerializer {};
  18. var pipe = new DuplexPipeMockup();
  19. var connection = new DefaultConnectionContext();
  20. connection.Transport = pipe;
  21. var ctx = new MqttConnectionContext(serializer, connection);
  22. pipe.Receive.Writer.Complete();
  23. await Assert.ThrowsExceptionAsync<MqttCommunicationException>(() => ctx.ReceivePacketAsync(TimeSpan.FromSeconds(1), CancellationToken.None));
  24. }
  25. }
  26. }