Example #1
0
        public void TestRunMessageLoggerProxySendMessageShouldInvokeRegisteredEventHandler()
        {
            var receivedRunMessage = false;

            using (loggerEvents)
            {
                loggerEvents.TestRunMessage += (sender, e) =>
                {
                    receivedRunMessage = true;
                };

                testSessionMessageLogger.SendMessage(TestMessageLevel.Error, "This is a string.");
            }

            Assert.IsTrue(receivedRunMessage);
        }
        public void InitializeShouldVerifyTheHandlerInitializationWhenAdapterIsFailedToLoad()
        {
            var mockLogger = new Mock <ITestMessageEventHandler>();

            //when handler instance is null
            sessionLogger.SendMessage(It.IsAny <TestMessageLevel>(), "verify that the HandleLogMessage method will not be invoked when handler is not initialized");

            // Verify.
            mockLogger.Verify(rd => rd.HandleLogMessage(It.IsAny <TestMessageLevel>(), "verify that the HandleLogMessage method will not be invoked when handler is not initialized"), Times.Never);
        }
Example #3
0
        public void DiscoveryInitializeShouldVerifyWarningMessageIfAdapterFailedToLoad()
        {
            var assemblyLocation = typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location;
            var mockLogger       = new Mock <ITestDiscoveryEventsHandler2>();

            TestPluginCacheHelper.SetupMockExtensions(
                new string[] { assemblyLocation },
                () => { });

            //Act
            this.discoveryManager.Initialize(new List <string> {
                assemblyLocation
            }, mockLogger.Object);

            //when handler instance returns warning
            sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that the HandleLogMessage method getting invoked at least once");

            // Verify.
            mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that the HandleLogMessage method getting invoked at least once"), Times.Once);
        }