public void TestStaticPropertyCrash() { Product toaster = new Product { Name = "toaster" }; Shop shop = new Shop { Products = { toaster } }; ObjectGraph graph = new ObjectGraph(shop); graph.Collapse(); }
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)); }
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)); }
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)); }
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)); }
/// <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(); }
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)); }