Пример #1
0
        public void ExtractResponse_WithMessage_DeserializesPackage()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);
            var message        = new NetMQMessage(4);

            message.AppendEmptyFrame();
            message.Append(requestId);
            message.AppendEmptyFrame();
            message.Append(data);

            // Act
            var(retRequestId, response) = messageFactory.ExtractResponse(message);

            // Assert
            mockSerializer.Verify(m => m.Deserialize <Package>(It.IsIn <byte[]>(data)), Times.Once);
        }
Пример #2
0
        public void ExtractResponse_WithMessage_UnpacksResponseObject()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);
            var message        = new NetMQMessage(4);

            message.AppendEmptyFrame();
            message.Append(requestId);
            message.AppendEmptyFrame();
            message.Append(data);

            // Act
            var(retRequestId, response) = messageFactory.ExtractResponse(message);

            // Assert
            mockPackageFactory.Verify(m => m.Unpack(It.IsIn(package)), Times.Once);
        }
Пример #3
0
        public void ExtractResponse_WithMessage_ReturnsRequestId()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);
            var message        = new NetMQMessage(4);

            message.AppendEmptyFrame();
            message.Append(requestId);
            message.AppendEmptyFrame();
            message.Append(data);

            // Act
            var(retRequestId, response) = messageFactory.ExtractResponse(message);

            // Assert
            Assert.That(retRequestId, Is.EqualTo(requestId));
        }