示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }