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)); }
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)); }
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)); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }