Example #1
0
        public void HandleEndpointSignIn()
        {
            var localEndpoint     = new EndpointId("local");
            var notifier          = new Mock <IStoreInformationAboutEndpoints>();
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var hub = new RemoteNotificationHub(
                notifier.Object,
                new NotificationProxyBuilder(
                    localEndpoint,
                    (e, msg, r) => { },
                    systemDiagnostics),
                systemDiagnostics);

            var endpoint = new EndpointId("other");
            var types    = new List <OfflineTypeInformation>
            {
                new OfflineTypeInformation(
                    typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler).FullName,
                    typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler).Assembly.GetName())
            };

            var eventWasTriggered = false;

            hub.OnEndpointConnected += (s, e) =>
            {
                eventWasTriggered = true;
                Assert.AreEqual(endpoint, e.Endpoint);
                Assert.IsTrue(hub.HasNotificationFor(e.Endpoint, typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler)));
            };

            hub.OnReceiptOfEndpointNotifications(endpoint, types);
            Assert.IsTrue(eventWasTriggered);
        }
Example #2
0
        public void NotificationsFor()
        {
            var localEndpoint     = new EndpointId("local");
            var notifier          = new Mock <IStoreInformationAboutEndpoints>();
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var hub = new RemoteNotificationHub(
                notifier.Object,
                new NotificationProxyBuilder(
                    localEndpoint,
                    (e, msg, r) => { },
                    systemDiagnostics),
                systemDiagnostics);

            var endpoint = new EndpointId("other");
            var types    = new List <OfflineTypeInformation>
            {
                new OfflineTypeInformation(
                    typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler).FullName,
                    typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler).Assembly.GetName())
            };

            hub.OnReceiptOfEndpointNotifications(endpoint, types);

            var proxy = hub.NotificationsFor <InteractionExtensionsTest.IMockNotificationSetWithEventHandler>(endpoint);

            Assert.IsNotNull(proxy);
            Assert.IsInstanceOf <NotificationSetProxy>(proxy);
            Assert.IsInstanceOf <InteractionExtensionsTest.IMockNotificationSetWithEventHandler>(proxy);
        }
Example #3
0
        public void RaiseNotification()
        {
            var localEndpoint     = new EndpointId("local");
            var notifier          = new Mock <IStoreInformationAboutEndpoints>();
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var hub = new RemoteNotificationHub(
                notifier.Object,
                new NotificationProxyBuilder(
                    localEndpoint,
                    (e, msg, r) => { },
                    systemDiagnostics),
                systemDiagnostics);

            var endpoint = new EndpointId("other");
            var types    = new List <OfflineTypeInformation>
            {
                new OfflineTypeInformation(
                    typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler).FullName,
                    typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler).Assembly.GetName())
            };

            hub.OnReceiptOfEndpointNotifications(endpoint, types);

            var proxy = hub.NotificationsFor <InteractionExtensionsTest.IMockNotificationSetWithEventHandler>(endpoint);

            Assert.IsNotNull(proxy);

            var id   = NotificationId.Create(typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler).GetEvent("OnMyEvent"));
            var args = new EventArgs();

            var wasEventRaised = false;

            proxy.OnMyEvent +=
                (s, e) =>
            {
                wasEventRaised = true;
                Assert.AreSame(args, e);
            };
            hub.RaiseNotification(endpoint, id, args);

            Assert.IsTrue(wasEventRaised);
        }