C#: Folder structure with service layer, interfaces, and mocks?
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 isol开发者_运维百科ate 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?
- 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.
精彩评论