$(ChutzpahAdapterVersion)
diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TestResults.html b/test/Microsoft.TestPlatform.AcceptanceTests/TestResults.html
new file mode 100644
index 0000000000..fe5d919771
--- /dev/null
+++ b/test/Microsoft.TestPlatform.AcceptanceTests/TestResults.html
@@ -0,0 +1,59 @@
+
+
+ TestResults
+
+
Summary
+ TotalTests:
+ 1
+ FailedTests:
+ 0
+ PassedTests:
+ 1
+ SkippedTests:
+ 0
+ Results
+
+
+ ✔
+ SampleUnitTestProject.UnitTest1.PassingTest7ms
+
+
+
\ No newline at end of file
diff --git a/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/HtmlLoggerTests.cs b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/HtmlLoggerTests.cs
new file mode 100644
index 0000000000..fe53dc7adc
--- /dev/null
+++ b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/HtmlLoggerTests.cs
@@ -0,0 +1,496 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using VisualStudio.TestTools.UnitTesting;
+ using Moq;
+ using ObjectModel = VisualStudio.TestPlatform.ObjectModel;
+ using VisualStudio.TestPlatform.ObjectModel.Client;
+ using Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger;
+ using HtmlLoggerConstants = VisualStudio.TestPlatform.Extensions.HtmlLogger.Constants;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
+ using HtmlLogger = VisualStudio.TestPlatform.Extensions.HtmlLogger;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+ using System.Linq;
+ using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
+ using System.Runtime.Serialization;
+ using Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel;
+
+ [TestClass]
+ public class HtmlLoggerTests
+ {
+ private Mock events;
+ private HtmlLogger.HtmlLogger htmlLogger;
+ private Dictionary parameters;
+ private static readonly string DefaultTestRunDirectory = Path.GetTempPath();
+ private static readonly string DefaultLogFileNameParameterValue = "logfilevalue.html";
+ private Mock mockFileHelper;
+ private Mock mockXmlSerializer;
+ private Mock mockHtmlTransformer;
+
+ [TestInitialize]
+ public void TestInitialize()
+ {
+ this.events = new Mock();
+ this.mockFileHelper = new Mock();
+ this.mockHtmlTransformer = new Mock();
+ this.mockXmlSerializer = new Mock();
+ this.htmlLogger = new HtmlLogger.HtmlLogger(this.mockFileHelper.Object, this.mockHtmlTransformer.Object, this.mockXmlSerializer.Object);
+ this.parameters = new Dictionary(2)
+ {
+ [DefaultLoggerParameterNames.TestRunDirectory] = HtmlLoggerTests.DefaultTestRunDirectory,
+ [HtmlLoggerConstants.LogFileNameKey] = HtmlLoggerTests.DefaultLogFileNameParameterValue
+ };
+ this.htmlLogger.Initialize(this.events.Object, this.parameters);
+ }
+
+ #region Initialize Method
+
+ [TestMethod]
+ public void InitializeShouldThrowExceptionIfEventsIsNull()
+ {
+ Assert.ThrowsException(
+ () =>
+ {
+ this.htmlLogger.Initialize(null, this.parameters);
+ });
+ }
+
+ [TestMethod]
+ public void InitializeShouldInitializeAllProperties()
+ {
+ const string testResultDir = @"C:\Code\abc";
+ var events = new Mock();
+
+ this.htmlLogger.Initialize(events.Object, testResultDir);
+
+ Assert.AreEqual(this.htmlLogger.TestResultsDirPath, testResultDir);
+ Assert.IsNotNull(this.htmlLogger.TestRunDetails);
+ Assert.IsNotNull(this.htmlLogger.Results);
+ }
+
+ [TestMethod]
+ public void InitializeShouldThrowExceptionIfTestRunDirectoryIsEmptyOrNull()
+ {
+ Assert.ThrowsException(
+ () =>
+ {
+ this.events = new Mock();
+ this.parameters[DefaultLoggerParameterNames.TestRunDirectory] = null;
+ this.htmlLogger.Initialize(events.Object, parameters);
+ });
+ }
+
+ [TestMethod]
+ public void InitializeShouldThrowExceptionIfParametersAreEmpty()
+ {
+ var events = new Mock();
+ Assert.ThrowsException(() => this.htmlLogger.Initialize(events.Object, new Dictionary()));
+ }
+
+ [TestMethod]
+ public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull()
+ {
+ Assert.ThrowsException(() =>
+ {
+ this.htmlLogger.TestMessageHandler(new object(), default(TestRunMessageEventArgs));
+ });
+ }
+
+ #endregion
+
+ [TestMethod]
+ public void TestMessageHandlerShouldAddMessageWhenItIsInformation()
+ {
+ const string message = "First message";
+ var testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Informational, message);
+
+ this.htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs);
+
+ var actualMessage = this.htmlLogger.TestRunDetails.RunLevelMessageInformational.First();
+ Assert.AreEqual(message, actualMessage);
+ }
+
+
+ [TestMethod]
+ public void TestCompleteHandlerShouldThrowExceptionIfParametersAreNull()
+ {
+ Dictionary parameters = null;
+ var events = new Mock();
+ Assert.ThrowsException(() => this.htmlLogger.Initialize(events.Object, parameters));
+ }
+
+ [TestMethod]
+ public void TestMessageHandlerShouldAddMessageInListIfItIsWarningAndError()
+ {
+ const string message = "error message";
+ const string message2 = "warning message";
+
+ var testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Error, message);
+ this.htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs);
+ var testRunMessageEventArgs2 = new TestRunMessageEventArgs(TestMessageLevel.Warning, message2);
+ this.htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs2);
+
+ Assert.AreEqual(message, this.htmlLogger.TestRunDetails.RunLevelMessageErrorAndWarning.First());
+ Assert.AreEqual(2, this.htmlLogger.TestRunDetails.RunLevelMessageErrorAndWarning.Count);
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldKeepTrackOfFailedResult()
+ {
+ var failTestCase1 = CreateTestCase("Fail1");
+
+ var failResult1 = new ObjectModel.TestResult(failTestCase1) { Outcome = TestOutcome.Failed };
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(failResult1).Object);
+
+ Assert.AreEqual(this.htmlLogger.FailedTests, 1, "Failed Tests");
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldKeepTrackOfTotalResult()
+ {
+ var passTestCase1 = CreateTestCase("Pass1");
+ var passResult1 = new ObjectModel.TestResult(passTestCase1) { Outcome = TestOutcome.Passed };
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(passResult1).Object);
+
+ Assert.AreEqual(this.htmlLogger.TotalTests, 1, "Total Tests");
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldKeepTrackOfPassedResult()
+ {
+ var passTestCase2 = CreateTestCase("Pass2");
+ var passResult2 = new ObjectModel.TestResult(passTestCase2) { Outcome = TestOutcome.Passed };
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(passResult2).Object);
+
+ Assert.AreEqual(this.htmlLogger.PassedTests, 1, "Passed Tests");
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldKeepTrackOfSkippedResult()
+ {
+
+ var skipTestCase1 = CreateTestCase("Skip1");
+ var skipResult1 = new ObjectModel.TestResult(skipTestCase1) { Outcome = TestOutcome.Skipped };
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(skipResult1).Object);
+
+ Assert.AreEqual(this.htmlLogger.SkippedTests, 1, "Skipped Tests");
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldSetDisplayNameIfDisplayNameIsNull()
+ {
+ //this assert is for checking result display name equals to null
+ var passTestCase1 = CreateTestCase("Pass1");
+ var passTestResultExpected = new ObjectModel.TestResult(passTestCase1)
+ {
+ DisplayName = null,
+ TestCase = { FullyQualifiedName = "abc" }
+ };
+
+ this.htmlLogger.TestResultHandler(new object(),new Mock(passTestResultExpected).Object);
+
+ Assert.AreEqual("abc", this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().DisplayName);
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldSetDisplayNameIfDisplayNameIsNotNull()
+ {
+ //this assert is for checking result display name not equals to null
+ var passTestCase1 = CreateTestCase("Pass1");
+ var passTestResultExpected = new ObjectModel.TestResult(passTestCase1)
+ {
+ DisplayName = "def",
+ TestCase = { FullyQualifiedName = "abc" }
+ };
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(passTestResultExpected).Object);
+
+ Assert.AreEqual("def", this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Last().DisplayName);
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldCreateTestResultProperly()
+ {
+ var passTestCase = CreateTestCase("Pass1");
+ passTestCase.DisplayName = "abc";
+ passTestCase.FullyQualifiedName = "fully";
+ passTestCase.Source = "abc/def.dll";
+ TimeSpan ts1 = new TimeSpan(0, 0, 0, 1, 0);
+
+ var passTestResultExpected = new ObjectModel.TestResult(passTestCase)
+ {
+ DisplayName = "def",
+ ErrorMessage = "error message",
+ ErrorStackTrace = "Error stack trace",
+ Duration = ts1
+ };
+
+ var eventArg = new Mock(passTestResultExpected);
+ // Act
+ this.htmlLogger.TestResultHandler(new object(), eventArg.Object);
+
+ var result = this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First();
+
+ Assert.AreEqual(result.DisplayName, "def");
+ Assert.AreEqual(result.ErrorMessage, "error message");
+ Assert.AreEqual(result.ErrorStackTrace, "Error stack trace");
+ Assert.AreEqual(result.FullyQualifiedName, "fully");
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.First().Source, "abc/def.dll");
+ Assert.AreEqual(result.Duration, "1s");
+ }
+
+ [TestMethod]
+ public void GetFormattedDurationStringShouldGiveCorrectFormat()
+ {
+ TimeSpan ts1 = new TimeSpan(0, 0, 0, 0, 1);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts1), "1ms");
+
+ TimeSpan ts2 = new TimeSpan(0, 0, 0, 1, 0);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts2), "1s");
+
+ TimeSpan ts3 = new TimeSpan(0, 0, 1, 0, 1);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts3), "1m");
+;
+ TimeSpan ts4 = new TimeSpan(0, 1, 0, 2, 3);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts4), "1h");
+
+ TimeSpan ts5 = new TimeSpan(0, 1, 2, 3, 4);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts5), "1h 2m");
+
+ TimeSpan ts6 = new TimeSpan(0, 0, 1, 2, 3);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts6), "1m 2s");
+
+ TimeSpan ts7 = new TimeSpan(0, 0, 0, 1, 3);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts7), "1s 3ms");
+
+ TimeSpan ts8 = new TimeSpan(2);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts8), "< 1ms");
+
+ TimeSpan ts10 = new TimeSpan(1, 0, 0, 1, 3);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts10), "> 1d");
+
+ TimeSpan ts9 = new TimeSpan(0, 0, 0, 0, 0);
+ Assert.AreEqual(htmlLogger.GetFormattedDurationString(ts9), null);
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldCreateOneTestEntryForEachTestCase()
+ {
+ TestCase testCase1 = CreateTestCase("TestCase1");
+ TestCase testCase2 = CreateTestCase("TestCase2");
+ ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed };
+ ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2) { Outcome = TestOutcome.Passed };
+ Mock resultEventArg1 = new Mock(result1);
+ Mock resultEventArg2 = new Mock(result2);
+
+ // Act
+ this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object);
+ this.htmlLogger.TestResultHandler(new object(), resultEventArg2.Object);
+
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, 2, "TestResultHandler is not creating test result entry for each test case");
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldCreateOneTestResultCollectionForOneSource()
+ {
+ TestCase testCase1 = CreateTestCase("TestCase1");
+ testCase1.Source = "abc.dll";
+
+ TestCase testCase2 = CreateTestCase("TestCase2");
+ testCase2.Source = "def.dll";
+
+ ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed };
+ ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2) { Outcome = TestOutcome.Passed };
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(result1).Object);
+ this.htmlLogger.TestResultHandler(new object(), new Mock(result2).Object);
+
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.Count, 2);
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.First().Source, "abc.dll");
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.Last().Source, "def.dll");
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldAddFailedResultToFailedResultListInTestResultCollection()
+ {
+ TestCase testCase1 = CreateTestCase("TestCase1");
+ ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed };
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(result1).Object);
+
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.First().FailedResultList.Count, 1);
+ }
+
+ [TestMethod]
+ public void TestResultHandlerShouldAddHierarchicalResultsForOrderedTest()
+ {
+ TestCase testCase1 = CreateTestCase("TestCase1");
+ TestCase testCase2 = CreateTestCase("TestCase2");
+ TestCase testCase3 = CreateTestCase("TestCase3");
+
+ Guid parentExecutionId = Guid.NewGuid();
+
+ ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1);
+ result1.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, parentExecutionId);
+ result1.SetPropertyValue(HtmlLoggerConstants.TestTypeProperty, HtmlLoggerConstants.OrderedTestTypeGuid);
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(result1).Object);
+
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, 1, "test handler is adding parent result correctly");
+ Assert.IsNull(this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().InnerTestResults, "test handler is adding child result correctly");
+
+ var result2 = new ObjectModel.TestResult(testCase2);
+ result2.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, Guid.NewGuid());
+ result2.SetPropertyValue(HtmlLoggerConstants.ParentExecIdProperty, parentExecutionId);
+
+ var result3 = new ObjectModel.TestResult(testCase3) { Outcome = TestOutcome.Failed };
+ result3.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, Guid.NewGuid());
+ result3.SetPropertyValue(HtmlLoggerConstants.ParentExecIdProperty, parentExecutionId);
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(result2).Object);
+ this.htmlLogger.TestResultHandler(new object(), new Mock(result3).Object);
+
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, 1, "test handler is adding parent result correctly");
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().InnerTestResults.Count, 2, "test handler is adding child result correctly");
+ }
+
+ [TestMethod]
+ public void TestCompleteHandlerShouldKeepTackOfSummary()
+ {
+ TestCase passTestCase1 = CreateTestCase("Pass1");
+ TestCase passTestCase2 = CreateTestCase("Pass2");
+ TestCase failTestCase1 = CreateTestCase("Fail1");
+ TestCase skipTestCase1 = CreateTestCase("Skip1");
+ var passResult1 = new ObjectModel.TestResult(passTestCase1) { Outcome = TestOutcome.Passed };
+ var passResult2 = new ObjectModel.TestResult(passTestCase2) { Outcome = TestOutcome.Passed };
+ var failResult1 = new ObjectModel.TestResult(failTestCase1) { Outcome = TestOutcome.Failed };
+ var skipResult1 = new ObjectModel.TestResult(skipTestCase1) { Outcome = TestOutcome.Skipped };
+
+ this.htmlLogger.TestResultHandler(new object(), new Mock(passResult1).Object);
+ this.htmlLogger.TestResultHandler(new object(), new Mock(passResult2).Object);
+ this.htmlLogger.TestResultHandler(new object(), new Mock(failResult1).Object);
+ this.htmlLogger.TestResultHandler(new object(), new Mock(skipResult1).Object);
+
+ this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) =>
+ {
+ }).Returns(new Mock().Object);
+
+ this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, TimeSpan.Zero));
+
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.Summary.TotalTests, 4, "summary should keep track of total tests");
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.Summary.FailedTests, 1, "summary should keep track of failed tests");
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.Summary.PassedTests, 2, "summary should keep track of passed tests");
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.Summary.SkippedTests, 1, "summary should keep track of passed tests");
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.Summary.PassPercentage, 50, "summary should keep track of passed tests");
+ Assert.AreEqual(this.htmlLogger.TestRunDetails.Summary.TotalRunTime, null, "summary should keep track of passed tests");
+ }
+
+ [TestMethod]
+ public void TestCompleteHandlerShouldCreateCustumHtmlFileNameIfParameterDirectoryIsNull()
+ {
+ var parameters = new Dictionary();
+ parameters[HtmlLoggerConstants.LogFileNameKey] = null;
+ parameters[DefaultLoggerParameterNames.TestRunDirectory] = "dsa";
+
+ var testCase1 = CreateTestCase("TestCase1");
+ var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed };
+ var resultEventArg1 = new Mock(result1);
+ this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object);
+
+ this.htmlLogger.Initialize(new Mock().Object, parameters);
+ this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, TimeSpan.Zero));
+ Assert.IsTrue(this.htmlLogger.HtmlFilePath.Contains("TestResult"));
+ }
+
+ [TestMethod]
+ public void TestCompleteHandlerShouldCreateFileCorrectly()
+ {
+ var testCase1 = CreateTestCase("TestCase1");
+ var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed };
+ var resultEventArg1 = new Mock(result1);
+
+
+ this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) =>
+ {
+ }).Returns(new Mock().Object);
+
+ this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object);
+ this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, TimeSpan.Zero));
+
+ this.mockFileHelper.Verify(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite), Times.Once);
+ }
+
+ [TestMethod]
+ public void TestCompleteHandlerShouldDeleteFileCorrectly()
+ {
+ var testCase1 = CreateTestCase("TestCase1");
+ var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed };
+ var resultEventArg1 = new Mock(result1);
+
+ this.mockFileHelper.Setup(x => x.Delete(It.IsAny())).Callback((x) =>
+ {
+ });
+
+ this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object);
+ this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, TimeSpan.Zero));
+
+ this.mockFileHelper.Verify(x => x.Delete(It.IsAny()), Times.Once);
+ }
+
+
+ [TestMethod]
+ public void TestCompleteHandlerShouldCallHtmlTransformerCorrectly()
+ {
+ var testCase1 = CreateTestCase("TestCase1");
+ var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed };
+ var resultEventArg1 = new Mock(result1);
+
+ this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) =>
+ {
+ }).Returns(new Mock().Object);
+
+ this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object);
+ this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, TimeSpan.Zero));
+
+ this.mockHtmlTransformer.Verify(x => x.Transform(It.IsAny(), It.IsAny()), Times.Once);
+ }
+
+ [TestMethod]
+ public void TestCompleteHandlerShouldWriteToXmlSerializerCorrectly()
+ {
+ var testCase1 = CreateTestCase("TestCase1") ?? throw new ArgumentNullException($"CreateTestCase(\"TestCase1\")");
+ var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed };
+ var resultEventArg1 = new Mock(result1);
+ this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) =>
+ {
+ }).Returns(new Mock().Object);
+
+ this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object);
+ this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, TimeSpan.Zero));
+
+ this.mockXmlSerializer.Verify(x => x.WriteObject(It.IsAny(), It.IsAny()), Times.Once);
+ Assert.IsTrue(htmlLogger.XmlFilePath.Contains(".xml"));
+ Assert.IsTrue(htmlLogger.HtmlFilePath.Contains(".html"));
+ }
+
+ private static TestCase CreateTestCase(string testCaseName)
+ {
+ return new TestCase(testCaseName, new Uri("some://uri"), "DummySourceFileName");
+ }
+ }
+}
+
+
+
+
+
+
diff --git a/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests.csproj b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests.csproj
new file mode 100644
index 0000000000..9b61960acb
--- /dev/null
+++ b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests.csproj
@@ -0,0 +1,24 @@
+
+
+
+ ..\..\
+ true
+ true
+ true
+
+
+
+ Exe
+ netcoreapp2.1;net451
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Program.cs b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Program.cs
new file mode 100644
index 0000000000..d674656dd0
--- /dev/null
+++ b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Program.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests
+{
+ public static class Program
+ {
+ public static void Main(string[] args)
+ {
+ }
+ }
+}
diff --git a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs
index 0eb5f6f1a4..96291ad49c 100644
--- a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs
+++ b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs
@@ -179,13 +179,11 @@ public void TestResultHandlerKeepingTheTrackOfPassedAndFailedTests()
Mock fail1 = new Mock(failResult1);
Mock skip1 = new Mock(skipResult1);
-
this.testableTrxLogger.TestResultHandler(new object(), pass1.Object);
this.testableTrxLogger.TestResultHandler(new object(), pass2.Object);
this.testableTrxLogger.TestResultHandler(new object(), fail1.Object);
this.testableTrxLogger.TestResultHandler(new object(), skip1.Object);
-
Assert.AreEqual(this.testableTrxLogger.PassedTestCount, 2, "Passed Tests");
Assert.AreEqual(this.testableTrxLogger.FailedTestCount, 1, "Failed Tests");
}
@@ -215,13 +213,11 @@ public void TestResultHandlerKeepingTheTrackOfTotalTests()
Mock fail1 = new Mock(failResult1);
Mock skip1 = new Mock(skipResult1);
-
this.testableTrxLogger.TestResultHandler(new object(), pass1.Object);
this.testableTrxLogger.TestResultHandler(new object(), pass2.Object);
this.testableTrxLogger.TestResultHandler(new object(), fail1.Object);
this.testableTrxLogger.TestResultHandler(new object(), skip1.Object);
-
Assert.AreEqual(this.testableTrxLogger.TotalTestCount, 4, "Passed Tests");
}