public void VersionCheckWithTestHostShouldCheckVersionIfVersionCheckPassesReturnTrue() { var mockCommunicationManager = new Mock <ICommunicationManager>(); var message = new Message() { MessageType = MessageType.VersionCheck, Payload = this.protocolConfig.Version }; mockCommunicationManager.Setup(mc => mc.ReceiveMessage()).Returns(message); var testRequestSender = new TestRequestSender(mockCommunicationManager.Object, this.mockDataSerializer.Object, this.protocolConfig); testRequestSender.CheckVersionWithTestHost(); mockCommunicationManager.Verify(mc => mc.SendMessage(MessageType.VersionCheck, this.protocolConfig.Version), Times.Once); }
public void VersionCheckWithTestHostShouldBeAbleToReceiveProtocolErrorAndThrowException() { var mockCommunicationManager = new Mock <ICommunicationManager>(); var message = new Message() { MessageType = MessageType.ProtocolError, Payload = null }; mockCommunicationManager.Setup(mc => mc.ReceiveMessage()).Returns(message); var testRequestSender = new TestRequestSender(mockCommunicationManager.Object, this.mockDataSerializer.Object, this.protocolConfig); var ex = Assert.ThrowsException <TestPlatformException>(() => testRequestSender.CheckVersionWithTestHost()); Assert.AreEqual("Protocol version check failed. Make sure test runner and host are compatible.", ex.Message); }
public void VersionCheckWithTestHostForInvalidMessageShouldThrowException() { var mockCommunicationManager = new Mock <ICommunicationManager>(); var message = new Message() { MessageType = MessageType.TestCasesFound, Payload = null }; mockCommunicationManager.Setup(mc => mc.ReceiveMessage()).Returns(message); var testRequestSender = new TestRequestSender(mockCommunicationManager.Object, this.mockDataSerializer.Object, this.protocolConfig); var ex = Assert.ThrowsException <TestPlatformException>(() => testRequestSender.CheckVersionWithTestHost()); Assert.AreEqual("Unexpected message received. Expected MessageType : ProtocolVersion Actual MessageType: TestDiscovery.TestFound", ex.Message); }