-
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.
Added extension methods for cleaner arrange code. (#13)
Added extension methods for cleaner arrange code
- Loading branch information
Showing
9 changed files
with
65 additions
and
10 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
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
4 changes: 2 additions & 2 deletions
4
FluentArrange.NSubstitute.Tests/FluentArrange.NSubstitute.Tests.csproj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Threading.Tasks; | ||
using FluentArrange.Tests.TestClasses; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace FluentArrange.Tests | ||
{ | ||
public class ExtensionMethods | ||
{ | ||
[Fact] | ||
public void Returns_ActionT_ShouldInvokeAction() | ||
{ | ||
// Arrange | ||
Foo foo = new(); | ||
|
||
// Act | ||
foo.Returns(e => e.Id = 1); | ||
|
||
// Assert | ||
foo.Id.Should().Be(1); | ||
} | ||
|
||
[Fact] | ||
public void Returns_ActionTaskT_ShouldInvokeAction() | ||
{ | ||
// Arrange | ||
Task<Foo> foo = Task.FromResult(new Foo()); | ||
|
||
// Act | ||
foo.Returns(e => e.Id = 2); | ||
|
||
// Assert | ||
foo.Result.Id.Should().Be(2); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ namespace FluentArrange.Tests.TestClasses | |
{ | ||
public class Foo : IFoo | ||
{ | ||
public int Id { get; set; } | ||
} | ||
} |
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,18 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace FluentArrange | ||
{ | ||
public static class ExtensionMethods | ||
{ | ||
public static void Returns<T>(this Task<T> @object, Action<T> configure) | ||
{ | ||
configure.Invoke(@object.GetAwaiter().GetResult()); | ||
} | ||
|
||
public static void Returns<T>(this T @object, Action<T> configure) | ||
{ | ||
configure.Invoke(@object); | ||
} | ||
} | ||
} |
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