Пример #1
0
        public void CanDeactivateWithNullDataset()
        {
            var project = new Mock <ILinkToProjects>();

            Func <string, IDisposable> timerFunc = s => new MockDisposable();

            var command = new DeactivateDatasetCommand(project.Object, null, timerFunc);

            Assert.IsFalse(command.CanExecute(null));
        }
Пример #2
0
        public void DeactivateDataset()
        {
            var history = new Mock <ITimeline>();
            {
                history.Setup(h => h.Mark())
                .Verifiable();
            }

            var project = new Mock <IProject>();
            {
                project.Setup(p => p.History)
                .Returns(history.Object);
            }

            var projectFacade = new ProjectFacade(project.Object);
            var projectLink   = new Mock <ILinkToProjects>();

            {
                projectLink.Setup(p => p.ActiveProject())
                .Returns(projectFacade);
            }

            using (var source = new CancellationTokenSource())
            {
                var proxy = new Mock <IProxyDataset>();
                {
                    proxy.Setup(p => p.IsActivated)
                    .Returns(true);
                    proxy.Setup(p => p.Deactivate())
                    .Returns(() => Task.Factory.StartNew(
                                 () =>
                    {
                    },
                                 source.Token,
                                 TaskCreationOptions.None,
                                 new CurrentThreadTaskScheduler()))
                    .Verifiable();
                }

                var dataset = new DatasetFacade(proxy.Object);

                Func <string, IDisposable> timerFunc = s => new MockDisposable();

                var command = new DeactivateDatasetCommand(projectLink.Object, dataset, timerFunc);
                command.Execute(null);

                proxy.Verify(p => p.Deactivate(), Times.Once());
                history.Verify(h => h.Mark(), Times.Once());
            }
        }
Пример #3
0
        public void CanDeactivateWithDeactivatedDataset()
        {
            var project = new Mock <ILinkToProjects>();

            var proxy = new Mock <IProxyDataset>();
            {
                proxy.Setup(p => p.IsActivated)
                .Returns(false);
            }

            var dataset = new DatasetFacade(proxy.Object);

            Func <string, IDisposable> timerFunc = s => new MockDisposable();

            var command = new DeactivateDatasetCommand(project.Object, dataset, timerFunc);

            Assert.IsFalse(command.CanExecute(null));
        }