예제 #1
0
        public void ProcessRequestsShouldProcessBeforeTestCaseStartEvent()
        {
            var message = new Message();

            message.MessageType = MessageType.DataCollectionTestStart;
            message.Payload     = JToken.FromObject(new TestCaseEndEventArgs());

            this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(new Message()
            {
                MessageType = MessageType.SessionEnd, Payload = "false"
            });

            var requestHandler = new DataCollectionTestCaseEventHandler(this.mockCommunicationManager.Object, this.mockDataCollectionManager.Object, this.dataSerializer.Object);

            requestHandler.ProcessRequests();

            this.mockDataCollectionManager.Verify(x => x.TestCaseStarted(It.IsAny <TestCaseStartEventArgs>()), Times.Once);
        }
        public void ProcessRequestsShouldProcessAfterTestCaseCompleteEvent()
        {
            var message = new Message();

            message.MessageType = MessageType.DataCollectionTestEnd;
            message.Payload     = JToken.FromObject(new TestResultEventArgs(new VisualStudio.TestPlatform.ObjectModel.TestResult(new TestCase())));

            this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(new Message()
            {
                MessageType = MessageType.SessionEnd, Payload = "false"
            });

            var requestHandler = new DataCollectionTestCaseEventHandler(this.mockCommunicationManager.Object, this.mockDataCollectionManager.Object);

            requestHandler.ProcessRequests();

            this.mockDataCollectionManager.Verify(x => x.TestCaseEnded(It.IsAny <TestCaseEndEventArgs>()), Times.Once);
            this.mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionTestEndResult, It.IsAny <Collection <AttachmentSet> >()));
        }
        public void ProcessRequestsShouldThrowExceptionIfThrownByCommunicationManager()
        {
            this.mockCommunicationManager.Setup(x => x.ReceiveMessage()).Throws <Exception>();

            Assert.ThrowsException <Exception>(() => { requestHandler.ProcessRequests(); });
        }