Пример #1
0
        public void RegisterNotification()
        {
            NotificationName notification          = null;
            Action <INotificationArguments> action = null;

            var service = new Mock <IUserInterfaceService>();
            {
                service.Setup(s => s.RegisterNotification(It.IsAny <NotificationName>(), It.IsAny <Action <INotificationArguments> >()))
                .Callback <NotificationName, Action <INotificationArguments> >(
                    (n, o) =>
                {
                    notification = n;
                    action       = o;
                });
            }

            var notificationNames = new Mock <INotificationNameConstants>();
            {
                notificationNames.Setup(n => n.SystemShuttingDown)
                .Returns(new NotificationName("a"));
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var facade            = new ApplicationFacade(service.Object, notificationNames.Object, systemDiagnostics);

            var name = new NotificationName("bla");
            Action <INotificationArguments> callback = o => { };

            facade.RegisterNotification(name, callback);

            Assert.AreSame(name, notification);
            Assert.AreSame(callback, action);
        }
Пример #2
0
        public void Shutdown()
        {
            bool wasTriggered = false;

            var service = new Mock <IUserInterfaceService>();
            {
                service.Setup(s => s.Contains(It.IsAny <CommandId>()))
                .Returns(true);
                service.Setup(s => s.Invoke(It.IsAny <CommandId>(), It.IsAny <ICommandContext>()))
                .Callback <CommandId, ICommandContext>(
                    (id, context) =>
                {
                    Assert.AreEqual(ShutdownApplicationCommand.CommandId, id);

                    wasTriggered = true;
                });
            }

            var notificationNames = new Mock <INotificationNameConstants>();
            {
                notificationNames.Setup(n => n.SystemShuttingDown)
                .Returns(new NotificationName("a"));
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var facade            = new ApplicationFacade(service.Object, notificationNames.Object, systemDiagnostics);

            facade.Shutdown();
            Assert.IsTrue(wasTriggered);
        }
Пример #3
0
        public void RegisterNotification()
        {
            NotificationName notification = null;
            Action<INotificationArguments> action = null;

            var service = new Mock<IUserInterfaceService>();
            {
                service.Setup(s => s.RegisterNotification(It.IsAny<NotificationName>(), It.IsAny<Action<INotificationArguments>>()))
                    .Callback<NotificationName, Action<INotificationArguments>>(
                        (n, o) =>
                            {
                                notification = n;
                                action = o;
                            });
            }

            var notificationNames = new Mock<INotificationNameConstants>();
            {
                notificationNames.Setup(n => n.SystemShuttingDown)
                    .Returns(new NotificationName("a"));
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var facade = new ApplicationFacade(service.Object, notificationNames.Object, systemDiagnostics);

            var name = new NotificationName("bla");
            Action<INotificationArguments> callback = o => { };
            facade.RegisterNotification(name, callback);

            Assert.AreSame(name, notification);
            Assert.AreSame(callback, action);
        }
Пример #4
0
        public void ApplicationStatus()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var service = new Mock<IUserInterfaceService>();
            var notificationNames = new Mock<INotificationNameConstants>();
            {
                notificationNames.Setup(n => n.SystemShuttingDown)
                    .Returns(new NotificationName("a"));
            }

            var facade = new ApplicationFacade(service.Object, notificationNames.Object, systemDiagnostics);

            var status = facade.ApplicationStatus;
            Assert.IsNotNull(status);
            Assert.AreEqual(typeof(ApplicationFacade).Assembly.GetName().Version, status.CoreVersion);
        }
Пример #5
0
        public void ApplicationStatus()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var service           = new Mock <IUserInterfaceService>();
            var notificationNames = new Mock <INotificationNameConstants>();
            {
                notificationNames.Setup(n => n.SystemShuttingDown)
                .Returns(new NotificationName("a"));
            }

            var facade = new ApplicationFacade(service.Object, notificationNames.Object, systemDiagnostics);

            var status = facade.ApplicationStatus;

            Assert.IsNotNull(status);
            Assert.AreEqual(typeof(ApplicationFacade).Assembly.GetName().Version, status.CoreVersion);
        }
Пример #6
0
        public void Shutdown()
        {
            bool wasTriggered = false;

            var service = new Mock<IUserInterfaceService>();
            {
                service.Setup(s => s.Contains(It.IsAny<CommandId>()))
                    .Returns(true);
                service.Setup(s => s.Invoke(It.IsAny<CommandId>(), It.IsAny<ICommandContext>()))
                    .Callback<CommandId, ICommandContext>(
                        (id, context) =>
                            {
                                Assert.AreEqual(ShutdownApplicationCommand.CommandId, id);

                                wasTriggered = true;
                            });
            }

            var notificationNames = new Mock<INotificationNameConstants>();
            {
                notificationNames.Setup(n => n.SystemShuttingDown)
                    .Returns(new NotificationName("a"));
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var facade = new ApplicationFacade(service.Object, notificationNames.Object, systemDiagnostics);
            facade.Shutdown();
            Assert.IsTrue(wasTriggered);
        }