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?
- 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With