예제 #1
0
        public void CreateRequestMessage_WithRequest_ForthFrameIsSerializedData()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);

            // Act
            var message = messageFactory.CreateRequestMessage(obj, requestId);

            // Assert
            Assert.That(message[3].ToByteArray(), Is.EqualTo(data));
        }
예제 #2
0
        public void CreateRequestMessage_WithRequest_ThirdFrameEmpty()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);

            // Act
            var message = messageFactory.CreateRequestMessage(obj, requestId);

            // Assert
            Assert.That(message[2], Is.EqualTo(NetMQFrame.Empty));
        }
예제 #3
0
        public void CreateRequestMessage_WithRequest_SecondFrameIsRequestId()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);

            // Act
            var message = messageFactory.CreateRequestMessage(obj, requestId);

            // Assert
            Assert.That(message[1].ConvertToInt32(), Is.EqualTo(requestId));
        }
예제 #4
0
        public void CreateRequestMessage_WithRequest_MessageHasFourFrames()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);

            // Act
            var message = messageFactory.CreateRequestMessage(obj, requestId);

            // Assert
            Assert.That(message.FrameCount, Is.EqualTo(4));
        }
예제 #5
0
        public void CreateRequestMessage_WithRequest_SerializesPackage()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);

            // Act
            var message = messageFactory.CreateRequestMessage(obj, requestId);

            // Assert
            mockSerializer.Verify(m => m.Serialize(It.IsIn <Package>(package)), Times.Once);
        }
예제 #6
0
        public void CreateRequestMessage_WithRequest_PacksRequest()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);

            // Act
            var message = messageFactory.CreateRequestMessage(obj, requestId);

            // Assert
            mockPackageFactory.Verify(m => m.Pack(It.IsIn <object>(obj)), Times.Once);
        }
예제 #7
0
        public void IsValidRequestMessage_WithEmptyAddress_IsFalse()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);
            var message        = messageFactory.CreateRequestMessage(obj, requestId);

            message.PushEmptyFrame();

            // Act
            var isValid = messageFactory.IsValidRequestMessage(message);

            // Assert
            Assert.That(isValid, Is.False);
        }
예제 #8
0
        public void IsValidRequestMessage_WithFiveFrameMessage_IsTrue()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);
            var message        = messageFactory.CreateRequestMessage(obj, 1);

            message.Push(address);

            // Act
            var isValid = messageFactory.IsValidRequestMessage(message);

            // Assert
            Assert.That(isValid, Is.True);
        }
예제 #9
0
        public void ExtractRequest_WithMessage_UnpacksRequestObject()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);
            var message        = messageFactory.CreateRequestMessage(obj, requestId);

            message.Push(address); // NetMQ prepends an address frame

            // Act
            var(request, retAddress, retRequestId, name) = messageFactory.ExtractRequest(message);

            // Assert
            mockPackageFactory.Verify(m => m.Unpack(It.IsIn <Package>(package)), Times.Once);
        }
예제 #10
0
        public void ExtractRequest_WithMessage_DeserializesPackage()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);
            var message        = messageFactory.CreateRequestMessage(obj, requestId);

            message.Push(address); // NetMQ prepends an address frame

            // Act
            var(request, retAddress, retRequestId, name) = messageFactory.ExtractRequest(message);

            // Assert
            mockSerializer.Verify(m => m.Deserialize <Package>(It.IsIn <byte[]>(data)), Times.Once);
        }
예제 #11
0
        public void ExtractRequest_WithMessage_ReturnsSameAddress()
        {
            // Arrange
            var messageFactory = new NetMQMessageFactory(serializerCache, packageFactory);
            var message        = messageFactory.CreateRequestMessage(obj, requestId);

            message.Push(address); // NetMQ prepends an address frame

            // Act
            var(request, retAddress, retRequestId, name) = messageFactory.ExtractRequest(message);

            // Assert
            Assert.That(retAddress, Is.EqualTo(address));
        }