public void AddChild()
        {
            DatasetCreationInformation creationInformation = null;

            var storage = new Mock <IPersistenceInformation>();
            var child   = CreateMockDataset();
            var dataset = new Mock <IProxyDataset>();
            {
                dataset.Setup(d => d.StoredAt)
                .Returns(storage.Object);

                dataset.Setup(d => d.CreateNewChild(It.IsAny <DatasetCreationInformation>()))
                .Callback <DatasetCreationInformation>(d => creationInformation = d)
                .Returns(child);
            }

            var facade      = new ScriptBackEndDatasetFacade(new DatasetFacade(dataset.Object));
            var childFacade = facade.AddChild();

            Assert.AreEqual(new ScriptBackEndDatasetFacade(new DatasetFacade(child)), childFacade);
            Assert.IsFalse(creationInformation.CanBeAdopted);
            Assert.IsTrue(creationInformation.CanBecomeParent);
            Assert.IsTrue(creationInformation.CanBeCopied);
            Assert.IsTrue(creationInformation.CanBeDeleted);
            Assert.AreEqual(DatasetCreator.User, creationInformation.CreatedOnRequestOf);
            Assert.AreEqual(storage.Object, creationInformation.LoadFrom);
        }
        public void DeleteWithUndeletableDataset()
        {
            var dataset = new Mock <IProxyDataset>();
            {
                dataset.Setup(d => d.CanBeDeleted)
                .Returns(false);
            }

            var facade = new ScriptBackEndDatasetFacade(new DatasetFacade(dataset.Object));

            Assert.Throws <CannotDeleteDatasetException>(() => facade.Delete());
        }
        public void OnDeactivated()
        {
            var dataset = new Mock <IProxyDataset>();
            var facade  = new ScriptBackEndDatasetFacade(new DatasetFacade(dataset.Object));

            bool wasUnloaded = false;

            facade.OnDeactivated += (s, e) => wasUnloaded = true;

            dataset.Raise(d => d.OnDeactivated += null, EventArgs.Empty);
            Assert.IsTrue(wasUnloaded);
        }
        public void OnSummaryUpdate()
        {
            var dataset = new Mock <IProxyDataset>();
            var facade  = new ScriptBackEndDatasetFacade(new DatasetFacade(dataset.Object));

            bool eventRaised = false;

            facade.OnSummaryChanged += (s, e) => { eventRaised = true; };

            dataset.Raise(d => d.OnSummaryChanged += null, new ValueChangedEventArgs <string>("newSummary"));
            Assert.IsTrue(eventRaised);
        }
        public void Summary()
        {
            var dataset = new Mock <IProxyDataset>();
            {
                dataset.SetupProperty(p => p.Summary);
            }

            var facade = new ScriptBackEndDatasetFacade(new DatasetFacade(dataset.Object));

            var summary = "text";

            facade.Summary = summary;
            Assert.AreEqual(summary, facade.Summary);
        }
        public void Name()
        {
            var dataset = new Mock <IProxyDataset>();
            {
                dataset.SetupProperty(p => p.Name);
            }

            var facade = new ScriptBackEndDatasetFacade(new DatasetFacade(dataset.Object));

            var name = "name";

            facade.Name = name;
            Assert.AreEqual(name, facade.Name);
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptFrontEndDatasetFacade"/> class.
        /// </summary>
        /// <param name="facade">The object that stores information about the dataset.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="facade"/> is <see langword="null" />.
        /// </exception>
        public ScriptFrontEndDatasetFacade(ScriptBackEndDatasetFacade facade)
        {
            {
                Enforce.Argument(() => facade);
            }

            m_Dataset = facade;
            m_Dataset.OnInvalidate += (s, e) => RaiseOnInvalidate();
            m_Dataset.OnProgressOfCurrentAction += (s, e) => RaiseOnProgressOfCurrentAction(e.Progress, e.Description, e.HasErrors);
            m_Dataset.OnActivated      += (s, e) => RaiseOnActivated();
            m_Dataset.OnDeactivated    += (s, e) => RaiseOnDeactivated();
            m_Dataset.OnNameChanged    += (s, e) => RaiseOnNameChanged();
            m_Dataset.OnSummaryChanged += (s, e) => RaiseOnSummaryChanged();
        }
        public void ChildrenOf()
        {
            var child   = CreateMockDataset();
            var dataset = new Mock <IProxyDataset>();
            {
                dataset.Setup(d => d.Children())
                .Returns(new List <IProxyDataset> {
                    child
                });
            }

            var facade   = new ScriptBackEndDatasetFacade(new DatasetFacade(dataset.Object));
            var children = facade.Children();

            Assert.AreEqual(1, children.Count());
            Assert.AreEqual(new ScriptBackEndDatasetFacade(new DatasetFacade(child)), children.First());
        }
        public void Delete()
        {
            var dataset = new Mock <IProxyDataset>();
            {
                dataset.Setup(d => d.CanBeDeleted)
                .Returns(true);

                dataset.Setup(d => d.Delete())
                .Verifiable();
            }

            var facade = new ScriptBackEndDatasetFacade(new DatasetFacade(dataset.Object));

            facade.Delete();

            dataset.Verify(d => d.Delete(), Times.Once());
        }