public void PrintClassWithDynamicMembersPrintsMembersIfGetDynamicMemberNamesIsImplemented() { // Arrange MockObjectVisitor visitor = CreateObjectVisitor(); dynamic d = new DynamicDictionary(); d.Cycle = d; d.Name = "Foo"; d.Value = null; // Act visitor.Print(d); // Assert Assert.True(visitor.Members.Contains("DynamicDictionary Cycle = Visited")); Assert.True(visitor.Members.Contains("string Name = Foo")); Assert.True(visitor.Members.Contains("Value = null")); }
public void PrintShowsVisitedWhenCircularReferenceIsNameValueCollection() { // Arrange MockObjectVisitor visitor = CreateObjectVisitor(); NameValueCollection nameValues = new NameValueCollection(); nameValues["id"] = "1"; List <NameValueCollection> values = new List <NameValueCollection>(); values.Add(nameValues); values.Add(nameValues); // Act visitor.Print(values); // Assert Assert.True(visitor.Values.Contains("Visited")); Assert.True(visitor.Visited.Contains("Visited " + nameValues.GetHashCode())); }
public void PrintShowsVisitedWhenCircularReferenceInObjectGraph() { // Arrange MockObjectVisitor visitor = CreateObjectVisitor(); PersonNode node = new PersonNode { Person = new Person { Name = "David", Age = 23.3 } }; node.Next = node; // Act visitor.Print(node); // Assert Assert.Contains("string Name = David", visitor.Members); Assert.Contains(String.Format("double Age = {0}", 23.3), visitor.Members); Assert.Contains("PersonNode Next = Visited", visitor.Members); }
public void PrintWritesEnumeratedElementsUntilLimitIsReached() { // Arrange MockObjectVisitor visitor = CreateObjectVisitor(); var enumeration = Enumerable.Range(0, 2000); // Act visitor.Print(enumeration); // Assert for (int i = 0; i <= 2000; i++) { if (i < 1000) { Assert.True(visitor.Values.Contains(i.ToString())); } else { Assert.False(visitor.Values.Contains(i.ToString())); } } Assert.True(visitor.Values.Contains("Limit Exceeded")); }