예제 #1
0
        public void Stop()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            ITimeline timeline    = new Timeline(BuildStorage);
            var       distributor = new Mock <IHelpDistributingDatasets>();
            var       builder     = new Mock <IBuildProjects>();

            var proxyLayer = new Mock <IProxyCompositionLayer>();
            var service    = new ProjectService(
                () => timeline,
                d => new DatasetStorageProxy(
                    d,
                    new GroupSelector(
                        new Mock <IConnectGroups>().Object,
                        proxyLayer.Object),
                    proxyLayer.Object),
                distributor.Object,
                new Mock <ICollectNotifications>().Object,
                systemDiagnostics,
                builder.Object);

            service.Start();
            Assert.AreEqual(StartupState.Started, service.StartupState);

            service.Stop();
            Assert.AreEqual(StartupState.Stopped, service.StartupState);
        }
예제 #2
0
        public void StopWithProject()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            ITimeline timeline    = new Timeline(BuildStorage);
            var       distributor = new Mock <IHelpDistributingDatasets>();

            bool wasClosed = false;
            var  project   = new Mock <IProject>();
            var  closable  = project.As <ICanClose>();
            {
                closable.Setup(c => c.Close())
                .Callback(() => { wasClosed = true; });
            }

            var builder = new Mock <IBuildProjects>();
            {
                builder.Setup(b => b.Define())
                .Returns(builder.Object)
                .Verifiable();

                builder.Setup(b => b.WithTimeline(It.IsAny <ITimeline>()))
                .Returns(builder.Object)
                .Verifiable();

                builder.Setup(
                    b => b.WithDatasetDistributor(
                        It.IsAny <Func <DatasetActivationRequest, CancellationToken, IEnumerable <DistributionPlan> > >()))
                .Returns(builder.Object)
                .Verifiable();

                builder.Setup(b => b.WithDataStorageBuilder(It.IsAny <Func <DatasetOnlineInformation, DatasetStorageProxy> >()))
                .Returns(builder.Object)
                .Verifiable();

                builder.Setup(b => b.WithNotifications(It.IsAny <ICollectNotifications>()))
                .Returns(builder.Object)
                .Verifiable();

                builder.Setup(b => b.WithDiagnostics(It.IsAny <SystemDiagnostics>()))
                .Returns(builder.Object)
                .Verifiable();

                builder.Setup(b => b.Build())
                .Returns(project.Object)
                .Verifiable();
            }

            var proxyLayer = new Mock <IProxyCompositionLayer>();
            var service    = new ProjectService(
                () => timeline,
                d => new DatasetStorageProxy(
                    d,
                    new GroupSelector(
                        new Mock <IConnectGroups>().Object,
                        proxyLayer.Object),
                    proxyLayer.Object),
                distributor.Object,
                new Mock <ICollectNotifications>().Object,
                systemDiagnostics,
                builder.Object);

            service.Start();
            Assert.AreEqual(StartupState.Started, service.StartupState);

            service.CreateNewProject();

            var createdProject = service.Current;

            Assert.IsNotNull(createdProject);

            service.Stop();
            Assert.AreEqual(StartupState.Stopped, service.StartupState);
            Assert.IsTrue(wasClosed);
        }
예제 #3
0
        public void StopWithProject()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            ITimeline timeline = new Timeline(BuildStorage);
            var distributor = new Mock<IHelpDistributingDatasets>();

            bool wasClosed = false;
            var project = new Mock<IProject>();
            var closable = project.As<ICanClose>();
            {
                closable.Setup(c => c.Close())
                    .Callback(() => { wasClosed = true; });
            }

            var builder = new Mock<IBuildProjects>();
            {
                builder.Setup(b => b.Define())
                    .Returns(builder.Object)
                    .Verifiable();

                builder.Setup(b => b.WithTimeline(It.IsAny<ITimeline>()))
                    .Returns(builder.Object)
                    .Verifiable();

                builder.Setup(
                        b => b.WithDatasetDistributor(
                            It.IsAny<Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>>>()))
                    .Returns(builder.Object)
                    .Verifiable();

                builder.Setup(b => b.WithDataStorageBuilder(It.IsAny<Func<DatasetOnlineInformation, DatasetStorageProxy>>()))
                    .Returns(builder.Object)
                    .Verifiable();

                builder.Setup(b => b.WithNotifications(It.IsAny<ICollectNotifications>()))
                    .Returns(builder.Object)
                    .Verifiable();

                builder.Setup(b => b.WithDiagnostics(It.IsAny<SystemDiagnostics>()))
                    .Returns(builder.Object)
                    .Verifiable();

                builder.Setup(b => b.Build())
                    .Returns(project.Object)
                    .Verifiable();
            }

            var proxyLayer = new Mock<IProxyCompositionLayer>();
            var service = new ProjectService(
                () => timeline,
                d => new DatasetStorageProxy(
                    d,
                    new GroupSelector(
                        new Mock<IConnectGroups>().Object,
                        proxyLayer.Object),
                    proxyLayer.Object),
                distributor.Object,
                new Mock<ICollectNotifications>().Object,
                systemDiagnostics,
                builder.Object);

            service.Start();
            Assert.AreEqual(StartupState.Started, service.StartupState);

            service.CreateNewProject();

            var createdProject = service.Current;
            Assert.IsNotNull(createdProject);

            service.Stop();
            Assert.AreEqual(StartupState.Stopped, service.StartupState);
            Assert.IsTrue(wasClosed);
        }
예제 #4
0
        public void Stop()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            ITimeline timeline = new Timeline(BuildStorage);
            var distributor = new Mock<IHelpDistributingDatasets>();
            var builder = new Mock<IBuildProjects>();

            var proxyLayer = new Mock<IProxyCompositionLayer>();
            var service = new ProjectService(
                () => timeline,
                d => new DatasetStorageProxy(
                    d,
                    new GroupSelector(
                        new Mock<IConnectGroups>().Object,
                        proxyLayer.Object),
                    proxyLayer.Object),
                distributor.Object,
                new Mock<ICollectNotifications>().Object,
                systemDiagnostics,
                builder.Object);

            service.Start();
            Assert.AreEqual(StartupState.Started, service.StartupState);

            service.Stop();
            Assert.AreEqual(StartupState.Stopped, service.StartupState);
        }