예제 #1
0
        public void Setup()
        {
            LoggerMock = new Mock <ILogger>();
            LoggerMock.Setup(l => l.Log(It.IsAny <LogLevel>(), It.IsAny <string>()));

            Config = DatafileProjectConfig.Create(TestData.Datafile, LoggerMock.Object, new ErrorHandler.NoOpErrorHandler());

            eventQueue          = new BlockingCollection <object>(100);
            EventDispatcherMock = new Mock <IEventDispatcher>();

            NotificationCallbackMock = new Mock <TestNotificationCallbacks>();
            NotificationCallbackMock.Setup(nc => nc.TestLogEventCallback(It.IsAny <LogEvent>()));

            NotificationCenter.AddNotification(NotificationCenter.NotificationType.LogEvent,
                                               NotificationCallbackMock.Object.TestLogEventCallback);
        }
        public void TestNotifications()
        {
            bool notificationTriggered = false;

            NotificationCenter.AddNotification(NotificationCenter.NotificationType.LogEvent, logEvent => notificationTriggered = true);
            var userEvent = CreateConversionEvent(EventName);

            EventProcessor.Process(userEvent);

            Assert.True(notificationTriggered);
        }
예제 #3
0
        public void TestAddAndRemoveNotificationListener()
        {
            // Verify that callback added successfully.
            Assert.AreEqual(1, NotificationCenter.AddNotification(NotificationTypeActivate, TestNotificationCallbacks.TestActivateCallback));
            Assert.AreEqual(1, NotificationCenter.NotificationsCount);

            // Verify that callback removed successfully.
            Assert.AreEqual(true, NotificationCenter.RemoveNotification(1));
            Assert.AreEqual(0, NotificationCenter.NotificationsCount);

            //Verify return false with invalid ID.
            Assert.AreEqual(false, NotificationCenter.RemoveNotification(1));

            // Verify that callback added successfully and return right notification ID.
            Assert.AreEqual(NotificationCenter.NotificationId, NotificationCenter.AddNotification(NotificationTypeActivate, TestNotificationCallbacks.TestActivateCallback));
            Assert.AreEqual(1, NotificationCenter.NotificationsCount);
        }