예제 #1
0
        public void AnnouncementServiceStartIsCalledBeforeTheServiceHostIsOpened()
        {
            var announcementService = Mocks.DynamicMock<IAnnouncementService>();

            announcementService.OnOnlineEvent += null;
            LastCall.IgnoreArguments();

            announcementService.OnOfflineEvent += null;
            LastCall.IgnoreArguments();

            announcementService.Expect(v => v.Start());

            var serviceHostHelper = Mocks.DynamicMock<IServiceHostHelper>();

            serviceHostHelper.Expect(v => v.OpenServiceHost(null, null)).IgnoreArguments();

            Mocks.ReplayAll();

            Mocks.Ordered();

            var listener = new NodeListener("JUNK")
                               {
                                   AnnouncementService = announcementService,
                                   ServiceHostHelper = serviceHostHelper
                               };

            listener.Start(null, null);
        }
예제 #2
0
        public void ANodeListenerIsCreatedWithAId()
        {
            const string nodelistenid = "NodeListenId";

            var listener = new NodeListener(nodelistenid);

            Assert.That(listener.Id, Is.EqualTo(nodelistenid));
        }
예제 #3
0
        public void OnLineAndOffLineEventsAreRegisterdOnStartUpOnly()
        {
            var announcementService = Mocks.DynamicMock<IAnnouncementService>();

            announcementService.OnOnlineEvent += null;
            LastCall.IgnoreArguments().Repeat.Never();

            announcementService.OnOfflineEvent += null;
            LastCall.IgnoreArguments().Repeat.Never();

            Mocks.ReplayAll();

            var listener = new NodeListener("JUNK");

            listener.AnnouncementService = announcementService;
        }
예제 #4
0
        public void WhenListenerIsStartedAServiceHostIsOpened()
        {
            var mockNode = Mocks.DynamicMock<INode>();

            var serviceHostHelper = Mocks.DynamicMock<IServiceHostHelper>();

            IAnnouncementService annoucementService = StubAnnoucementService();

            var baseAddress = new Uri("http://fatcatnode.com/Testing");

            serviceHostHelper.Expect(v => v.OpenServiceHost(mockNode, baseAddress));

            Mocks.ReplayAll();

            var listener = new NodeListener("TestNodeId");

            listener.ServiceHostHelper = serviceHostHelper;

            listener.AnnouncementService = annoucementService;

            listener.Start(mockNode, baseAddress);
        }
예제 #5
0
        public void WhenListenStartsAnAnnouncementIsMade()
        {
            IServiceHostHelper serviceHostHelper = StubServiceHostHelper();

            var announcementService = Mocks.DynamicMock<IAnnouncementService>();

            announcementService.OnOnlineEvent += null;
            LastCall.IgnoreArguments();

            announcementService.OnOfflineEvent += null;
            LastCall.IgnoreArguments();

            announcementService.Expect(v => v.Start());

            Mocks.ReplayAll();

            var listener = new NodeListener("JUNK");
            listener.ServiceHostHelper = serviceHostHelper;

            listener.AnnouncementService = announcementService;

            listener.Start(null, null);
        }