Пример #1
0
 public void TestStaticPropertyCrash()
 {
     Product toaster = new Product { Name = "toaster" };
     Shop shop = new Shop { Products = { toaster } };
     ObjectGraph graph = new ObjectGraph(shop);
     graph.Collapse();
 }
Пример #2
0
        public void TestContainsObject()
        {
            Product toaster = new Product {Name = "toaster"};
            Shop shop = new Shop {Products = {toaster}};

            ObjectGraph graph = new ObjectGraph(shop);
            Assert.IsTrue(graph.ContainsNode(toaster));
        }
Пример #3
0
        public void TestArrayOfStructsException()
        {
            TestGraph.Worker arthur = new TestGraph.Worker { Name = "Arthur", Image = new byte[] { 0, 1, 2, 3, 4, 5 } };
            ObjectGraph graph = new ObjectGraph(arthur) { IncludeReferenceTypes = true };
            IEnumerable<object> objects = graph.Collapse();

            Assert.AreEqual(6, objects.Count(item => item is byte));
        }
Пример #4
0
        public void TestResolveBackReferenceInEnumerable()
        {
            Product toaster = new Product {Name = "toaster"};
            Shop shop = new Shop {Products = {toaster}};

            ObjectGraph graph = new ObjectGraph(shop);
            object backReference = graph.ResolveBackReference(toaster);
            Assert.IsTrue(Object.ReferenceEquals(backReference, shop));
        }
Пример #5
0
        public void TestDoesNotContainObject()
        {
            Product kettle = new Product { Name = "kettle" };
            Product toaster = new Product { Name = "toaster" };
            Shop shop = new Shop {Products = {kettle}};

            ObjectGraph graph = new ObjectGraph(shop);
            Assert.IsFalse(graph.ContainsNode(toaster));
        }
Пример #6
0
        /// <summary>
        /// Re-reads the object graph with updated settings in this class.
        /// </summary>
        public void Refresh()
        {
            this._objectGraph = new ObjectGraph(this.Graph)
                                    {
                                        IgnoredTypes = this.IgnoredTypes,
                                        IgnoreRoot = this.IgnoreRoot,
                                        IncludeStrings = false
                                    };

            List<object> nodes = this._objectGraph.Collapse().ToList();
            this.GraphNodes = nodes;

            this._primaryKeys.Clear();
            nodes.ForEach(node => this._primaryKeys.Add(node));

            this.Types = nodes.Select(node => node.GetType()).Distinct();
        }
Пример #7
-1
        public void TestResolveBackReference()
        {
            Owner owner = new Owner {Name = "Arthur Dent"};
            Shop shop = new Shop {Owner = owner};

            ObjectGraph graph = new ObjectGraph(shop);
            object backReference = graph.ResolveBackReference(owner);
            Assert.IsTrue(Object.ReferenceEquals(backReference, shop));
        }