-
This solution is implemented using .Net Core version 3.1 and runs as a
ASP.Net MVC
application -
The programming language used for implementation is
C#
-
The root directory contains README file, solution file and projects folders
-
Following bullet points explains about projects and their structure.
-
KoganCubic
- This project is the .net core MVC application. It calls the API endpoint asynchronous - The
Home
controller implementsCalculate
action and calls theCalculate
service . - The
Calculate
class has dependency onCalculaterClient
for getting the content from API. TheCalculator
service makes continuous calls to pages of API and calculates the parcel's 'Cubic weight' inAir conditioner
category - The
CalculatorClient
class has dependency on singleton object of .NetHttpClient
and its responsibility is to fetch and deserialize the API response - The
Model
folder contains thePOCO
classes including the API response and calculation response
- This project is the .net core MVC application. It calls the API endpoint asynchronous - The
-
KobagCubic.Test
- This is the unit test project of the solution.
- Unit test implements
ICalculatorClient
as fake client and returns mock data - Unit test class initialize the object of type
ICalculator
and pass the fakeICalculatorClient
- One unit test is covering the following scenario
- Calls the fake client method and check the number of objects with
Calculator
response - Calculates the average cubic weight and compare it with response average weight.
- Calls the fake client method and check the number of objects with
-
docker-compose project
- This is the docker compose project which pulls .net core images and build the web project
- It runs the backend on port 5001.
- Asynchronous Programming : To avoid UI freeze, client and services calculate and return the data in asynchronous format.
- Single responsibility : Each class and service like
Calculator
andCalculatorClient
is responsible for a single and isolated task. - Dependency Injection : by using the built-in DI container of .Net core framework, each class simply accept its dependency and DI container is responsible to resolve the scope and type of dependencies.
- Docker desktop must be up and running
- In order to build and run application, execute in the root folder the following commands :
docker-compose build
and after thatdocker-compose up
- When the
docker-compose up
job is finished, access the application using this url : http://localhost:5001
- Open the solution
sln
file in visual studio - Build the solution by right click on Solution and click
Build solution
- right click on
KoganCubic
project and set as Startup project - Click on
IIS Express
and it should display the home page in browser : https://localhost:44387/
Example of the screen when application loads
Example of the screen of Average cubic weight report
Test result