public void InitializeTests() { this.baseTestRunEventsHandler = new Mock <ITestRunEventsHandler>(); this.proxyDataCollectionManager = new Mock <IProxyDataCollectionManager>(); this.mockDataSerializer = new Mock <IDataSerializer>(); this.testRunEventHandler = new DataCollectionTestRunEventsHandler(this.baseTestRunEventsHandler.Object, this.proxyDataCollectionManager.Object, CancellationToken.None, this.mockDataSerializer.Object); }
public void HandleRawMessageShouldInvokeAfterTestRunEndPassingTrueIfRequestCancelled() { var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection <AttachmentSet>(), new TimeSpan()); this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny <string>())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); this.mockDataSerializer.Setup(x => x.DeserializePayload <TestRunCompletePayload>(It.IsAny <Message>())) .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); var cancellationTokenSource = new CancellationTokenSource(); testRunEventHandler = new DataCollectionTestRunEventsHandler(this.baseTestRunEventsHandler.Object, this.proxyDataCollectionManager.Object, cancellationTokenSource.Token, this.mockDataSerializer.Object); cancellationTokenSource.Cancel(); testRunEventHandler.HandleRawMessage(string.Empty); this.proxyDataCollectionManager.Verify( dcm => dcm.AfterTestRunEnd(true, It.IsAny <ITestRunEventsHandler>()), Times.Once); }
public void GetCombinedAttachmentSetsShouldReturnFirstArgumentIfSecondArgumentIsNull() { Collection <AttachmentSet> Attachments1 = new Collection <AttachmentSet>(); AttachmentSet attachmentset1 = new AttachmentSet(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); attachmentset1.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v11"), "AttachmentV1-Attachment1")); Attachments1.Add(attachmentset1); var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(Attachments1, null); Assert.AreEqual(1, result.Count); Assert.AreEqual(1, result.First().Attachments.Count); }
public void GetCombinedAttachmentSetsShouldReturnCombinedAttachments() { Collection <AttachmentSet> Attachments1 = new Collection <AttachmentSet>(); AttachmentSet attachmentset1 = new AttachmentSet(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); attachmentset1.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v11"), "AttachmentV1-Attachment1")); Attachments1.Add(attachmentset1); Collection <AttachmentSet> Attachments2 = new Collection <AttachmentSet>(); AttachmentSet attachmentset2 = new AttachmentSet(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); attachmentset2.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v12"), "AttachmentV1-Attachment2")); Attachments2.Add(attachmentset2); var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(Attachments1, Attachments2); Assert.AreEqual(1, result.Count); Assert.AreEqual(2, result.First().Attachments.Count); }
/// <summary> /// Starts the test run /// </summary> /// <param name="testRunCriteria"> The settings/options for the test run. </param> /// <param name="eventHandler"> EventHandler for handling execution events from Engine. </param> /// <returns> The process id of the runner executing tests. </returns> public override int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) { var currentEventHandler = eventHandler; if (this.ProxyDataCollectionManager != null) { currentEventHandler = new DataCollectionTestRunEventsHandler(eventHandler, this.ProxyDataCollectionManager); } // Log all the exceptions that has occured while initializing DataCollectionClient if (this.DataCollectionRunEventsHandler?.ExceptionMessages?.Count > 0) { foreach (var message in this.DataCollectionRunEventsHandler.ExceptionMessages) { currentEventHandler.HandleLogMessage(TestMessageLevel.Error, message); } } return(base.StartTestRun(testRunCriteria, currentEventHandler)); }
/// <summary> /// Starts the test run /// </summary> /// <param name="testRunCriteria"> The settings/options for the test run. </param> /// <param name="eventHandler"> EventHandler for handling execution events from Engine. </param> /// <returns> The process id of the runner executing tests. </returns> public override int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) { var currentEventHandler = eventHandler; if (this.ProxyDataCollectionManager != null) { currentEventHandler = new DataCollectionTestRunEventsHandler(eventHandler, this.ProxyDataCollectionManager); } // Log all the messages that are reported while initializing DataCollectionClient if (this.DataCollectionRunEventsHandler.Messages.Count > 0) { foreach (var message in this.DataCollectionRunEventsHandler.Messages) { currentEventHandler.HandleLogMessage(message.Item1, message.Item2); } this.DataCollectionRunEventsHandler.Messages.Clear(); } return(base.StartTestRun(testRunCriteria, currentEventHandler)); }
public void GetCombinedAttachmentSetsShouldReturnNullIfFirstArgumentIsNull() { var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(null, null); Assert.IsNull(result); }
public void InitializeTests() { this.baseTestRunEventsHandler = new Mock <ITestRunEventsHandler>(); this.proxyDataCollectionManager = new Mock <IProxyDataCollectionManager>(); this.testRunEventHandler = new DataCollectionTestRunEventsHandler(this.baseTestRunEventsHandler.Object, this.proxyDataCollectionManager.Object); }