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.IsTrue(flag);// new assertion:
flag.Should().BeTrue();
Failure messages
varflag=false;// old assertion:
Assert.IsTrue(flag);/* fail message: Assert.IsTrue failed. */// new assertion:
flag.Should().BeTrue();/* fail message: Expected flag to be True, but found False. */
scenario: AssertIsFalse
// arrangevarflag=false;// old assertion:
Assert.IsFalse(flag);// new assertion:
flag.Should().BeFalse();
Failure messages
varflag=true;// old assertion:
Assert.IsFalse(flag);/* fail message: Assert.IsFalse failed. */// new assertion:
flag.Should().BeFalse();/* fail message: Expected flag to be False, but found True. */
scenario: AssertIsNull
// arrangeobjectobj=null;// old assertion:
Assert.IsNull(obj);// new assertion:
obj.Should().BeNull();
Failure messages
varobj="foo";// old assertion:
Assert.IsNull(obj);/* fail message: Assert.IsNull failed. */// new assertion:
obj.Should().BeNull();/* fail message: Expected obj to be <null>, but found "foo". */
scenario: AssertIsNotNull
// arrangevarobj=newobject();// old assertion:
Assert.IsNotNull(obj);// new assertion:
obj.Should().NotBeNull();
Failure messages
objectobj=null;// old assertion:
Assert.IsNotNull(obj);/* fail message: Assert.IsNotNull failed. */// new assertion:
obj.Should().NotBeNull();/* fail message: Expected obj not to be <null>. */
scenario: AssertIsInstanceOfType
// arrangevarobj=newList<object>();// old assertion:
Assert.IsInstanceOfType(obj,typeof(List<object>));
Assert.IsInstanceOfType<List<object>>(obj);// new assertion:
obj.Should().BeOfType<List<object>>();
Failure messages
varobj=newList<int>();// old assertion:
Assert.IsInstanceOfType(obj,typeof(List<object>));/* fail message: Assert.IsInstanceOfType failed. Expected type:<System.Collections.Generic.List`1[System.Object]>. Actual type:<System.Collections.Generic.List`1[System.Int32]>. */
Assert.IsInstanceOfType<List<object>>(obj);/* fail message: Assert.IsInstanceOfType failed. Expected type:<System.Collections.Generic.List`1[System.Object]>. Actual type:<System.Collections.Generic.List`1[System.Int32]>. */// new assertion:
obj.Should().BeOfType<List<object>>();/* fail message: Expected type to be System.Collections.Generic.List`1[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], but found System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]. */
scenario: AssertIsNotInstanceOfType
// arrangevarobj=newList<int>();// old assertion:
Assert.IsNotInstanceOfType(obj,typeof(List<object>));
Assert.IsNotInstanceOfType<List<object>>(obj);// new assertion:
obj.Should().NotBeOfType<List<object>>();
Failure messages
varobj=newList<object>();// old assertion:
Assert.IsNotInstanceOfType(obj,typeof(List<object>));/* fail message: Assert.IsNotInstanceOfType failed. Wrong Type:<System.Collections.Generic.List`1[System.Object]>. Actual type:<System.Collections.Generic.List`1[System.Object]>. */
Assert.IsNotInstanceOfType<List<object>>(obj);/* fail message: Assert.IsNotInstanceOfType failed. Wrong Type:<System.Collections.Generic.List`1[System.Object]>. Actual type:<System.Collections.Generic.List`1[System.Object]>. */// new assertion:
obj.Should().NotBeOfType<List<object>>();/* fail message: Expected type not to be [System.Collections.Generic.List`1[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e], but it is. */
scenario: AssertObjectAreEqual
// arrangeobjectobj1="foo";objectobj2="foo";// old assertion:
Assert.AreEqual(obj2, obj1);// new assertion:
obj1.Should().Be(obj2);
Failure messages
objectobj1="foo";objectobj2=42;// old assertion:
Assert.AreEqual(obj2, obj1);/* fail message: Assert.AreEqual failed. Expected:<42 (System.Int32)>. Actual:<foo (System.String)>. */// new assertion:
obj1.Should().Be(obj2);/* fail message: Expected obj1 to be 42, but found "foo". */
scenario: AssertObjectAreEqual_LiteralValue
// arrangeobjectobj1="foo";// old assertion:
Assert.AreEqual(obj1,"foo");// new assertion:
obj1.Should().Be("foo");
Failure messages
objectobj1="foo";// old assertion:
Assert.AreEqual(obj1,"bar");/* fail message: Assert.AreEqual failed. Expected:<foo>. Actual:<bar>. */// new assertion:
obj1.Should().Be("bar");/* fail message: Expected obj1 to be "bar", but found "foo". */
scenario: AssertOptionalIntegerAreEqual
// arrangeint?number1=42;int?number2=42;// old assertion:
Assert.AreEqual(number2, number1);// new assertion:
number1.Should().Be(number2);
Failure messages
int?number1=42;int?number2=6;// old assertion:
Assert.AreEqual(number2, number1);/* fail message: Assert.AreEqual failed. Expected:<6>. Actual:<42>. */// new assertion:
number1.Should().Be(number2);/* fail message: Expected number1 to be 6, but found 42 (difference of 36). */
scenario: AssertOptionalIntegerAndNullAreEqual
// arrangeint?number=null;// old assertion:
Assert.AreEqual(number,null);
Assert.AreEqual(null, number);// new assertion:
number.Should().BeNull();
Failure messages
int?number=42;// old assertion:
Assert.AreEqual(number,null);/* fail message: Assert.AreEqual failed. Expected:<42>. Actual:<(null)>. */
Assert.AreEqual(null, number);/* fail message: Assert.AreEqual failed. Expected:<(null)>. Actual:<42>. */// new assertion:
number.Should().BeNull();/* fail message: Did not expect a value, but found 42. */
scenario: AssertDoubleAreEqual
// arrangedoublenumber1=3.14;doublenumber2=3.141;doubledelta=0.00159;// old assertion:
Assert.AreEqual(number2, number1, delta);// new assertion:
number1.Should().BeApproximately(number2, delta);
Failure messages
doublenumber1=3.14;doublenumber2=4.2;doubledelta=0.0001;// old assertion:
Assert.AreEqual(number2, number1, delta);/* fail message: Assert.AreEqual failed. Expected a difference no greater than <0.0001> between expected value <4.2> and actual value <3.14>. */// new assertion:
number1.Should().BeApproximately(number2, delta);/* fail message: Expected number1 to approximate 4.2 +/- 0.0001, but 3.14 differed by 1.06. */
scenario: AssertFloatAreEqual
// arrangefloatnumber1=3.14f;floatnumber2=3.141f;floatdelta=0.00159f;// old assertion:
Assert.AreEqual(number2, number1, delta);// new assertion:
number1.Should().BeApproximately(number2, delta);
Failure messages
floatnumber1=3.14f;floatnumber2=4.2f;floatdelta=0.0001f;// old assertion:
Assert.AreEqual(number2, number1, delta);/* fail message: Assert.AreEqual failed. Expected a difference no greater than <0.0001> between expected value <4.2> and actual value <3.14>. */// new assertion:
number1.Should().BeApproximately(number2, delta);/* fail message: Expected number1 to approximate 4.2F +/- 0.0001F, but 3.14F differed by 1.0599997F. */
scenario: AssertStringAreEqual_CaseSensitive
// arrangestringstr1="foo";stringstr2="foo";// old assertion:
Assert.AreEqual(str2, str1);
Assert.AreEqual(str2, str1, ignoreCase:false);
Assert.AreEqual(str2, str1, ignoreCase:false, culture: CultureInfo.CurrentCulture);// new assertion:
str1.Should().Be(str2);
Failure messages
stringstr1="foo";stringstr2="FoO";// old assertion:
Assert.AreEqual(str2, str1);/* fail message: Assert.AreEqual failed. Expected:<FoO>. Actual:<foo>. */
Assert.AreEqual(str2, str1, ignoreCase:false);/* fail message: Assert.AreEqual failed. Expected:<FoO>. Actual:<foo>. */
Assert.AreEqual(str2, str1, ignoreCase:false, culture: CultureInfo.CurrentCulture);/* fail message: Assert.AreEqual failed. Expected:<FoO>. Actual:<foo>. */// new assertion:
str1.Should().Be(str2);/* fail message: Expected str1 to be "FoO", but "foo" differs near "foo" (index 0). */
scenario: AssertStringAreEqual_IgnoreCase
// arrangestringstr1="foo";stringstr2="FoO";// old assertion:
Assert.AreEqual(str2, str1, ignoreCase:true);
Assert.AreEqual(str2, str1, ignoreCase:true, culture: CultureInfo.CurrentCulture);// new assertion:
str1.Should().BeEquivalentTo(str2);
Failure messages
stringstr1="foo";stringstr2="bar";// old assertion:
Assert.AreEqual(str2, str1, ignoreCase:true);/* fail message: Assert.AreEqual failed. Expected:<bar>. Actual:<foo>. */
Assert.AreEqual(str2, str1, ignoreCase:true, culture: CultureInfo.CurrentCulture);/* fail message: Assert.AreEqual failed. Expected:<bar>. Actual:<foo>. */// new assertion:
str1.Should().BeEquivalentTo(str2);/* fail message: Expected str1 to be equivalent to "bar", but "foo" differs near "foo" (index 0). */
scenario: AssertObjectAreNotEqual
// arrangeobjectobj1="foo";objectobj2="bar";// old assertion:
Assert.AreNotEqual(obj2, obj1);// new assertion:
obj1.Should().NotBe(obj2);
Failure messages
objectobj1="foo";objectobj2="foo";// old assertion:
Assert.AreNotEqual(obj2, obj1);/* fail message: Assert.AreNotEqual failed. Expected any value except:<foo>. Actual:<foo>. */// new assertion:
obj1.Should().NotBe(obj2);/* fail message: Did not expect obj1 to be equal to "foo". */
scenario: AssertOptionalIntegerAreNotEqual
// arrangeint?number1=42;int?number2=6;// old assertion:
Assert.AreNotEqual(number2, number1);// new assertion:
number1.Should().NotBe(number2);
Failure messages
int?number1=42;int?number2=42;// old assertion:
Assert.AreNotEqual(number2, number1);/* fail message: Assert.AreNotEqual failed. Expected any value except:<42>. Actual:<42>. */// new assertion:
number1.Should().NotBe(number2);/* fail message: Did not expect number1 to be 42. */
scenario: AssertDoubleAreNotEqual
// arrangedoublenumber1=3.14;doublenumber2=4.2;doubledelta=0.0001;// old assertion:
Assert.AreNotEqual(number2, number1, delta);// new assertion:
number1.Should().NotBeApproximately(number2, delta);
Failure messages
doublenumber1=3.14;doublenumber2=3.141;doubledelta=0.00159;// old assertion:
Assert.AreNotEqual(number2, number1, delta);/* fail message: Assert.AreNotEqual failed. Expected a difference greater than <0.00159> between expected value <3.141> and actual value <3.14>. */// new assertion:
number1.Should().NotBeApproximately(number2, delta);/* fail message: Expected number1 to not approximate 3.141 +/- 0.00159, but 3.14 only differed by 0.0009999999999998899. */
scenario: AssertFloatAreNotEqual
// arrangefloatnumber1=3.14f;floatnumber2=4.2f;floatdelta=0.0001f;// old assertion:
Assert.AreNotEqual(number2, number1, delta);// new assertion:
number1.Should().NotBeApproximately(number2, delta);
Failure messages
floatnumber1=3.14f;floatnumber2=3.141f;floatdelta=0.00159f;// old assertion:
Assert.AreNotEqual(number2, number1, delta);/* fail message: Assert.AreNotEqual failed. Expected a difference greater than <0.00159> between expected value <3.141> and actual value <3.14>. */// new assertion:
number1.Should().NotBeApproximately(number2, delta);/* fail message: Expected number1 to not approximate 3.141F +/- 0.00159F, but 3.14F only differed by 0.0009999275F. */
scenario: AssertStringAreNotEqual_CaseSensitive
// arrangestringstr1="foo";stringstr2="bar";// old assertion:
Assert.AreNotEqual(str2, str1);
Assert.AreNotEqual(str2, str1, ignoreCase:false);
Assert.AreNotEqual(str2, str1, ignoreCase:false, culture: CultureInfo.CurrentCulture);// new assertion:
str1.Should().NotBe(str2);
Failure messages
stringstr1="foo";stringstr2="foo";// old assertion:
Assert.AreNotEqual(str2, str1);/* fail message: Assert.AreNotEqual failed. Expected any value except:<foo>. Actual:<foo>. */
Assert.AreNotEqual(str2, str1, ignoreCase:false);/* fail message: Assert.AreNotEqual failed. Expected any value except:<foo>. Actual:<foo>. */
Assert.AreNotEqual(str2, str1, ignoreCase:false, culture: CultureInfo.CurrentCulture);/* fail message: Assert.AreNotEqual failed. Expected any value except:<foo>. Actual:<foo>. */// new assertion:
str1.Should().NotBe(str2);/* fail message: Expected str1 not to be "foo". */
scenario: AssertStringAreNotEqual_IgnoreCase
// arrangestringstr1="foo";stringstr2="bar";// old assertion:
Assert.AreNotEqual(str2, str1, ignoreCase:true);
Assert.AreNotEqual(str2, str1, ignoreCase:true, culture: CultureInfo.CurrentCulture);// new assertion:
str1.Should().NotBeEquivalentTo(str2);
Failure messages
stringstr1="foo";stringstr2="FoO";// old assertion:
Assert.AreNotEqual(str2, str1, ignoreCase:true);/* fail message: Assert.AreNotEqual failed. Expected any value except:<FoO>. Actual:<foo>. */
Assert.AreNotEqual(str2, str1, ignoreCase:true, culture: CultureInfo.CurrentCulture);/* fail message: Assert.AreNotEqual failed. Expected any value except:<FoO>. Actual:<foo>. */// new assertion:
str1.Should().NotBeEquivalentTo(str2);/* fail message: Expected str1 not to be equivalent to "FoO", but they are. */
scenario: AssertAreSame
// arrangevarobj1=newobject();varobj2= obj1;// old assertion:
Assert.AreSame(obj2, obj1);// new assertion:
obj1.Should().BeSameAs(obj2);
Failure messages
objectobj1=6;objectobj2="foo";// old assertion:
Assert.AreSame(obj2, obj1);/* fail message: Assert.AreSame failed. */// new assertion:
obj1.Should().BeSameAs(obj2);/* fail message: Expected obj1 to refer to "foo", but found 6. */
scenario: AssertAreNotSame
// arrangeobjectobj1=6;objectobj2="foo";// old assertion:
Assert.AreNotSame(obj2, obj1);// new assertion:
obj1.Should().NotBeSameAs(obj2);
Failure messages
objectobj1="foo";objectobj2="foo";// old assertion:
Assert.AreNotSame(obj2, obj1);/* fail message: Assert.AreNotSame failed. */// new assertion:
obj1.Should().NotBeSameAs(obj2);/* fail message: Did not expect obj1 to refer to "foo". */
// arrangevarlist=newList<object>{1,2,3};// old assertion:
CollectionAssert.AllItemsAreInstancesOfType(list,typeof(int));// new assertion:
list.Should().AllBeOfType<int>();
Failure messages
varlist=newList<object>{1,2,"foo"};// old assertion:
CollectionAssert.AllItemsAreInstancesOfType(list,typeof(int));/* fail message: CollectionAssert.AllItemsAreInstancesOfType failed. Element at index 2 is not of expected type. Expected type:<System.Int32>. Actual type:<System.String>. */// new assertion:
list.Should().AllBeOfType<int>();/* fail message: Expected type to be "System.Int32", but found "[System.Int32, System.Int32, System.String]". */
scenario: CollectionAssertAreEqual
// arrangevarlist1=newList<int>{1,2,3};varlist2=newList<int>{1,2,3};// old assertion:
CollectionAssert.AreEqual(list2, list1);// new assertion:
list1.Should().Equal(list2);
Failure messages
varlist1=newList<int>{1,2,3};varlist2=newList<int>{1,2,4};// old assertion:
CollectionAssert.AreEqual(list2, list1);/* fail message: CollectionAssert.AreEqual failed. (Element at index 2 do not match.) */// new assertion:
list1.Should().Equal(list2);/* fail message: Expected list1 to be equal to {1, 2, 4}, but {1, 2, 3} differs at index 2. */
scenario: CollectionAssertAreNotEqual
// arrangevarlist1=newList<int>{1,2,3};varlist2=newList<int>{1,2,4};// old assertion:
CollectionAssert.AreNotEqual(list2, list1);// new assertion:
list1.Should().NotEqual(list2);
Failure messages
varlist1=newList<int>{1,2,3};varlist2=newList<int>{1,2,3};// old assertion:
CollectionAssert.AreNotEqual(list2, list1);/* fail message: CollectionAssert.AreNotEqual failed. (Both collection contain same elements.) */// new assertion:
list1.Should().NotEqual(list2);/* fail message: Did not expect collections {1, 2, 3} and {1, 2, 3} to be equal. */
scenario: CollectionAssertAreEquivalent
// arrangevarlist1=newList<int>{1,2,3};varlist2=newList<int>{3,2,1};// old assertion:
CollectionAssert.AreEquivalent(list2, list1);// new assertion:
list1.Should().BeEquivalentTo(list2);
Failure messages
varlist1=newList<int>{1,2,3};varlist2=newList<int>{2,3,4};// old assertion:
CollectionAssert.AreEquivalent(list2, list1);/* fail message: CollectionAssert.AreEquivalent failed. The expected collection contains 1 occurrence(s) of <4>. The actual collection contains 0 occurrence(s). */// new assertion:
list1.Should().BeEquivalentTo(list2);/* fail message: Expected list1[2] to be 4, but found 1.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- Include all non-private properties- Include all non-private fields- Match member by name (or throw)- Be strict about the order of items in byte arrays- Without automatic conversion. */
scenario: CollectionAssertAreNotEquivalent
// arrangevarlist1=newList<int>{1,2,3};varlist2=newList<int>{2,3,4};// old assertion:
CollectionAssert.AreNotEquivalent(list2, list1);// new assertion:
list1.Should().NotBeEquivalentTo(list2);
Failure messages
varlist1=newList<int>{1,2,3};varlist2=newList<int>{2,3,1};// old assertion:
CollectionAssert.AreNotEquivalent(list2, list1);/* fail message: CollectionAssert.AreNotEquivalent failed. Both collections contain the same elements. */// new assertion:
list1.Should().NotBeEquivalentTo(list2);/* fail message: Expected list1 {1, 2, 3} not to be equivalent to collection {2, 3, 1}. */
scenario: CollectionAssertAllItemsAreNotNull
// arrangevarlist=newList<object>{1,"foo",true};// old assertion:
CollectionAssert.AllItemsAreNotNull(list);// new assertion:
list.Should().NotContainNulls();
Failure messages
varlist=newList<object>{1,null,true};// old assertion:
CollectionAssert.AllItemsAreNotNull(list);/* fail message: CollectionAssert.AllItemsAreNotNull failed. */// new assertion:
list.Should().NotContainNulls();/* fail message: Expected list not to contain <null>s, but found one at index 1. */
scenario: CollectionAssertAllItemsAreUnique
// arrangevarlist=newList<int>{1,2,3};// old assertion:
CollectionAssert.AllItemsAreUnique(list);// new assertion:
list.Should().OnlyHaveUniqueItems();
Failure messages
varlist=newList<int>{1,2,1};// old assertion:
CollectionAssert.AllItemsAreUnique(list);/* fail message: CollectionAssert.AllItemsAreUnique failed. Duplicate item found:<1>. */// new assertion:
list.Should().OnlyHaveUniqueItems();/* fail message: Expected list to only have unique items, but item 1 is not unique. */
scenario: CollectionAssertContains
// arrangevarlist=newList<int>{1,2,3};// old assertion:
CollectionAssert.Contains(list,2);// new assertion:
list.Should().Contain(2);
Failure messages
varlist=newList<int>{1,2,3};// old assertion:
CollectionAssert.Contains(list,4);/* fail message: CollectionAssert.Contains failed. */// new assertion:
list.Should().Contain(4);/* fail message: Expected list {1, 2, 3} to contain 4. */
scenario: CollectionAssertDoesNotContain
// arrangevarlist=newList<int>{1,2,3};// old assertion:
CollectionAssert.DoesNotContain(list,4);// new assertion:
list.Should().NotContain(4);
Failure messages
varlist=newList<int>{1,2,3};// old assertion:
CollectionAssert.DoesNotContain(list,2);/* fail message: CollectionAssert.DoesNotContain failed. */// new assertion:
list.Should().NotContain(2);/* fail message: Expected list {1, 2, 3} to not contain 2. */
scenario: CollectionAssertIsSubsetOf
// arrangevarlist1=newList<int>{1,2,3,4};varlist2=newList<int>{2,3};// old assertion:
CollectionAssert.IsSubsetOf(list2, list1);// new assertion:
list2.Should().BeSubsetOf(list1);
Failure messages
varlist1=newList<int>{1,2,3,4};varlist2=newList<int>{2,3,5};// old assertion:
CollectionAssert.IsSubsetOf(list2, list1);/* fail message: CollectionAssert.IsSubsetOf failed. */// new assertion:
list2.Should().BeSubsetOf(list1);/* fail message: Expected list2 to be a subset of {1, 2, 3, 4}, but items {5} are not part of the superset. */
scenario: CollectionAssertIsNotSubsetOf
// arrangevarlist1=newList<int>{1,2,3,4};varlist2=newList<int>{2,3,5};// old assertion:
CollectionAssert.IsNotSubsetOf(list2, list1);// new assertion:
list2.Should().NotBeSubsetOf(list1);
Failure messages
varlist1=newList<int>{1,2,3,4};varlist2=newList<int>{2,3};// old assertion:
CollectionAssert.IsNotSubsetOf(list2, list1);/* fail message: CollectionAssert.IsNotSubsetOf failed. */// new assertion:
list2.Should().NotBeSubsetOf(list1);/* fail message: Did not expect list2 {2, 3} to be a subset of {1, 2, 3, 4}. */
scenario: AssertThrowsException
// arrangestaticvoidThrowException()=>thrownew InvalidOperationException();Actionaction= ThrowException;// old assertion:
Assert.ThrowsException<InvalidOperationException>(action);// new assertion:
action.Should().ThrowExactly<InvalidOperationException>();
Failure messages
staticvoidThrowException()=>thrownew InvalidOperationException();Actionaction= ThrowException;// old assertion:
Assert.ThrowsException<ArgumentException>(action);/* fail message: Assert.ThrowsException failed. Expected exception type:<System.ArgumentException>. Actual exception type:<System.InvalidOperationException>. */// new assertion:
action.Should().ThrowExactly<ArgumentException>();/* fail message: Expected type to be System.ArgumentException, but found System.InvalidOperationException. */
scenario: AssertThrowsExceptionAsync
// arrangestatic Task ThrowExceptionAsync()=>thrownew InvalidOperationException();Func<Task>action= ThrowExceptionAsync;// old assertion:await Assert.ThrowsExceptionAsync<InvalidOperationException>(action);// new assertion:await action.Should().ThrowExactlyAsync<InvalidOperationException>();
Failure messages
static Task ThrowExceptionAsync()=>thrownew InvalidOperationException();Func<Task>action= ThrowExceptionAsync;// old assertion:await Assert.ThrowsExceptionAsync<ArgumentException>(action);/* fail message: Assert.ThrowsException failed. Expected exception type:<System.ArgumentException>. Actual exception type:<System.InvalidOperationException>. */// new assertion:await action.Should().ThrowExactlyAsync<ArgumentException>();/* fail message: Expected type to be System.ArgumentException, but found System.InvalidOperationException. */
scenario: StringAssertContains
// arrangevarstr="foo";// old assertion:
StringAssert.Contains(str,"oo");// new assertion:
str.Should().Contain("oo");
Failure messages
varstr="foo";// old assertion:
StringAssert.Contains(str,"bar");/* fail message: StringAssert.Contains failed. String 'foo' does not contain string 'bar'. . */// new assertion:
str.Should().Contain("bar");/* fail message: Expected str "foo" to contain "bar". */
scenario: StringAssertStartsWith
// arrangevarstr="foo";// old assertion:
StringAssert.StartsWith(str,"fo");// new assertion:
str.Should().StartWith("fo");
Failure messages
varstr="foo";// old assertion:
StringAssert.StartsWith(str,"oo");/* fail message: StringAssert.StartsWith failed. String 'foo' does not start with string 'oo'. . */// new assertion:
str.Should().StartWith("oo");/* fail message: Expected str to start with "oo", but "foo" differs near "foo" (index 0). */
scenario: StringAssertEndsWith
// arrangevarstr="foo";// old assertion:
StringAssert.EndsWith(str,"oo");// new assertion:
str.Should().EndWith("oo");
Failure messages
varstr="foo";// old assertion:
StringAssert.EndsWith(str,"fo");/* fail message: StringAssert.EndsWith failed. String 'foo' does not end with string 'fo'. . */// new assertion:
str.Should().EndWith("fo");/* fail message: Expected str "foo" to end with "fo". */
scenario: StringAssertMatches
// arrangevarstr="foo";varpattern=new Regex("f.o");// old assertion:
StringAssert.Matches(str, pattern);// new assertion:
str.Should().MatchRegex(pattern);
Failure messages
varstr="foo";varpattern=new Regex("b.r");// old assertion:
StringAssert.Matches(str, pattern);/* fail message: StringAssert.Matches failed. String 'foo' does not match pattern 'b.r'. . */// new assertion:
str.Should().MatchRegex(pattern);/* fail message: Expected str to match regex "b.r", but "foo" does not match. */
scenario: StringAssertDoesNotMatch
// arrangevarstr="foo";varpattern=new Regex("b.r");// old assertion:
StringAssert.DoesNotMatch(str, pattern);// new assertion:
str.Should().NotMatchRegex(pattern);
Failure messages
varstr="foo";varpattern=new Regex("f.o");// old assertion:
StringAssert.DoesNotMatch(str, pattern);/* fail message: StringAssert.DoesNotMatch failed. String 'foo' matches pattern 'f.o'. . */// new assertion:
str.Should().NotMatchRegex(pattern);/* fail message: Did not expect str to match regex "f.o", but "foo" matches. */