public void Result_Should_Be_True_With_Or_And() { var source = EqualityTestObject.Default(); Assert.True(source.If().Not.Null.Or.In(GetEqualityObjectCollectionWithDefault(true)).And.Not.In(GetEqualityObjectCollectionWithDefault(false)).Result); Assert.True(source.If().Null.Or.In(GetEqualityObjectCollectionWithDefault(true)).And.Not.In(GetEqualityObjectCollectionWithDefault(false)).Result); }
public void Object_Comparison_Equality_TypeInsensitiveDifferentTypes() { var item1 = new { Property1 = "Value1", Property2 = "Value2", Property3 = new { NestedObject = new { SomeInternalProperty = "Value" }, NestedProperty = "NestedValue" } }; var item2 = new EqualityTestObject { Property1 = "Value1", Property2 = "Value2", Property3 = new EqualityTestObject2() { NestedProperty = "NestedValue", NestedObject = new EqualityTestObject3 { SomeInternalProperty = "Value" } } }; Assert.IsTrue(_.Object.AreEquivalent(item2, item1)); Assert.IsTrue(_.Object.AreEquivalent(item1, item2)); }
public void Object_Comparison_Equality_TypeInsensitiveSameType() { var item1 = new EqualityTestObject { Property1 = "Value1", Property2 = "Value2", Property3 = new EqualityTestObject2 { NestedProperty = "NestedValue", NestedObject = new EqualityTestObject3 { SomeInternalProperty = "Value" } } }; var item2 = new EqualityTestObject { Property1 = "Value1", Property2 = "Value2", Property3 = new EqualityTestObject2() { NestedProperty = "NestedValue", NestedObject = new EqualityTestObject3 { SomeInternalProperty = "Value" } } }; Assert.IsTrue(_.Object.AreEquivalent(item2, item1)); Assert.IsTrue(_.Object.AreEquivalent(item1, item2)); }
public void RefreshObject_EqualityTest() { var obj1 = new EqualityTestObject() { Name = "Bob", Age = 1 }; var obj2 = new EqualityTestObject() { Name = "Bob", Age = 2 };; string root = "root"; var tree = new TreeView <object> (); tree.TreeBuilder = new DelegateTreeBuilder <object> ((s) => ReferenceEquals(s, root) ? new object [] { obj1 } : null); tree.AddObject(root); // Tree is not expanded so the root has no children yet Assert.Empty(tree.GetChildren(root)); tree.Expand(root); // now that the tree is expanded we should get our child returned Assert.Equal(1, tree.GetChildren(root).Count(child => ReferenceEquals(obj1, child))); // change the getter to return an Equal object (but not the same reference - obj2) tree.TreeBuilder = new DelegateTreeBuilder <object> ((s) => ReferenceEquals(s, root) ? new object [] { obj2 } : null); // tree has cached the knowledge of what children the root has so won't know about the change (we still get obj1) Assert.Equal(1, tree.GetChildren(root).Count(child => ReferenceEquals(obj1, child))); // now that we refresh the root we should get the new child reference (obj2) tree.RefreshObject(root); Assert.Equal(1, tree.GetChildren(root).Count(child => ReferenceEquals(obj2, child))); }
private static IEnumerable <EqualityTestObject> GetEqualityObjectCollectionWithDefault(bool withDefault) => new[] { EqualityTestObject.New(), EqualityTestObject.New("str", 5), withDefault ? EqualityTestObject.Default() : null };
private static IChainableCondition <EqualityTestObject> EqualityTestObjectInCollectionCondition() => EqualityTestObject.Default().If();
public void Object_Comparison_Equality_TypeSensitiveDifferentTypes() { var item1 = new { Property1 = "Value1", Property2 = "Value2", Property3 = new { NestedObject = new { SomeInternalProperty = "Value" }, NestedProperty = "NestedValue" } }; var item2 = new EqualityTestObject { Property1 = "Value1", Property2 = "Value2", Property3 = new EqualityTestObject2() { NestedProperty = "NestedValue", NestedObject = new EqualityTestObject3 { SomeInternalProperty = "Value" } } }; Assert.IsFalse(_.Object.AreEquivalent(item2, item1, true)); Assert.IsFalse(_.Object.AreEquivalent(item1, item2, true)); }