Beispiel #1
0
        public void OnSummaryChange()
        {
            var context = new Mock <IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                .Returns(true);
            }

            var progressTracker = new Mock <ITrackSteppingProgress>();
            var projectLink     = new Mock <ILinkToProjects>();

            var proxy = new Mock <IProxyDataset>();

            var dataset = new DatasetFacade(proxy.Object);
            var model   = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            var wasRaised = false;

            model.PropertyChanged += (s, e) =>
            {
                wasRaised = true;
                Assert.AreEqual("Summary", e.PropertyName);
            };

            proxy.Raise(p => p.OnSummaryChanged += null, new ValueChangedEventArgs <string>("a"));
            Assert.IsTrue(wasRaised);
        }
Beispiel #2
0
        public void OnNameChange()
        {
            var context = new Mock <IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                .Returns(true);
            }

            var progressTracker = new Mock <ITrackSteppingProgress>();
            var projectLink     = new Mock <ILinkToProjects>();

            var proxy = new Mock <IProxyDataset>();

            var dataset = new DatasetFacade(proxy.Object);
            var model   = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            var wasRaised  = 0;
            var properties = new List <string>();

            model.PropertyChanged += (s, e) =>
            {
                wasRaised++;
                properties.Add(e.PropertyName);
            };

            proxy.Raise(p => p.OnNameChanged += null, new ValueChangedEventArgs <string>("a"));
            Assert.AreEqual(1, wasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List <string>
            {
                "Name",
            }));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetViewVertex"/> class.
        /// </summary>
        /// <param name="context">The context that is used to execute actions on the UI thread.</param>
        /// <param name="model">The model of the dataset.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="model"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="context"/> is <see langword="null" />.
        /// </exception>
        public DatasetViewVertex(IContextAware context, DatasetModel model)
            : base(context)
        {
            {
                Enforce.Argument(() => model);
            }

            m_Dataset                = model;
            m_Dataset.OnActivated   += (s, e) => Notify(() => IsDatasetActivated);
            m_Dataset.OnDeactivated += (s, e) => Notify(() => IsDatasetActivated);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetViewVertex"/> class.
        /// </summary>
        /// <param name="context">The context that is used to execute actions on the UI thread.</param>
        /// <param name="model">The model of the dataset.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="model"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="context"/> is <see langword="null" />.
        /// </exception>
        public DatasetViewVertex(IContextAware context, DatasetModel model)
            : base(context)
        {
            {
                Enforce.Argument(() => model);
            }

            m_Dataset = model;
            m_Dataset.OnActivated += (s, e) => Notify(() => IsDatasetActivated);
            m_Dataset.OnDeactivated += (s, e) => Notify(() => IsDatasetActivated);
        }
Beispiel #5
0
        public void OnActivated()
        {
            var context = new Mock <IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                .Returns(true);
            }

            var progressTracker = new Mock <ITrackSteppingProgress>();
            {
                progressTracker.Setup(p => p.StopTracking())
                .Verifiable();
            }

            var projectLink = new Mock <ILinkToProjects>();

            var proxy = new Mock <IProxyDataset>();

            var dataset = new DatasetFacade(proxy.Object);
            var model   = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            var propertyChangedWasRaised = 0;
            var properties = new List <string>();

            model.PropertyChanged += (s, e) =>
            {
                propertyChangedWasRaised++;
                properties.Add(e.PropertyName);
            };
            var onLoadedWasRaised = false;

            model.OnActivated += (s, e) =>
            {
                onLoadedWasRaised = true;
            };

            proxy.Raise(p => p.OnActivated += null, EventArgs.Empty);
            Assert.AreEqual(4, propertyChangedWasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List <string>
            {
                "IsActivated",
                "RunsOn",
                "Progress",
                "ProgressDescription",
            }));
            Assert.IsTrue(onLoadedWasRaised);
            progressTracker.Verify(p => p.StopTracking(), Times.Once());
        }
        public void Create()
        {
            var context = new Mock<IContextAware>();
            var progressTracker = new Mock<ITrackSteppingProgress>();

            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);
            }

            var name = "a";
            var summary = "b";
            var proxy = new Mock<IProxyDataset>();
            {
                proxy.Setup(p => p.Name)
                    .Returns(name);
                proxy.Setup(p => p.Summary)
                    .Returns(summary);
                proxy.Setup(p => p.IsActivated)
                    .Returns(true);
            }

            var dataset = new DatasetFacade(proxy.Object);
            var model = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            Assert.AreEqual(name, model.Name);
            Assert.AreEqual(summary, model.Summary);

            Assert.IsTrue(model.IsActivated);
        }
Beispiel #7
0
        public void Create()
        {
            var context         = new Mock <IContextAware>();
            var progressTracker = new Mock <ITrackSteppingProgress>();

            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);
            }

            var name    = "a";
            var summary = "b";
            var proxy   = new Mock <IProxyDataset>();
            {
                proxy.Setup(p => p.Name)
                .Returns(name);
                proxy.Setup(p => p.Summary)
                .Returns(summary);
                proxy.Setup(p => p.IsActivated)
                .Returns(true);
            }

            var dataset = new DatasetFacade(proxy.Object);
            var model   = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            Assert.AreEqual(name, model.Name);
            Assert.AreEqual(summary, model.Summary);

            Assert.IsTrue(model.IsActivated);
        }
Beispiel #8
0
        public void UpdateName()
        {
            var context         = new Mock <IContextAware>();
            var progressTracker = new Mock <ITrackSteppingProgress>();
            var mockChangeSet   = new Mock <IChangeSet>();
            {
                mockChangeSet.Setup(m => m.StoreChanges())
                .Verifiable();
            }

            var history = new Mock <ITimeline>();
            {
                history.Setup(h => h.RecordHistory())
                .Returns(mockChangeSet.Object);
            }

            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);
            }

            var proxy = new Mock <IProxyDataset>();
            {
                proxy.Setup(p => p.Name)
                .Verifiable();
            }

            var dataset = new DatasetFacade(proxy.Object);
            var model   = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            var name = "a";

            model.Name = name;
            proxy.VerifySet(p => p.Name = It.Is <string>(s => s.Equals(name)), Times.Once());
            mockChangeSet.Verify(h => h.StoreChanges(), Times.Once());
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new dataset model.
        /// </summary>
        /// <param name="dataset">The dataset for the new model.</param>
        /// <returns>
        /// The dataset model for the given facade.
        /// </returns>
        private DatasetModel CreateModel(DatasetFacade dataset)
        {
            var context         = m_Container.Resolve <IContextAware>();
            var projectFacade   = m_Container.Resolve <ILinkToProjects>();
            var progressTracker = m_Container.Resolve <ITrackSteppingProgress>();
            var timer           = m_Container.Resolve <Func <string, IDisposable> >();
            var eventAggregator = m_Container.Resolve <IEventAggregator>();

            var result = new DatasetModel(context, progressTracker, projectFacade, dataset)
            {
                NewChildDatasetCommand   = new AddChildDatasetCommand(projectFacade, dataset, timer),
                DeleteDatasetCommand     = new DeleteDatasetCommand(projectFacade, dataset, timer),
                ActivateDatasetCommand   = CreateActivateDatasetCommand(projectFacade, dataset, timer),
                DeactivateDatasetCommand = new DeactivateDatasetCommand(projectFacade, dataset, timer),
                ShowDetailViewCommand    = new ShowDatasetDetailViewCommand(context, eventAggregator, dataset),
            };

            return(result);
        }
Beispiel #10
0
        public void OnDeactivated()
        {
            var context = new Mock <IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                .Returns(true);
            }

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

            var dataset = new DatasetFacade(proxy.Object);
            var model   = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);
            var vertex  = new DatasetViewVertex(context.Object, model);

            var propertyChangedWasRaised = 0;
            var properties = new List <string>();

            vertex.PropertyChanged += (s, e) =>
            {
                propertyChangedWasRaised++;
                properties.Add(e.PropertyName);
            };

            proxy.Raise(p => p.OnDeactivated += null, EventArgs.Empty);
            Assert.AreEqual(1, propertyChangedWasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List <string>
            {
                "IsDatasetActivated",
            }));
            Assert.IsFalse(vertex.IsDatasetActivated);
        }
        public void OnActivated()
        {
            var context = new Mock<IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                    .Returns(true);
            }

            var progressTracker = new Mock<ITrackSteppingProgress>();
            var projectLink = new Mock<ILinkToProjects>();
            var proxy = new Mock<IProxyDataset>();
            {
                proxy.Setup(p => p.IsActivated)
                    .Returns(true);
            }

            var dataset = new DatasetFacade(proxy.Object);
            var model = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);
            var vertex = new DatasetViewVertex(context.Object, model);

            var propertyChangedWasRaised = 0;
            var properties = new List<string>();
            vertex.PropertyChanged += (s, e) =>
            {
                propertyChangedWasRaised++;
                properties.Add(e.PropertyName);
            };

            proxy.Raise(p => p.OnActivated += null, EventArgs.Empty);
            Assert.AreEqual(1, propertyChangedWasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List<string>
                    {
                        "IsDatasetActivated",
                    }));
            Assert.IsTrue(vertex.IsDatasetActivated);
        }
Beispiel #12
0
        public void OnProgress()
        {
            var context         = new Mock <IContextAware>();
            var progressTracker = new Mock <ITrackSteppingProgress>();
            {
                progressTracker.Setup(p => p.StartTracking())
                .Verifiable();
                progressTracker.Setup(p => p.StopTracking())
                .Verifiable();
                progressTracker.Setup(p => p.UpdateProgress(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <bool>()))
                .Verifiable();
            }

            var projectLink = new Mock <ILinkToProjects>();

            var proxy = new Mock <IProxyDataset>();

            var dataset = new DatasetFacade(proxy.Object);
            var model   = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            // Verify here to indicate that we do really need this instance.
            Assert.IsNotNull(model);

            proxy.Raise(p => p.OnProgressOfCurrentAction += null, new ProgressEventArgs(0, "a", false));
            progressTracker.Verify(p => p.StartTracking(), Times.Once());
            progressTracker.Verify(p => p.UpdateProgress(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <bool>()), Times.Once());
            progressTracker.Verify(p => p.StopTracking(), Times.Never());

            proxy.Raise(p => p.OnProgressOfCurrentAction += null, new ProgressEventArgs(50, "b", false));
            progressTracker.Verify(p => p.StartTracking(), Times.Once());
            progressTracker.Verify(p => p.UpdateProgress(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <bool>()), Times.Exactly(2));
            progressTracker.Verify(p => p.StopTracking(), Times.Never());

            proxy.Raise(p => p.OnProgressOfCurrentAction += null, new ProgressEventArgs(100, "c", false));
            progressTracker.Verify(p => p.StartTracking(), Times.Once());
            progressTracker.Verify(p => p.UpdateProgress(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <bool>()), Times.Exactly(3));
            progressTracker.Verify(p => p.StopTracking(), Times.Once());
        }
Beispiel #13
0
        public void Convert()
        {
            var context = new Mock <IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                .Returns(true);
            }

            var progressTracker = new Mock <ITrackSteppingProgress>();
            var projectLink     = new Mock <ILinkToProjects>();
            var proxy           = new Mock <IProxyDataset>();
            {
                proxy.Setup(p => p.IsActivated)
                .Returns(true);
            }

            var dataset   = new DatasetFacade(proxy.Object);
            var model     = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);
            var vertex    = new DatasetViewVertex(context.Object, model);
            var converter = new DatasetViewVertexToDatasetModelConverter();
            var obj       = converter.Convert(vertex, null, null, null) as DatasetModel;

            Assert.AreSame(model, obj);
        }
        public void Convert()
        {
            var context = new Mock<IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                    .Returns(true);
            }

            var progressTracker = new Mock<ITrackSteppingProgress>();
            var projectLink = new Mock<ILinkToProjects>();
            var proxy = new Mock<IProxyDataset>();
            {
                proxy.Setup(p => p.IsActivated)
                    .Returns(true);
            }

            var dataset = new DatasetFacade(proxy.Object);
            var model = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);
            var vertex = new DatasetViewVertex(context.Object, model);
            var converter = new DatasetViewVertexToDatasetModelConverter();
            var obj = converter.Convert(vertex, null, null, null) as DatasetModel;

            Assert.AreSame(model, obj);
        }
Beispiel #15
0
        public void UpdateSummary()
        {
            var context = new Mock<IContextAware>();
            var progressTracker = new Mock<ITrackSteppingProgress>();
            var mockChangeSet = new Mock<IChangeSet>();
            {
                mockChangeSet.Setup(m => m.StoreChanges())
                    .Verifiable();
            }

            var history = new Mock<ITimeline>();
            {
                history.Setup(h => h.RecordHistory())
                    .Returns(mockChangeSet.Object);
            }

            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);
            }

            var proxy = new Mock<IProxyDataset>();
            {
                proxy.Setup(p => p.Summary)
                    .Verifiable();
            }

            var dataset = new DatasetFacade(proxy.Object);
            var model = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            var summary = "a";
            model.Summary = summary;
            proxy.VerifySet(p => p.Summary = It.Is<string>(s => s.Equals(summary)), Times.Once());
            mockChangeSet.Verify(h => h.StoreChanges(), Times.Once());
        }
Beispiel #16
0
        public void OnNameChange()
        {
            var context = new Mock<IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                    .Returns(true);
            }

            var progressTracker = new Mock<ITrackSteppingProgress>();
            var projectLink = new Mock<ILinkToProjects>();

            var proxy = new Mock<IProxyDataset>();

            var dataset = new DatasetFacade(proxy.Object);
            var model = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            var wasRaised = 0;
            var properties = new List<string>();
            model.PropertyChanged += (s, e) =>
            {
                wasRaised++;
                properties.Add(e.PropertyName);
            };

            proxy.Raise(p => p.OnNameChanged += null, new ValueChangedEventArgs<string>("a"));
            Assert.AreEqual(1, wasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List<string>
                    {
                        "Name",
                    }));
        }
Beispiel #17
0
        public void OnSummaryChange()
        {
            var context = new Mock<IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                    .Returns(true);
            }

            var progressTracker = new Mock<ITrackSteppingProgress>();
            var projectLink = new Mock<ILinkToProjects>();

            var proxy = new Mock<IProxyDataset>();

            var dataset = new DatasetFacade(proxy.Object);
            var model = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            var wasRaised = false;
            model.PropertyChanged += (s, e) =>
            {
                wasRaised = true;
                Assert.AreEqual("Summary", e.PropertyName);
            };

            proxy.Raise(p => p.OnSummaryChanged += null, new ValueChangedEventArgs<string>("a"));
            Assert.IsTrue(wasRaised);
        }
Beispiel #18
0
        public void OnProgress()
        {
            var context = new Mock<IContextAware>();
            var progressTracker = new Mock<ITrackSteppingProgress>();
            {
                progressTracker.Setup(p => p.StartTracking())
                    .Verifiable();
                progressTracker.Setup(p => p.StopTracking())
                    .Verifiable();
                progressTracker.Setup(p => p.UpdateProgress(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>()))
                    .Verifiable();
            }

            var projectLink = new Mock<ILinkToProjects>();

            var proxy = new Mock<IProxyDataset>();

            var dataset = new DatasetFacade(proxy.Object);
            var model = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            // Verify here to indicate that we do really need this instance.
            Assert.IsNotNull(model);

            proxy.Raise(p => p.OnProgressOfCurrentAction += null, new ProgressEventArgs(0, "a", false));
            progressTracker.Verify(p => p.StartTracking(), Times.Once());
            progressTracker.Verify(p => p.UpdateProgress(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>()), Times.Once());
            progressTracker.Verify(p => p.StopTracking(), Times.Never());

            proxy.Raise(p => p.OnProgressOfCurrentAction += null, new ProgressEventArgs(50, "b", false));
            progressTracker.Verify(p => p.StartTracking(), Times.Once());
            progressTracker.Verify(p => p.UpdateProgress(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>()), Times.Exactly(2));
            progressTracker.Verify(p => p.StopTracking(), Times.Never());

            proxy.Raise(p => p.OnProgressOfCurrentAction += null, new ProgressEventArgs(100, "c", false));
            progressTracker.Verify(p => p.StartTracking(), Times.Once());
            progressTracker.Verify(p => p.UpdateProgress(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>()), Times.Exactly(3));
            progressTracker.Verify(p => p.StopTracking(), Times.Once());
        }
Beispiel #19
0
        public void OnActivated()
        {
            var context = new Mock<IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                    .Returns(true);
            }

            var progressTracker = new Mock<ITrackSteppingProgress>();
            {
                progressTracker.Setup(p => p.StopTracking())
                    .Verifiable();
            }

            var projectLink = new Mock<ILinkToProjects>();

            var proxy = new Mock<IProxyDataset>();

            var dataset = new DatasetFacade(proxy.Object);
            var model = new DatasetModel(context.Object, progressTracker.Object, projectLink.Object, dataset);

            var propertyChangedWasRaised = 0;
            var properties = new List<string>();
            model.PropertyChanged += (s, e) =>
            {
                propertyChangedWasRaised++;
                properties.Add(e.PropertyName);
            };
            var onLoadedWasRaised = false;
            model.OnActivated += (s, e) =>
            {
                onLoadedWasRaised = true;
            };

            proxy.Raise(p => p.OnActivated += null, EventArgs.Empty);
            Assert.AreEqual(4, propertyChangedWasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List<string>
                    {
                        "IsActivated",
                        "RunsOn",
                        "Progress",
                        "ProgressDescription",
                    }));
            Assert.IsTrue(onLoadedWasRaised);
            progressTracker.Verify(p => p.StopTracking(), Times.Once());
        }