public void MultipleAssemblies() { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; var clockTime = TimeSpan.FromSeconds(12.3456); var @short = new ExecutionSummary { Total = 2112, Errors = 6, Failed = 42, Skipped = 8, Time = 1.2345M }; var nothing = new ExecutionSummary { Total = 0 }; var longerName = new ExecutionSummary { Total = 10240, Errors = 7, Failed = 96, Skipped = 4, Time = 3.4567M }; var message = new TestExecutionSummary(clockTime, new List <KeyValuePair <string, ExecutionSummary> > { new KeyValuePair <string, ExecutionSummary>("short", @short), new KeyValuePair <string, ExecutionSummary>("nothing", nothing), new KeyValuePair <string, ExecutionSummary>("longerName", longerName), }); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); Assert.Collection(handler.Messages, msg => Assert.Equal("[Imp] => === TEST EXECUTION SUMMARY ===", msg), msg => Assert.Equal("[Imp] => short Total: 2112, Errors: 6, Failed: 42, Skipped: 8, Time: 1.235s", msg), msg => Assert.Equal("[Imp] => nothing Total: 0", msg), msg => Assert.Equal("[Imp] => longerName Total: 10240, Errors: 7, Failed: 96, Skipped: 4, Time: 3.457s", msg), msg => Assert.Equal("[Imp] => ----- -- --- -- ------", msg), msg => Assert.Equal("[Imp] => GRAND TOTAL: 12352 13 138 12 4.691s (12.346s)", msg) ); }
public void DoesNotLogOutputByDefault() { var message = Mocks.TestPassed("This is my display name \t\r\n", output: "This is\t" + Environment.NewLine + "output"); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); Assert.Empty(handler.Messages); }
public static void LogsMessage(bool diagnosticMessages, string expectedResult) { var message = Mocks.TestAssemblyExecutionStarting(diagnosticMessages: diagnosticMessages); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); var msg = Assert.Single(handler.Messages); Assert.Equal <object>(expectedResult, msg); }
public static void LogsMessage() { var message = Mocks.TestAssemblyExecutionFinished(); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); var msg = Assert.Single(handler.Messages); Assert.Equal("[Imp] => Finished: testAssembly", msg); }
public static void LogsMessage(bool diagnosticMessages, int toRun, int discovered, string expectedResult) { var message = Mocks.TestAssemblyDiscoveryFinished(diagnosticMessages, toRun, discovered); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); var msg = Assert.Single(handler.Messages); Assert.Equal(expectedResult, msg); }
public static void LogsTestNameAsWarning() { var message = Mocks.TestSkipped("This is my display name \t\r\n", "This is my skip reason \t\r\n"); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); Assert.Collection(handler.Messages, msg => Assert.Equal("[Wrn] => This is my display name \\t\\r\\n [SKIP]", msg), msg => Assert.Equal("[Imp] => This is my skip reason \\t\\r\\n", msg) ); }
public void LogsMessage(IMessageSinkMessage message, string messageType) { var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); Assert.Collection(handler.Messages, msg => Assert.Equal("[Err @ SomeFolder\\SomeClass.cs:18] => [" + messageType + "] ExceptionType", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => ExceptionType : This is my message \t", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => Message Line 2", msg), msg => Assert.Equal("[--- @ SomeFolder\\SomeClass.cs:18] => Stack Trace:", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => Line 1", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => SomeFolder\\SomeClass.cs(18,0): at SomeClass.SomeMethod()", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => Line 3", msg) ); }
public void LogsOutputWhenDiagnosticsAreEnabled() { var message = Mocks.TestPassed("This is my display name \t\r\n", output: "This is\t" + Environment.NewLine + "output"); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(Mocks.TestAssemblyExecutionStarting(diagnosticMessages: true, assemblyFilename: message.TestAssembly.Assembly.AssemblyPath), null); handler.Messages.Clear(); // Ignore any output from the "assembly execution starting" message handler.OnMessageWithTypes(message, null); Assert.Collection(handler.Messages, msg => Assert.Equal("[Imp] => This is my display name \\t\\r\\n [PASS]", msg), msg => Assert.Equal("[---] => Output:", msg), msg => Assert.Equal("[Imp] => This is\t", msg), msg => Assert.Equal("[Imp] => output", msg) ); }
public void SingleAssembly() { var clockTime = TimeSpan.FromSeconds(12.3456); var assembly = new ExecutionSummary { Total = 2112, Errors = 6, Failed = 42, Skipped = 8, Time = 1.2345M }; var message = new TestExecutionSummary(clockTime, new List <KeyValuePair <string, ExecutionSummary> > { new KeyValuePair <string, ExecutionSummary>("assembly", assembly) }); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); Assert.Collection(handler.Messages, msg => Assert.Equal("[Imp] => === TEST EXECUTION SUMMARY ===", msg), msg => Assert.Equal("[Imp] => assembly Total: 2112, Errors: 6, Failed: 42, Skipped: 8, Time: 1.235s", msg) ); }
public void LogsTestNameWithExceptionAndStackTraceAndOutput() { var message = Mocks.TestFailed("This is my display name \t\r\n", 1.2345M, output: "This is\t" + Environment.NewLine + "output"); SetupFailureInformation(message); var handler = TestableDefaultRunnerReporterWithTypesMessageHandler.Create(); handler.OnMessageWithTypes(message, null); Assert.Collection(handler.Messages, msg => Assert.Equal("[Err @ SomeFolder\\SomeClass.cs:18] => This is my display name \\t\\r\\n [FAIL]", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => ExceptionType : This is my message \t", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => Message Line 2", msg), msg => Assert.Equal("[--- @ SomeFolder\\SomeClass.cs:18] => Stack Trace:", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => Line 1", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => SomeFolder\\SomeClass.cs(18,0): at SomeClass.SomeMethod()", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => Line 3", msg), msg => Assert.Equal("[--- @ SomeFolder\\SomeClass.cs:18] => Output:", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => This is\t", msg), msg => Assert.Equal("[Imp @ SomeFolder\\SomeClass.cs:18] => output", msg) ); }