Example #1
0
        public async void SendsAndReceivesNullSuccessfully(
            [ValueSource("OutsourcedWorkerConnections")] IWorkerConnection connection)
        {
            // Arrange
            var ct = new CancellationToken();

            TestStream.Position = 0; // To start from fresh

            // Act
            await connection.SendObjectAsync(null, ct).ConfigureAwait(false);

            TestStream.Position = 0; // To read what we just wrote
            var deserialized = await connection.ReceiveObjectAsync(ct).ConfigureAwait(false);

            // Assert
            Assert.That(deserialized, Is.EqualTo(null));
        }
Example #2
0
        public async void SendsAndReceivesObjectSuccessfully <T>(
            [ValueSource("OutsourcedWorkerConnections")] IWorkerConnection connection,
            [ValueSource("TestObjects")] T testValue)
        {
            // Arrange
            var ct = new CancellationToken();

            TestStream.Position = 0; // To start from fresh

            // Act
            await connection.SendObjectAsync(testValue, ct).ConfigureAwait(false);

            TestStream.Position = 0; // To read what we just wrote
            var deserialized = (T)await connection.ReceiveObjectAsync(ct).ConfigureAwait(false);

            // Assert
            deserialized.ShouldBeEquivalentTo(testValue);
        }