-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78ef8f6
commit 645d9a8
Showing
7 changed files
with
114 additions
and
50 deletions.
There are no files selected for viewing
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,75 @@ | ||
using Pretender; | ||
|
||
namespace Example.Tests; | ||
|
||
public class MatcherTests | ||
{ | ||
[Fact] | ||
public void OneAnyMatcher_OneAnonymousMatcher() | ||
{ | ||
var testInterfacePretend = Pretend.That<ITestInterface>(); | ||
|
||
testInterfacePretend | ||
.Setup(i => i.Test(It.IsAny<string>(), It.Is<string>(s => s == "Hi"))) | ||
.Returns(1); | ||
|
||
var testInterface = testInterfacePretend.Create(); | ||
|
||
var returnValue = testInterface.Test("Yo", "Hi"); | ||
Assert.Equal(1, returnValue); | ||
} | ||
|
||
[Fact] | ||
public void TwoAnonymousMatchers() | ||
{ | ||
var testInterfacePretend = Pretend.That<ITestInterface>(); | ||
|
||
testInterfacePretend | ||
.Setup(i => i.Test(It.Is<string>(s => s == "Yo"), It.Is<string>(s => s == "Hi"))) | ||
.Returns(1); | ||
|
||
var testInterface = testInterfacePretend.Create(); | ||
|
||
var returnValue = testInterface.Test("Yo", "Hi"); | ||
Assert.Equal(1, returnValue); | ||
} | ||
|
||
[Fact] | ||
public void AnonymousMatcherThatCapturesLocal() | ||
{ | ||
var testInterfacePretend = Pretend.That<ITestInterface>(); | ||
|
||
string local = "Yo"; | ||
|
||
testInterfacePretend | ||
.Setup(i => i.Test(It.Is<string>(s => s == local), It.Is<string>(s => s == "Hi"))) | ||
.Returns(1); | ||
|
||
var testInterface = testInterfacePretend.Create(); | ||
|
||
var returnValue = testInterface.Test("Yo", "Hi"); | ||
Assert.Equal(1, returnValue); | ||
} | ||
|
||
public string TestProperty { get; set; } = "Yo"; | ||
|
||
[Fact] | ||
public void AnonymousMatcherThatCapturesProperty() | ||
{ | ||
var testInterfacePretend = Pretend.That<ITestInterface>(); | ||
|
||
testInterfacePretend | ||
.Setup(i => i.Test(It.Is<string>(s => s == TestProperty), It.Is<string>(s => s == "Hi"))) | ||
.Returns(1); | ||
|
||
var testInterface = testInterfacePretend.Create(); | ||
|
||
var returnValue = testInterface.Test("Yo", "Hi"); | ||
Assert.Equal(1, returnValue); | ||
} | ||
} | ||
|
||
public interface ITestInterface | ||
{ | ||
int Test(string arg1, string arg2); | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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