Ejemplo n.º 1
0
        public void DotNetBrowserServiceNormalTest()
        {
            var serviceProviderMock = new Mock <IServiceProvider>();
            var eventAggregator     = new EventAggregator();

            var browserService = new DotNetBrowserServiceStub(
                serviceProviderMock.Object,
                eventAggregator
                );

            browserService.PostMessage("bootstrap1");
            //goes through -- no queue
            Assert.IsTrue(browserService.QueueCount == 0);
            eventAggregator.Publish(new WebviewDidInitializeEvent());
            browserService.PostMessage("bootstrap2");
            //goes through -- no queue
            Assert.IsTrue(browserService.QueueCount == 0);
            eventAggregator.Publish(new SessionLogoutEvent());
            browserService.PostMessage("bootstrap3");
            Thread.Sleep(1);
            eventAggregator.Publish(new WebviewDidInitializeEvent());
            Thread.Sleep(1);
            Assert.IsTrue(browserService.QueueCount == 0);

            Assert.IsTrue(browserService.Items[0] == "bootstrap1");
            Assert.IsTrue(browserService.Items[1] == "bootstrap2");
            Assert.IsTrue(browserService.Items[2] == "bootstrap3");
            browserService.Dispose();
        }
Ejemplo n.º 2
0
        public void DotNetBrowserServiceNormalThenQueuedTest()
        {
            var serviceProviderMock = new Mock <IServiceProvider>();
            var eventAggregator     = new EventAggregator();

            var browserService = new DotNetBrowserServiceStub(
                serviceProviderMock.Object,
                eventAggregator
                );

            browserService.PostMessage("bootstrap1");
            browserService.PostMessage("bootstrap2");
            browserService.PostMessage("lsp1", true);
            browserService.PostMessage("lsp2", true);
            browserService.PostMessage("lsp3", true);
            browserService.PostMessage("bootstrap3");
            browserService.PostMessage("bootstrap4");

            Assert.IsTrue(browserService.QueueCount > 0);
            Assert.IsTrue(browserService.QueueCount < 4);
            eventAggregator.Publish(new WebviewDidInitializeEvent());
            Thread.Sleep(1000);
            Assert.IsTrue(browserService.QueueCount == 0);
            Assert.IsTrue(browserService.Items[0] == "bootstrap1");
            Assert.IsTrue(browserService.Items[1] == "bootstrap2");
            Assert.IsTrue(browserService.Items[2] == "bootstrap3");
            Assert.IsTrue(browserService.Items[3] == "bootstrap4");
            Assert.IsTrue(browserService.Items[4] == "lsp1");
            Assert.IsTrue(browserService.Items[5] == "lsp2");
            Assert.IsTrue(browserService.Items[6] == "lsp3");

            browserService.Dispose();
        }
Ejemplo n.º 3
0
        public void DotNetBrowserServiceReloadTest()
        {
            var serviceProviderMock = new Mock <IServiceProvider>();
            var eventAggregator     = new EventAggregator();

            var browserService = new DotNetBrowserServiceStub(
                serviceProviderMock.Object,
                eventAggregator
                );

            browserService.PostMessage("bootstrap1");
            Assert.IsTrue(browserService.QueueCount == 0);
            for (var i = 0; i < 200; i++)
            {
                browserService.PostMessage($"data{i}", true);
            }
            eventAggregator.Publish(new WebviewDidInitializeEvent());
            SpinWait.SpinUntil(() => browserService.WasReloaded, 2000);
            Assert.AreEqual(true, browserService.WasReloaded);
            browserService.Dispose();
        }