public void Calling_Compare_on_ignored_types_returns_Inconclusive() { var value1 = default(AlwaysEqual); var value2 = default(object); "Given a DefaultComparison".x(() => SUT = new DefaultComparison() ); "And the type is skipped".x(() => SUT.Skip <AlwaysEqual>() ); "And 2 objects to compare".x(() => { value1 = new AlwaysEqual(); value2 = new AlwaysEqual(); }); "When calling Compare".x(() => (Result, _) = SUT.Compare(null, value1, value2) ); "The result should be Inconclusive".x(() => Result.ShouldBe(ComparisonResult.Inconclusive) ); }
public void Comparing_value_types_returns_Pass_or_Fail(object value1, object value2, bool expected) { "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And a Comparison context object" .And(() => Context = new ComparisonContext("Root")); "When calling Compare" .When(() => Result = SUT.Compare(Context, value1, value2)); "The result should be Pass or Fail" .Then(() => Result.ShouldBe(expected ? ComparisonResult.Pass : ComparisonResult.Fail)); if (!expected) { var expectedDifference = new Difference { Breadcrumb = "Root", Value1 = value1, Value2 = value2 }; "And it should add a difference" .And(() => Context.Differences[0].ShouldBe(expectedDifference)); } }
public void Comparing_different_types_results_in_implicit_cast() { var object1 = default(CastSpy); var object2 = default(string); "Given a DefaultComparison".x(() => SUT = new DefaultComparison() ); "And 2 objects to compare".x(() => { object1 = new CastSpy("abc"); object2 = "abc"; }); "And a Comparison context object".x(() => Context = new ComparisonContext() ); "When calling Compare".x(() => (Result, _) = SUT.Compare(Context, object1, object2) ); "Then it should call the implicit operator".x(() => object1.Called.ShouldBe(true) ); "And it should return Pass".x(() => Result.ShouldBe(ComparisonResult.Pass) ); }
public void Comparing_objects_calls_Equals_method() { var object1 = default(EqualsSpy); var object2 = default(EqualsSpy); "Given a DefaultComparison".x(() => SUT = new DefaultComparison() ); "And 2 objects to compare".x(() => { object1 = new EqualsSpy(); object2 = new EqualsSpy(); }); "And a Comparison context object".x(() => Context = new ComparisonContext() ); "When calling Compare".x(() => (Result, _) = SUT.Compare(Context, object1, object2) ); "Then it should call Equals".x(() => object1.Calls[0].ShouldBeSameAs(object2) ); }
public void Comparing_value_types_returns_Pass_or_Fail(object value1, object value2, ComparisonResult expectedResult) { var newContext = default(IComparisonContext); "Given a DefaultComparison".x(() => SUT = new DefaultComparison() ); "And a Comparison context object".x(() => Context = new ComparisonContext("Root") ); "When calling Compare".x(() => (Result, newContext) = SUT.Compare(Context, value1, value2) ); "The result should be Pass or Fail".x(() => Result.ShouldBe(expectedResult) ); if (expectedResult == ComparisonResult.Fail) { var expectedDifference = new BasicDifference( breadcrumb: "Root", value1: value1, value2: value2, childProperty: null ); "And it should add a difference".x(() => newContext.Differences[0].ShouldDeepEqual(expectedDifference) ); } }
public void Comparing_incompatible_types_returns_Inconclusive() { var object1 = default(object); var object2 = default(int); "Given a DefaultComparison".x(() => SUT = new DefaultComparison() ); "And 2 objects to compare".x(() => { object1 = new object(); object2 = 123; }); "And a Comparison context object".x(() => Context = new ComparisonContext() ); "When calling Compare".x(() => (Result, _) = SUT.Compare(Context, object1, object2) ); "Then it should return Inconclusive".x(() => Result.ShouldBe(ComparisonResult.Inconclusive) ); }
public void Comparing_different_types_results_in_call_to_IConvertible() { var object1 = default(StringConvertibleSpy); var object2 = default(string); "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And 2 objects to compare" .And(() => { object1 = new StringConvertibleSpy("abc"); object2 = "abc"; }); "And a Comparison context object" .And(() => Context = new ComparisonContext()); "When calling Compare" .When(() => Result = SUT.Compare(Context, object1, object2)); "Then it should call IConvertible.ToString" .Then(() => object1.Called.ShouldBe(true)); "And it should return Pass" .And(() => Result.ShouldBe(ComparisonResult.Pass)); }
public void Delegates_WithCustomComparison() { var c = new DefaultComparison(); syntax.WithCustomComparison(c); builder.Verify(x => x.WithCustomComparison(c), Times.Once()); }
public void Creating_a_DefaultComparison() { "When creating a DefaultComparison" .x(() => SUT = new DefaultComparison()); "Then is should implement IComparison" .x(() => SUT.ShouldBeAssignableTo <IComparison>()); }
public void Creating_a_DefaultComparison() { "When creating a DefaultComparison" .When(() => SUT = new DefaultComparison()); "Then is should implement IComparison" .Then(() => SUT.ShouldBeTypeOf <IComparison>()); }
public void Can_compare_any_type(Type type1, Type type2) { "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "When calling CanCompare" .When(() => CanCompareResult = SUT.CanCompare(type1, type2)); "Then the result should be true" .Then(() => CanCompareResult.ShouldBe(true)); }
public void Can_not_compare_types_that_are_different(Type type1, Type type2) { "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "When calling CanCompare" .When(() => CanCompareResult = SUT.CanCompare(type1, type2)); "Then the result should be true" .Then(() => CanCompareResult.ShouldBe(false)); }
public void Can_compare_types_that_are_equal(Type type) { "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "When calling CanCompare" .When(() => CanCompareResult = SUT.CanCompare(type, type)); "Then the result should be true" .Then(() => CanCompareResult.ShouldBe(true)); }
public void Calling_CanCompare_compare_on_ignored_types(Type type1, Type type2) { "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And the type is skipped" .And(() => SUT.Skip<AlwaysEqual>()); "When calling Compare" .When(() => CanCompareResult = SUT.CanCompare(type1, type2)); "The result should be Pass or Fail" .Then(() => CanCompareResult.ShouldBe(false)); }
public void Calling_CanCompare_on_ignored_types_returns_false(Type type1, Type type2) { "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And the type is skipped" .And(() => SUT.Skip <AlwaysEqual>()); "When calling Compare" .When(() => CanCompareResult = SUT.CanCompare(type1, type2)); "The result should be false" .Then(() => CanCompareResult.ShouldBe(false)); }
public void Comparing_object_types_returns_Pass_or_Inconclusive(bool expected) { var value1 = default(EqualsSpy); var value2 = default(EqualsSpy); "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And 2 objects to compare" .And(() => { value1 = new EqualsSpy(expected); value2 = new EqualsSpy(expected); }); "When calling Compare" .When(() => Result = SUT.Compare(null, value1, value2)); "The result should be Pass or Fail" .Then(() => Result.ShouldBe(expected ? ComparisonResult.Pass : ComparisonResult.Inconclusive)); }
public void Calling_Compare_compare_on_ignored_types() { var value1 = default (AlwaysEqual); var value2 = default (object); "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And the type is skipped" .And(() => SUT.Skip<AlwaysEqual>()); "And 2 objects to compare" .And(() => { value1 = new AlwaysEqual(); value2 = new AlwaysEqual(); }); "When calling Compare" .When(() => Result = SUT.Compare(null, value1, value2)); "The result should be Pass or Fail" .Then(() => Result.ShouldBe(ComparisonResult.Inconclusive)); }
public void Creating_a_DefaultComparison() { "When creating a DefaultComparison" .When(() => SUT = new DefaultComparison()); "Then is should implement IComparison" .Then(() => SUT.ShouldBeTypeOf<IComparison>()); }
public void Comparing_object_types_returns_Pass_or_Inconclusive(bool expected) { var value1 = default (EqualsSpy); var value2 = default (EqualsSpy); "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And 2 objects to compare" .And(() => { value1 = new EqualsSpy(expected); value2 = new EqualsSpy(expected); }); "When calling Compare" .When(() => Result = SUT.Compare(null, value1, value2)); "The result should be Pass or Fail" .Then(() => Result.ShouldBe(expected ? ComparisonResult.Pass : ComparisonResult.Inconclusive)); }
public void Comparing_objects_calls_Equals_method() { var object1 = default (EqualsSpy); var object2 = default (EqualsSpy); "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And 2 objects to compare" .And(() => { object1 = new EqualsSpy(); object2 = new EqualsSpy(); }); "And a Comparison context object" .And(() => Context = new ComparisonContext()); "When calling Compare" .When(() => Result = SUT.Compare(Context, object1, object2)); "Then it should call Equals" .Then(() => object1.Calls[0].ShouldBeSameAs(object2)); }
public void ReturnsFalse_WhenUnequalStrings(string val1, string val2) { var comparison = new DefaultComparison(); RunComparer(comparison, val1, val2, false); }
public void ReturnsTrue_WhenEqualStrings(string val1, string val2) { var comparison = new DefaultComparison(); RunComparer(comparison, val1, val2, true); }
public void Comparing_incompatible_types_returns_Inconclusive() { var object1 = default (object); var object2 = default (int); "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And 2 objects to compare" .And(() => { object1 = new object(); object2 = 123; }); "And a Comparison context object" .And(() => Context = new ComparisonContext()); "When calling Compare" .When(() => Result = SUT.Compare(Context, object1, object2)); "Then it should return Inconclusive" .Then(() => Result.ShouldBe(ComparisonResult.Inconclusive)); }
public void Comparing_different_types_results_in_implicit_cast() { var object1 = default (CastSpy); var object2 = default (string); "Given a DefaultComparison" .Given(() => SUT = new DefaultComparison()); "And 2 objects to compare" .And(() => { object1 = new CastSpy("abc"); object2 = "abc"; }); "And a Comparison context object" .And(() => Context = new ComparisonContext()); "When calling Compare" .When(() => Result = SUT.Compare(Context, object1, object2)); "Then it should call the implicit operator" .Then(() => object1.Called.ShouldBe(true)); "And it should return Pass" .And(() => Result.ShouldBe(ComparisonResult.Pass)); }