diff options
Diffstat (limited to 'spec/Create.cs')
| -rw-r--r-- | spec/Create.cs | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/spec/Create.cs b/spec/Create.cs index 3876dcc..1717ba3 100644 --- a/spec/Create.cs +++ b/spec/Create.cs @@ -2,52 +2,20 @@ using System; using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using Rhino.Mocks;
+using Moq;
namespace specs
{
static public class Create
{
- static public Stub an<Stub>() where Stub : class
+ static public Mock<Stub> an<Stub>() where Stub : class
{
return An<Stub>();
}
- static ItemToStub An<ItemToStub>() where ItemToStub : class
+ static public Mock<ItemToStub> An<ItemToStub>() where ItemToStub : class
{
- var type = typeof (ItemToStub);
- if (type.IsClass)
- {
- var constructors = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- if (constructors.Any(x => x.GetParameters().Length == 0))
- return MockRepository.GenerateMock<ItemToStub>();
-
- return MockRepository.GenerateMock<ItemToStub>(get_parameters_for(get_greediest_constructor_from(constructors)).ToArray());
- }
- return MockRepository.GenerateMock<ItemToStub>();
- }
-
- static IEnumerable<object> get_parameters_for(ConstructorInfo constructor)
- {
- return constructor
- .GetParameters()
- .Select(x =>
- {
- if (x.ParameterType.IsValueType)
- return Activator.CreateInstance(x.ParameterType);
- if (x.ParameterType.IsSealed) return null;
- return MockRepository.GenerateStub(x.ParameterType);
- });
- }
-
- static ConstructorInfo get_greediest_constructor_from(IEnumerable<ConstructorInfo> constructors)
- {
- return constructors.OrderBy(x => x.GetParameters().Count()).Last();
- }
-
- static public T the_dependency<T>() where T : class
- {
- return An<T>();
+ return new Mock<ItemToStub>();
}
}
-}
\ No newline at end of file +}
|
