I recently made the following by keeping a blank solution and then added the following projects/templates to it:
1. API Template/project having name ASWRestAPIs 2. nUnit Template/project having name ASWRestAPIs.Tests 3. Worker service project/template having name AWSPollingService 4. nUnit Template/project having the name AWSPollingService.Tests
Enclosing quick snap-shot, Is it the right approach to move forward? Appreciate your inputs.
ste5an
As already written, I haven't done this with Core. So you need to test it.
satmisha
ASKER
Hi Ste5an, I couldn't get your point. Let me re-phrase myself, I want to ask is my project structure correct, the way I created the project structure by combining the rest API project with the worker service project template along with unit tests projects?
The other way around, nothing to do with .Net core. If I ask you, Will the following project structure correct where I combine the following projects under one blank project? 1. WindowService 2. RestAPIs 3. NUnit project ( WindowService .Tests) 4. NUnit project RestAPIs.Tests
ste5an
Nope, it should be
1. Class library for Unit Of Work.
2. Unit test project for class library.
3. Rest API.
4. Self hosting service.
Testing the API or the service would be an integration test.
satmisha
ASKER
Thank you Ste5an, we are now heading in right direction :-).
What are two of these for, apologies for my limited knowledge: 1. Class library for Unit Of Work. 2. Unit test project for the class library.
My understanding is that I should have two nUnit projects in the solution, one meant to test the code written in the API project and another meant to test the code of the worker service.
A unit test is for test a unit. Well, sounds odd. Thus an example. Consider a calculator available via rest API.
Then you would implement a separate Calculator class with just the Add, Minus, Mulitply and Divide methods.
The unit test project would only test this calculator class.
Now you implement your calculator as rest API in a separate project. And maybe in your self-hosted worker project.
Testing the rest API is possible, but this is an integration test. It tests whether you have integrated the calculator class correctly into the rest API. While it is a test, it is not a unit test. Same for tests about the worker service.
satmisha
ASKER
Does that mean,
1. the project "class library for unit of work" (UnitOfWork) will contain the classes to test the both worker service project and API project. It should contain classes from both the projects with methods used in the actual project. 2. However project "unit test project for the class library" (UnitOfWork.Tests)will test the project "class library for the unit of work" as mentioned above?
Sorry for asking too much as my confusion has gone up :-(
Or Can't I have two nunit test project one to test the API and another one to test the worker service?
Thank you so much ste5an. I guess it clears a lot to me. I am going to open a new ticket which talks for the deployment of monster, please visit that too.
I have created another question " How to deploy API and worker service project on production environment" which is just the extension of this current one and on the deployment part. Appreciate it if you could provide your inputs there as I did not want to ask everything in one ticket.
Cause the worker service project template was introduced with .NET Core 3.0.