You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// arrangevarflag=true;// old assertion:
Assert.True(flag);// new assertion:
flag.Should().BeTrue();
Failure messages
varflag=false;// old assertion:
Assert.True(flag);/* fail message: Assert.True() FailureExpected: TrueActual: False */// new assertion:
flag.Should().BeTrue();/* fail message: Expected flag to be True, but found False. */
scenario: AssertFalse
// arrangevarflag=false;// old assertion:
Assert.False(flag);// new assertion:
flag.Should().BeFalse();
Failure messages
varflag=true;// old assertion:
Assert.False(flag);/* fail message: Assert.False() FailureExpected: FalseActual: True */// new assertion:
flag.Should().BeFalse();/* fail message: Expected flag to be False, but found True. */
scenario: AssertSame
// arrangevarobj1=newobject();varobj2= obj1;// old assertion:
Assert.Same(obj1, obj2);// new assertion:
obj1.Should().BeSameAs(obj2);
Failure messages
objectobj1=6;objectobj2="foo";// old assertion:
Assert.Same(obj1, obj2);/* fail message: Assert.Same() Failure: Values are not the same instanceExpected: 6Actual: "foo" */// new assertion:
obj1.Should().BeSameAs(obj2);/* fail message: Expected obj1 to refer to "foo", but found 6. */
scenario: AssertNotSame
// arrangeobjectobj1=6;objectobj2="foo";// old assertion:
Assert.NotSame(obj1, obj2);// new assertion:
obj1.Should().NotBeSameAs(obj2);
Failure messages
objectobj1="foo";objectobj2="foo";// old assertion:
Assert.NotSame(obj1, obj2);/* fail message: Assert.NotSame() Failure: Values are the same instance */// new assertion:
obj1.Should().NotBeSameAs(obj2);/* fail message: Did not expect obj1 to refer to "foo". */
scenario: AssertDoubleEqual
// arrangedoubleactual=3.14;doubleexpected=3.141;doubletolerance=0.00159;// old assertion:
Assert.Equal(expected, actual, tolerance);// new assertion:
actual.Should().BeApproximately(expected, tolerance);
Failure messages
doubleactual=3.14;doubleexpected=4.2;doubletolerance=0.0001;// old assertion:
Assert.Equal(expected, actual, tolerance);/* fail message: Assert.Equal() Failure: Values are not within tolerance 0.0001Expected: 4.2000000000000002Actual: 3.1400000000000001 */// new assertion:
actual.Should().BeApproximately(expected, tolerance);/* fail message: Expected actual to approximate 4.2 +/- 0.0001, but 3.14 differed by 1.06. */
scenario: AssertDateTimeEqual
// arrangevaractual=new DateTime(2021,1,1);varexpected=new DateTime(2021,1,2);// old assertion:
Assert.Equal(expected, actual, TimeSpan.FromDays(3));// new assertion:
actual.Should().BeCloseTo(expected, TimeSpan.FromDays(3));
Failure messages
varactual=new DateTime(2021,1,1);varexpected=new DateTime(2021,1,2);// old assertion:
Assert.Equal(expected, actual, TimeSpan.FromHours(3));/* fail message: Assert.Equal() Failure: Values differExpected: 2021-01-02T00:00:00.0000000Actual: 2021-01-01T00:00:00.0000000 (difference 1.00:00:00 is larger than 03:00:00) */// new assertion:
actual.Should().BeCloseTo(expected, TimeSpan.FromHours(3));/* fail message: Expected actual to be within 3h from <2021-01-02>, but <2021-01-01> was off by 1d. */
scenario: AssertObjectEqual
// arrangeobjectactual="foo";objectexpected="foo";// old assertion:
Assert.Equal(expected, actual);// new assertion:
actual.Should().Be(expected);
Failure messages
objectactual="foo";objectexpected=6;// old assertion:
Assert.Equal(expected, actual);/* fail message: Assert.Equal() Failure: Values differExpected: 6Actual: foo */// new assertion:
actual.Should().Be(expected);/* fail message: Expected actual to be 6, but found "foo". */
scenario: AssertObjectEqualWithComparer
// arrangeobjectactual="foo";objectexpected="foo";// old assertion:
Assert.Equal(expected, actual,EqualityComparer<object>.Default);// new assertion:
actual.Should().BeEquivalentTo(expected,options => options.Using(EqualityComparer<object>.Default));
Failure messages
objectactual="foo";objectexpected=6;// old assertion:
Assert.Equal(expected, actual,EqualityComparer<object>.Default);/* fail message: Assert.Equal() Failure: Values differExpected: 6Actual: foo */// new assertion:
actual.Should().BeEquivalentTo(expected,options => options.Using(EqualityComparer<object>.Default));/* fail message: Expected actual to be 6, but found "foo".With configuration:- Use declared types and members- Compare enums by value- Compare tuples by their properties- Compare anonymous types by their properties- Compare records by their members- Include non-browsable members- Match member by name (or throw)- Use System.Collections.Generic.ObjectEqualityComparer`1[System.Object] for objects of type System.Object- Be strict about the order of items in byte arrays- Without automatic conversion. */
scenario: AssertObjectNotEqual
// arrangeobjectactual="foo";objectexpected=6;// old assertion:
Assert.NotEqual(expected, actual);// new assertion:
actual.Should().NotBe(expected);
Failure messages
objectactual="foo";objectexpected="foo";// old assertion:
Assert.NotEqual(expected, actual);/* fail message: Assert.NotEqual() Failure: Strings are equalExpected: Not "foo"Actual: "foo" */// new assertion:
actual.Should().NotBe(expected);/* fail message: Did not expect actual to be equal to "foo". */
scenario: AssertObjectNotEqualWithComparer
// arrangeobjectactual="foo";objectexpected=6;// old assertion:
Assert.NotEqual(expected, actual,EqualityComparer<object>.Default);// new assertion:
actual.Should().NotBeEquivalentTo(expected,options => options.Using(EqualityComparer<object>.Default));
Failure messages
objectactual="foo";objectexpected="foo";// old assertion:
Assert.NotEqual(expected, actual,EqualityComparer<object>.Default);/* fail message: Assert.NotEqual() Failure: Strings are equalExpected: Not "foo"Actual: "foo" */// new assertion:
actual.Should().NotBeEquivalentTo(expected,options => options.Using(EqualityComparer<object>.Default));/* fail message: Expected actual not to be equivalent to "foo", but they are. */
scenario: AssertStrictEqual
// arrangeobjectactual="foo";objectexpected="foo";// old assertion:
Assert.StrictEqual(expected, actual);// new assertion:
actual.Should().Be(expected);
Failure messages
objectactual="foo";objectexpected=6;// old assertion:
Assert.StrictEqual(expected, actual);/* fail message: Assert.StrictEqual() Failure: Values differExpected: 6Actual: "foo" */// new assertion:
actual.Should().Be(expected);/* fail message: Expected actual to be 6, but found "foo". */
scenario: AssertNotStrictEqual
// arrangeobjectactual="foo";objectexpected=6;// old assertion:
Assert.NotStrictEqual(expected, actual);// new assertion:
actual.Should().NotBe(expected);
Failure messages
objectactual="foo";objectexpected="foo";// old assertion:
Assert.NotStrictEqual(expected, actual);/* fail message: Assert.NotStrictEqual() Failure: Values are equalExpected: Not "foo"Actual: "foo" */// new assertion:
actual.Should().NotBe(expected);/* fail message: Did not expect actual to be equal to "foo". */