示例#1
0
        internal void GivenMessage_WhichIsInvalidForThisPort_RespondsWithMessageRejected()
        {
            // Arrange
            var server = new MessageServerFacade(
                this.container,
                this.messagingAdapter,
                this.compressor,
                EncryptionSettings.None(),
                this.testRequestAddress,
                this.testResponseAddress);

            server.Start().Wait();

            var dealer = new TestDealer(
                this.container,
                this.headerSerializer,
                this.requestSerializer,
                this.responseSerializer,
                this.compressor,
                EncryptionSettings.None(),
                this.testRequestAddress,
                this.testResponseAddress);

            dealer.Start().Wait();

            // Act
            dealer.SendRaw(
                Encoding.UTF8.GetBytes("WOW"),
                BitConverter.GetBytes(3),
                Encoding.UTF8.GetBytes("Payload"));

            var response = dealer.Receive();

            // Assert
            Assert.Equal(typeof(MessageRejected), response.Type);
            Assert.Equal(1, server.ReceivedCount);
            Assert.Equal(1, server.SentCount);

            // Tear Down
            dealer.Stop().Wait();
            server.Stop().Wait();
            dealer.Dispose();
            server.Dispose();
        }
示例#2
0
        internal void GivenMessage_WhichHasIncorrectFrameCount_RespondsWithMessageRejected()
        {
            // Arrange
            var server = new MessageServerFacade(
                this.container,
                this.messagingAdapter,
                this.compressor,
                EncryptionSettings.None(),
                this.testRequestAddress,
                this.testResponseAddress);

            server.Start().Wait();

            var dealer = new TestDealer(
                this.container,
                this.headerSerializer,
                this.requestSerializer,
                this.responseSerializer,
                this.compressor,
                EncryptionSettings.None(),
                this.testRequestAddress,
                this.testResponseAddress);

            dealer.Start().Wait();

            // Act
            dealer.SendRaw(new byte[] { });
            var response = dealer.Receive();

            // Assert
            Assert.Equal(typeof(MessageRejected), response.Type);
            Assert.Equal(1, server.ReceivedCount);
            Assert.Equal(1, server.SentCount);

            // Tear Down
            dealer.Stop().Wait();
            server.Stop().Wait();
            dealer.Dispose();
            server.Dispose();
        }