-
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.
v1.0.0-alpha.2 - simplify API by reducing the generic type parameters…
… that need to be specified
- Loading branch information
1 parent
ec033f3
commit b48be6f
Showing
21 changed files
with
407 additions
and
192 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
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,80 @@ | ||
using Moq; | ||
|
||
namespace XpressTest; | ||
|
||
public class DependencyBuilder<TSut, TDependency> : | ||
IDependencyBuilder<TSut> | ||
where TSut : class | ||
{ | ||
private readonly TDependency _dependency; | ||
|
||
private readonly ICollection<IDependency> _dependencies; | ||
|
||
public DependencyBuilder( | ||
TDependency dependency, | ||
ICollection<IDependency> dependencies | ||
) | ||
{ | ||
_dependency = dependency; | ||
_dependencies = dependencies; | ||
} | ||
|
||
|
||
public IDependencyBuilder<TSut> With<TNewDependency>(TNewDependency newDependency) | ||
{ | ||
var dependency = new Dependency<TDependency>(_dependency); | ||
|
||
_dependencies.Add(dependency); | ||
|
||
var builder = new DependencyBuilder<TSut, TNewDependency>( | ||
newDependency, | ||
_dependencies | ||
); | ||
|
||
return builder; | ||
} | ||
|
||
public IMockDependencyBuilder<TSut, TNewDependency> WithA<TNewDependency>() where TNewDependency : class | ||
{ | ||
var dependency = new Dependency<TDependency>(_dependency); | ||
|
||
_dependencies.Add(dependency); | ||
|
||
var newMock = new Mock<TNewDependency>(); | ||
|
||
var builder = new MockDependencyBuilder<TSut, TNewDependency>( | ||
newMock, | ||
_dependencies | ||
); | ||
|
||
return builder; | ||
} | ||
|
||
public IAsserter<Action<TResult>> WhenIt<TResult>(Func<TSut, TResult> func) | ||
{ | ||
var dependency = new Dependency<TDependency>(_dependency); | ||
|
||
_dependencies.Add(dependency); | ||
|
||
var builder = new ResultAsserter<TSut, TResult>( | ||
func, | ||
_dependencies | ||
); | ||
|
||
return builder; | ||
} | ||
|
||
public IAsserter<Action> WhenIt(Action<TSut> func) | ||
{ | ||
var dependency = new Dependency<TDependency>(_dependency); | ||
|
||
_dependencies.Add(dependency); | ||
|
||
var builder = new VoidAsserter<TSut>( | ||
func, | ||
_dependencies | ||
); | ||
|
||
return builder; | ||
} | ||
} |
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,8 @@ | ||
namespace XpressTest; | ||
|
||
public interface IActor<TSut> | ||
{ | ||
IAsserter<Action<TResult>> WhenIt<TResult>(Func<TSut, TResult> func); | ||
|
||
IAsserter<Action> WhenIt(Action<TSut> func); | ||
} |
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,6 @@ | ||
namespace XpressTest; | ||
|
||
public interface IAsserter<TAssertion> | ||
{ | ||
ITester ThenItShould(TAssertion assertion); | ||
} |
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,9 @@ | ||
namespace XpressTest; | ||
|
||
public interface IDependencyBuilder<TSut> : IActor<TSut> | ||
{ | ||
IDependencyBuilder<TSut> With<TNewDependency>(TNewDependency newDependency); | ||
|
||
IMockDependencyBuilder<TSut, TNewDependency> WithA<TNewDependency>() | ||
where TNewDependency : class; | ||
} |
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,9 @@ | ||
using System.Linq.Expressions; | ||
|
||
namespace XpressTest; | ||
|
||
public interface IMockDependencyBuilder<TSut, TDependency> : IDependencyBuilder<TSut> | ||
{ | ||
IMockDependencyBuilder<TSut, TDependency> That<TDependencyResult>(Expression<Func<TDependency, TDependencyResult>> func, | ||
TDependencyResult dependencyResult); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace XpressTest; | ||
|
||
public interface ITester | ||
{ | ||
void Test(); | ||
} |
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
Oops, something went wrong.