Exemplo n.º 1
0
        private void AddDatasetToGraph()
        {
            Action <DatasetViewGraph, DatasetFacade, DatasetFacade> action =
                (graph, parent, child) =>
            {
                if (m_VertexMap.ContainsKey(child))
                {
                    return;
                }

                var vertex = new DatasetViewVertex(InternalContext, m_DatasetModelBuilder(child));
                m_VertexMap.Add(child, vertex);

                graph.AddVertex(vertex);
                if (parent != null)
                {
                    Debug.Assert(m_VertexMap.ContainsKey(parent), "Lost the parent!");
                    var parentVertex = m_VertexMap[parent];
                    var edge         = new DatasetViewEdge(parentVertex, vertex);
                    graph.AddEdge(edge);
                }
            };

            IterateOverGraph(action);
            Notify(() => Graph);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 6
0
        private void ReloadProject()
        {
            m_Graph.Clear();

            Action<DatasetViewGraph, DatasetFacade, DatasetFacade> action =
                (graph, parent, child) =>
                {
                    if (m_VertexMap.ContainsKey(child))
                    {
                        return;
                    }

                    var vertex = new DatasetViewVertex(InternalContext, m_DatasetModelBuilder(child));
                    m_VertexMap.Add(child, vertex);
                    graph.AddVertex(vertex);

                    if (parent != null)
                    {
                        Debug.Assert(m_VertexMap.ContainsKey(parent), "Lost the parent!");
                        var parentVertex = m_VertexMap[parent];
                        var edge = new DatasetViewEdge(parentVertex, vertex);
                        graph.AddEdge(edge);
                    }
                };

            IterateOverGraph(action);

            Notify(() => Graph);
        }