views:

33

answers:

1

I recently started creating services layers and making declarations like:

MyService myService = new MyService();
myService.DoSomething();

This was inspired by some ASP.NET MVC videos and I like the pattern.

Then I started creating interfaces and mocks like:

IMyService myService = new MockMyService();
myService.DoSomething();

So I can isolate parts of the code to test. But now my service layer folder is loaded with classes, interfaces, and mock classes:

IServiceTypeA.cs
ServiceTypeA.cs
MockServiceTypeA.cs
IServiceTypeB.cs
ServiceTypeB.cs
MockServiceTypeB.cs
...
IServiceTypeZ.cs
ServiceTypeZ.cs
MockServiceTypeZ.cs

How do you organize these in a logical way?

+4  A: 
- Providers
    ServiceTypeA.cs
    ServiceTypeB.cs
    ServiceTypeC.cs
- Interfaces
    IServiceTypeA.cs
    IServiceTypeB.cs
    IServiceTypeC.cs
- Testing
    - Unit Tests
    - Mocks
        MockServiceTypeA.cs
        MockServiceTypeB.cs
        MockServiceTypeC.cs

Or you could use Mocking frameworks to have the Mock Services generated at runtime.

Justin Niessner
+1 straightforward and a good place to start. I also like the suggestion of a mocking framework.
blu