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

            var project = new Mock <IProject>();
            var facade  = new ProjectFacade(project.Object);

            var model = new ProjectDescriptionModel(context.Object, facade);

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

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

            project.Raise(p => p.OnDatasetCreated += null, EventArgs.Empty);

            Assert.AreEqual(1, propertyChangedWasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List <string>
            {
                "NumberOfDatasets",
            }));
        }
Example #2
0
        public void OnSummaryChange()
        {
            var context = new Mock <IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                .Returns(true);
            }

            var project = new Mock <IProject>();
            var facade  = new ProjectFacade(project.Object);

            var model = new ProjectDescriptionModel(context.Object, facade);

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

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

            var text = "a";

            project.Raise(p => p.OnSummaryChanged += null, new ValueChangedEventArgs <string>(text));

            Assert.AreEqual(1, propertyChangedWasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List <string>
            {
                "Summary",
            }));
        }
        public void OnDatasetCreated()
        {
            var context = new Mock<IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                    .Returns(true);
            }

            var project = new Mock<IProject>();
            var facade = new ProjectFacade(project.Object);

            var model = new ProjectDescriptionModel(context.Object, facade);

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

            project.Raise(p => p.OnDatasetCreated += null, EventArgs.Empty);

            Assert.AreEqual(1, propertyChangedWasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List<string>
                    {
                        "NumberOfDatasets",
                    }));
        }
Example #4
0
        public void Summary()
        {
            var context = new Mock <IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                .Returns(true);
            }

            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.SetupProperty(p => p.Summary, "a")
                .Verify();
                project.Setup(p => p.History)
                .Returns(history.Object);
            }

            var facade = new ProjectFacade(project.Object);

            var model = new ProjectDescriptionModel(context.Object, facade);

            var text = "b";

            model.Summary = text;

            project.VerifySet(p => p.Summary = text, Times.Once());
            mockChangeSet.Verify(h => h.StoreChanges(), Times.Once());
        }
        public void Name()
        {
            var context = new Mock<IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                    .Returns(true);
            }

            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.SetupProperty(p => p.Name, "a")
                    .Verify();
                project.Setup(p => p.History)
                    .Returns(history.Object);
            }

            var facade = new ProjectFacade(project.Object);

            var model = new ProjectDescriptionModel(context.Object, facade);

            var text = "b";
            model.Name = text;

            project.VerifySet(p => p.Name = text, Times.Once());
            mockChangeSet.Verify(h => h.StoreChanges(), Times.Once());
        }
        public void OnSummaryChange()
        {
            var context = new Mock<IContextAware>();
            {
                context.Setup(c => c.IsSynchronized)
                    .Returns(true);
            }

            var project = new Mock<IProject>();
            var facade = new ProjectFacade(project.Object);

            var model = new ProjectDescriptionModel(context.Object, facade);

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

            var text = "a";
            project.Raise(p => p.OnSummaryChanged += null, new ValueChangedEventArgs<string>(text));

            Assert.AreEqual(1, propertyChangedWasRaised);
            Assert.That(
                properties,
                Is.EquivalentTo(
                    new List<string>
                    {
                        "Summary",
                    }));
        }