forked from mrpinkzh/exas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented string-contains-not assertion mrpinkzh#12
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/ExAs/Assertions/MemberAssertions/Strings/ContainsNotAssertion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using ExAs.Results; | ||
using ExAs.Utils; | ||
|
||
namespace ExAs.Assertions.MemberAssertions.Strings | ||
{ | ||
public class ContainsNotAssertion : IAssertValue<string> | ||
{ | ||
private readonly string expected; | ||
|
||
public ContainsNotAssertion(string expected) | ||
{ | ||
this.expected = expected; | ||
} | ||
|
||
public ValueAssertionResult AssertValue(string actual) | ||
{ | ||
return new ValueAssertionResult( | ||
!actual.Contains_NullAware(expected), | ||
actual.ToValueString(), | ||
ComposeLog.Expected($"doesn't contain {expected.ToValueString()}")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/ExAs.Tests/Api/Strings/StringAssertion_DoesntContain_Feature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using ExAs.Utils; | ||
using NUnit.Framework; | ||
using static ExAs.Utils.Creation.CreateNinjas; | ||
|
||
namespace ExAs.Api.Strings | ||
{ | ||
public class StringAssertion_DoesntContain_Feature | ||
{ | ||
[Test] | ||
public void ExpectingNotAkashi_OnNaruto_ShouldPass() | ||
{ | ||
// act | ||
var result = Naruto().Evaluate(n => n.Member(x => x.Name).DoesntContain("akashi")); | ||
|
||
// assert | ||
result.ExAssert(r => r.Member(x => x.succeeded).IsTrue() | ||
.Member(x => x.log) .IsEqualTo("Ninja: ( )Name = 'Naruto'") | ||
.Member(x => x.expectation).IsEqualTo(ComposeLog.Expected("doesn't contain 'akashi'"))); | ||
} | ||
|
||
[Test] | ||
public void ExpectingNotKash_OnKakashi_ShouldFail() | ||
{ | ||
// act | ||
var result = Kakashi().Evaluate(n => n.Member(x => x.Name).DoesntContain("kash")); | ||
|
||
// assert | ||
result.ExAssert(r => r.Member(x => x.succeeded).IsFalse() | ||
.Member(x => x.log) .IsEqualTo("Ninja: (X)Name = 'Kakashi'") | ||
.Member(x => x.expectation).IsEqualTo(ComposeLog.Expected("doesn't contain 'kash'"))); | ||
} | ||
|
||
[Test] | ||
public void ExpectingNull_OnNaruto_ShouldSucceed() | ||
{ | ||
// act | ||
var result = Naruto().Evaluate(n => n.Member(x => x.Name).DoesntContain(null)); | ||
|
||
// assert | ||
result.ExAssert(r => r.Member(x => x.succeeded).IsTrue() | ||
.Member(x => x.expectation).IsEqualTo(ComposeLog.Expected("doesn't contain null"))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters