Ejemplo n.º 1
0
        public async Task ReadAsync_IsDisposed_Return()
        {
            // arrange
            ISession manager   = new Mock <ISession>().Object;
            string   id        = "123";
            var      operation = new SocketOperation(manager, id);
            await operation.DisposeAsync();

            List <OperationMessage> messages = new();

            // act
            await foreach (var elm in operation.ReadAsync(CancellationToken.None))
            {
                messages.Push(elm);
            }

            // assert
            Assert.Empty(messages);
        }
Ejemplo n.º 2
0
        public async Task ReadAsync_IsDisposedDuringReceiving_Return()
        {
            // arrange
            ISession manager   = new Mock <ISession>().Object;
            string   id        = "123";
            var      operation = new SocketOperation(manager, id);
            List <OperationMessage> messages = new();

            // act
            await operation.ReceiveMessageAsync(
                ErrorOperationMessage.ConnectionInitializationError,
                CancellationToken.None);

            await foreach (var elm in operation.ReadAsync(CancellationToken.None))
            {
                messages.Push(elm);
                await operation.DisposeAsync();
            }

            // assert
            Assert.Single(messages);
        }