public void ComparisonEqualsFalseShouldFail() { var comparison1 = new ComparableClass { Property = "Kangaroo", IgnoredProperty = "Whale" }; var comparison2 = new ComparableClass { Property = "Cat", IgnoredProperty = "Ant" }; Verify.ShouldFail(() => comparison1.ShouldBe(comparison2, new ComparableClassComparer(), "Some additional context"), errorWithSource: @"comparison1 should be Shouldly.Tests.TestHelpers.ComparableClass (000000) but was Shouldly.Tests.TestHelpers.ComparableClass (000000) Additional Info: Some additional context", errorWithoutSource: @"Shouldly.Tests.TestHelpers.ComparableClass (000000) should be Shouldly.Tests.TestHelpers.ComparableClass (000000) but was not Additional Info: Some additional context"); }
public void ComparerEqualsShouldFail() { var comparison1 = new ComparableClass { Property = "Elephant", IgnoredProperty = "Duck" }; var comparison2 = new ComparableClass { Property = "Elephant", IgnoredProperty = "Dog" }; Verify.ShouldFail(() => comparison1.ShouldNotBe(comparison2, new ComparableClassComparer(), "Some additional context"), errorWithSource: @"comparison1 should not be Shouldly.Tests.TestHelpers.ComparableClass (000000) but was Additional Info: Some additional context", errorWithoutSource: @"Shouldly.Tests.TestHelpers.ComparableClass (000000) should not be Shouldly.Tests.TestHelpers.ComparableClass (000000) but was Additional Info: Some additional context"); }
public void ComparerNotEqualsShouldFail() { var comparison1 = new ComparableClass { Property = "Snake", IgnoredProperty = "Whale" }; var comparison2 = new[] { new ComparableClass { Property = "Snake", IgnoredProperty = "Platypus" }, new ComparableClass { Property = "Cat", IgnoredProperty = "Ant" } }; Verify.ShouldFail(() => comparison1.ShouldNotBeOneOf(comparison2, new ComparableClassComparer(), "Some additional context"), errorWithSource: @"comparison1 should not be one of [Shouldly.Tests.TestHelpers.ComparableClass (000000), Shouldly.Tests.TestHelpers.ComparableClass (000000)] but was Shouldly.Tests.TestHelpers.ComparableClass (000000) Additional Info: Some additional context", errorWithoutSource: @"Shouldly.Tests.TestHelpers.ComparableClass (000000) should not be one of [Shouldly.Tests.TestHelpers.ComparableClass (000000), Shouldly.Tests.TestHelpers.ComparableClass (000000)] but was Additional Info: Some additional context"); }
public int CompareTo(object obj) { ComparableClass cc = (obj as ComparableClass); if (cc == null) { throw new ArgumentException("wrong type", "obj"); } return(x.CompareTo(cc.x)); }
public void ComparerNotEqualsShouldPass() { var comparison1 = new ComparableClass { Property = "Kangaroo", IgnoredProperty = "Whale" }; var comparison2 = new ComparableClass { Property = "Cat", IgnoredProperty = "Ant" }; comparison1.ShouldNotBe(comparison2, new ComparableClassComparer()); }
public void ComparisonEqualsTrueShouldPass() { var comparison1 = new ComparableClass { Property = "Elephant", IgnoredProperty = "Duck" }; var comparison2 = new ComparableClass { Property = "Elephant", IgnoredProperty = "Dog" }; comparison1.ShouldBe(comparison2, new ComparableClassComparer()); }
public void ComparerEqualsShouldPass() { var comparison1 = new ComparableClass { Property = "Tiger", IgnoredProperty = "Duck" }; var comparison2 = new[] { new ComparableClass { Property = "Elephant", IgnoredProperty = "Dog" }, new ComparableClass { Property = "Lion", IgnoredProperty = "Spider" } }; comparison1.ShouldNotBeOneOf(comparison2, new ComparableClassComparer()); }
public int CompareTo(object obj) { if (obj is ComparableClass) { ComparableClass c = (ComparableClass)obj; return(Value.CompareTo(c.Value)); } else { throw (new Exception("Not valid object")); } }
public int Compare(object x, object y) { if (x is ComparableClass && y is ComparableClass) { ComparableClass _x = (ComparableClass)x; ComparableClass _y = (ComparableClass)y; return(_x.CompareTo(_y)); } else { throw(new Exception("Not valid parameter")); } }
public void ComparerEqualsShouldPass() { var comparison1 = new[] { new ComparableClass { Property = "Elephant", IgnoredProperty = "Duck" }, new ComparableClass { Property = "Lion", IgnoredProperty = "Whale" } }; var comparison2 = new ComparableClass { Property = "Kangaroo", IgnoredProperty = "Dog" }; comparison1.ShouldNotContain(comparison2, new ComparableClassComparer()); }
public void ComparerNotEqualsShouldFail() { var comparison1 = new[] { new ComparableClass { Property = "Snake", IgnoredProperty = "Whale" }, new ComparableClass { Property = "Tiger", IgnoredProperty = "Salmon" } }; var comparison2 = new ComparableClass { Property = "Snake", IgnoredProperty = "Platypus" }; Verify.ShouldFail(() => comparison1.ShouldNotContain(comparison2, new ComparableClassComparer(), "Some additional context"), errorWithSource: @"comparison1 should not contain Shouldly.Tests.TestHelpers.ComparableClass (000000) but was actually [Shouldly.Tests.TestHelpers.ComparableClass (000000), Shouldly.Tests.TestHelpers.ComparableClass (000000)] Additional Info: Some additional context", errorWithoutSource: @"[Shouldly.Tests.TestHelpers.ComparableClass (000000), Shouldly.Tests.TestHelpers.ComparableClass (000000)] should not contain Shouldly.Tests.TestHelpers.ComparableClass (000000) but did Additional Info: Some additional context"); }