-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assignment
- Loading branch information
0 parents
commit 6e2d775
Showing
85 changed files
with
34,112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using TaxCalculation.Domain; | ||
using TaxCalculation.Domain.Enums; | ||
using TaxCalculation.Domain.Factories; | ||
using TaxCalculation.Domain.Interfaces; | ||
using TaxCalculation.Domain.Repositories; | ||
|
||
|
||
namespace TaxCalculation.ConsoleApp | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
IOrdersRepository repository = new OrdersRepository(); | ||
// | ||
var orders = repository.ReadOrders("SalesData.txt"); | ||
|
||
foreach (var order in orders) | ||
{ | ||
System.Console.WriteLine(order.OrderNumber); | ||
foreach(var lineItem in order.LineItems) | ||
{ | ||
System.Console.WriteLine(lineItem.GetQuantity() + " " + lineItem.Name + " " + decimal.Round(lineItem.GetTotal(),2)); | ||
} | ||
Console.WriteLine("Sales Taxes: " + order.GetOrderLineTax()); | ||
Console.WriteLine("Total: " + order.GetOrderTotal()); | ||
Console.WriteLine(Environment.NewLine); | ||
} | ||
Console.ReadLine(); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("TaxCalculation.Console")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("TaxCalculation.Console")] | ||
[assembly: AssemblyCopyright("Copyright © 2013")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("214b66b9-646e-45fb-913c-c28e725cfca9")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{5D8F40B3-BAF4-4522-8A7D-EA3D8D6E89F5}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>TaxCalculation.Console</RootNamespace> | ||
<AssemblyName>TaxCalculation.Console</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\TaxCalculation.Domain\TaxCalculation.Domain.csproj"> | ||
<Project>{690771c4-1c1d-425c-8ddb-5cfad55c3418}</Project> | ||
<Name>TaxCalculation.Domain</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#Quantity,Product,Price,ItemType | ||
Order 1 | ||
1,book,12.49,Exempt | ||
1,music CD,14.99,Basic | ||
1,chocolate bar,0.85,Exempt | ||
Order 2 | ||
1,imported box of chocolates,10.00,Import | ||
1,imported bottle of perfume,47.50,BasicImport | ||
Order 3 | ||
1,imported bottle of perfume,27.99,BasicImport | ||
1,bottle of perfume,18.99,Basic | ||
1,packet of headache pills,9.75,Exempt | ||
1,imported box of chocolates,11.25,Import |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
TaxCalculation.Console/bin/Debug/TaxCalculation.Console.exe.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+6.56 KB
TaxCalculation.Console/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
TaxCalculation.Console/obj/Debug/TaxCalculation.Console.csproj.FileListAbsolute.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\obj\Debug\TaxCalculation.Console.csprojResolveAssemblyReference.cache | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Console.exe.config | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Console.exe | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Console.pdb | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Domain.dll | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Domain.pdb | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\obj\Debug\TaxCalculation.Console.exe | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\obj\Debug\TaxCalculation.Console.pdb |
Binary file added
BIN
+4.94 KB
TaxCalculation.Console/obj/Debug/TaxCalculation.Console.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
TaxCalculation.Console/obj/Debug/TaxCalculation.ConsoleApp.csproj.FileListAbsolute.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Console.exe.config | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Console.exe | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Console.pdb | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Domain.dll | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\bin\Debug\TaxCalculation.Domain.pdb | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\obj\Debug\TaxCalculation.Console.exe | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\obj\Debug\TaxCalculation.Console.pdb | ||
C:\Edwin\ThoughtWorks\TaxCalculator\TaxCalculation.Console\obj\Debug\TaxCalculation.ConsoleApp.csprojResolveAssemblyReference.cache |
Binary file added
BIN
+6.22 KB
...culation.Console/obj/Debug/TaxCalculation.ConsoleApp.csprojResolveAssemblyReference.cache
Binary file not shown.
Empty file added
0
...culation.Console/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
Empty file.
Empty file added
0
...culation.Console/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
Empty file.
Empty file added
0
...culation.Console/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace TaxCalculation.Domain.Enums | ||
{ | ||
[Flags] | ||
public enum ItemType | ||
{ | ||
Exempt = 0, | ||
Basic = 1, | ||
Import = 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using TaxCalculation.Domain.Enums; | ||
using TaxCalculation.Domain.Interfaces; | ||
|
||
namespace TaxCalculation.Domain.Factories | ||
{ | ||
public static class LineItemFactory | ||
{ | ||
private static readonly Rounding ROUNDING = new Rounding(0.05M); | ||
private static readonly ITax BASICTAX = new Tax(0.1M, ROUNDING); | ||
private static readonly ITax IMPORTTAX = new Tax(0.05M, ROUNDING); | ||
private static readonly ITax EXEMPTTAX = new Tax(0.0M, ROUNDING); | ||
|
||
private static readonly Dictionary<ItemType, ITax> itemTaxLookup = new Dictionary<ItemType, ITax>() | ||
{ | ||
{ ItemType.Basic, BASICTAX }, | ||
{ ItemType.Import, IMPORTTAX }, | ||
{ ItemType.Exempt, EXEMPTTAX } | ||
}; | ||
|
||
public static ILineItem GetLineItem(string name, decimal price, int quantity, ItemType itemType) | ||
{ | ||
ILineItem item = new LineItem(name, price, quantity); | ||
|
||
foreach (int flag in Enum.GetValues(typeof(ItemType))) | ||
{ | ||
if ((flag & (int)itemType) == flag) | ||
{ | ||
item = (ILineItem)Activator.CreateInstance(typeof(LineItemTaxDecorator), new object[] { item, itemTaxLookup[(ItemType)flag] }); | ||
} | ||
} | ||
|
||
return item; | ||
} | ||
|
||
public static ILineItem GetLineItem(string name, decimal price, int quantity) | ||
{ | ||
return new LineItem(name, price, quantity); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace TaxCalculation.Domain.Interfaces | ||
{ | ||
public interface ILineItem | ||
{ | ||
string Name { get; } | ||
decimal GetPrice(); | ||
int GetQuantity(); | ||
decimal GetLineTax(); | ||
decimal GetTotal(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace TaxCalculation.Domain.Interfaces | ||
{ | ||
public interface IOrdersRepository | ||
{ | ||
List<Order> ReadOrders(string textFilePath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
namespace TaxCalculation.Domain.Interfaces | ||
{ | ||
public interface IRounding | ||
{ | ||
decimal Round(decimal valToRound); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace TaxCalculation.Domain.Interfaces | ||
{ | ||
public interface ITax | ||
{ | ||
IRounding Rounding { get; } | ||
decimal Rate { get; } | ||
decimal CalculateTax(decimal itemPrice); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using TaxCalculation.Domain.Interfaces; | ||
|
||
namespace TaxCalculation.Domain | ||
{ | ||
public class LineItem : ILineItem | ||
{ | ||
private string _name; | ||
private decimal _price; | ||
private int _quantity; | ||
|
||
public LineItem(string name, decimal price, int quantity) | ||
{ | ||
#region Parameter Checking | ||
if (string.IsNullOrWhiteSpace(name)) | ||
throw new ArgumentException("name"); | ||
if(price < 0) | ||
throw new ArgumentException("price"); | ||
#endregion | ||
|
||
this._name = name; | ||
this._price = price; | ||
this._quantity = quantity; | ||
|
||
} | ||
|
||
#region ILineItem Members | ||
|
||
public string Name | ||
{ | ||
get { return this._name; } | ||
} | ||
|
||
public decimal GetPrice() | ||
{ | ||
return this._price; | ||
} | ||
|
||
public int GetQuantity() | ||
{ | ||
return this._quantity; | ||
} | ||
|
||
public decimal GetLineTax() | ||
{ | ||
return 0.0M; | ||
} | ||
|
||
public decimal GetTotal() | ||
{ | ||
return this.GetPrice() + this.GetLineTax(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Oops, something went wrong.