The project is written in C# 7.0 and it was created in a Windows 10 operating system using Visual Studio 2017 RC. The solution provided conisists in three projects:
- Salestax: a simple Console App (.NET Core) that prints out results after processing hardcoded input
- Salestax.Core: a Class Library (.NET Standard) with the core logic
- Salestax.Tests: a xUnit Test Project (.NET Core) that verifies the accuracy of core project logics
The Console App is able to parse input strings (using a Regex) in the following format:
<quantity> imported? <description> at <price>
- <quantity> must be an integer
- "imported" is an optional string
- <description> is the description of the product
- <price> must be a decimal
The result is the receipt with computed amount of each product followed by the sales taxes and the total amount:
1 book: 12.49
1 music CD: 16.49
1 chocolate bar: 0.85
Sales Taxes: 1.50
Total: 29.83
In order to compile and run the project you need:
- the
Microsoft .NET Core SDK
:- you have to download the
1.0.0-preview4-004175 .NET Core SDK Installer
from the .NET Core command-line (CLI) tools site (use ".NET Core SDK Installer" column)
- you have to download the
- the
Microsoft .NET Core 1.1 runtime
:- you have to download the
Current release
from the .NET Core Site - please ensure to select "Current" and "Runtime" buttons
- you have to download the
If you want an IDE to modify and run the code you have to use Visual Studio 2017 RC
:
- you have to download the
Community
edition of Visual Studio- please ensure you check the
.NET Core and Docker Preview
when you install the product
- please ensure you check the
- open Visual Studio
- from the top menu click on
File -> Open -> Project/solution
- select the
SalesTax.sln
file - from the top menu click on
Build -> Rebuild Solution
(or simply use the keyboard shortcutF6
)
If you love the "Command Prompt" you can compile the entire solution from command line:
- open a command prompt in solution folder (where the SalesTax.sln file is located)
- "dotnet restore"
- "dotnet build"
- from the top menu click on
Debug -> Start Debugging
(or simply use the keyboard shortcutF5
)
- open a command prompt in SalesTax project folder (where
Program.cs
file is located) - "dotnet run"
Every test inside the project SalesTax.Tests has comments to describe what's going on.
// Arrange
-> setup test environment (input, variables, ...)// Act
-> execute the operation you want to test// Assert
-> do all the checks to establish the test result.
- from the top menu click on
Test -> Windows -> Test Explorer
- run all tests from the Test Explorer Tab
- open a command prompt in SalesTax.Tests project folder (where all test classes are located)
- "dotnet test"