Пример #1
0
        public void InNormalModeTestWarningAndErrorMessagesShouldShow()
        {
            // Setup
            var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance);

            loggerEvents.EnableEvents();
            var parameters = new Dictionary <string, string>
            {
                { "verbosity", "normal" }
            };

            this.consoleLogger.Initialize(loggerEvents, parameters);
            string message      = "Adapter Warning";
            string errorMessage = "Adapter Error";

            // Act. Raise an event on mock object
            loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, message));
            loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, errorMessage));
            loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock <ITestRunStatistics>().Object, false, false, null, new Collection <AttachmentSet>(), TimeSpan.FromSeconds(1)));
            loggerEvents.WaitForEventCompletion();

            // Verify
            this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunFailed, OutputLevel.Error), Times.Once());
            this.mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Warning), Times.Once());
            this.mockOutput.Verify(o => o.WriteLine(errorMessage, OutputLevel.Error), Times.Once());
        }
Пример #2
0
        public void InQuietModeTestWarningMessageShouldNotShow()
        {
            // Setup
            var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance);

            loggerEvents.EnableEvents();
            var parameters = new Dictionary <string, string>
            {
                { "verbosity", "quiet" }
            };

            this.consoleLogger.Initialize(loggerEvents, parameters);
            string message = "Adapter Warning";

            // Act. Raise an event on mock object
            loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, message));
            loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock <ITestRunStatistics>().Object, false, false, null, new Collection <AttachmentSet>(), TimeSpan.FromSeconds(1)));

            // Verify
            this.mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Warning), Times.Never());
        }