From eef116b5f6c1d0682dab318c8f6b24e762aaf25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Mon, 18 Nov 2019 16:59:38 +0100 Subject: [PATCH] Add project files. --- BrokerageLib/BrokerageLib.csproj | 61 +++++++++ BrokerageLib/CommissionCalculator.cs | 35 ++++++ BrokerageLib/CommissionConstants.cs | 21 ++++ BrokerageLib/PaymentDate.cs | 33 +++++ BrokerageLib/Properties/AssemblyInfo.cs | 36 ++++++ .../Scenarios/CommisionCalcScenario.txt | 1 + .../Scenarios/PaymentDateScenario.txt | 10 ++ StartingSolution.sln | 37 ++++++ TestRunner/App.config | 6 + TestRunner/App.xaml | 9 ++ TestRunner/App.xaml.cs | 17 +++ TestRunner/MainWindow.xaml | 18 +++ TestRunner/MainWindow.xaml.cs | 41 ++++++ TestRunner/Properties/AssemblyInfo.cs | 55 ++++++++ TestRunner/Properties/Resources.Designer.cs | 71 +++++++++++ TestRunner/Properties/Resources.resx | 117 ++++++++++++++++++ TestRunner/Properties/Settings.Designer.cs | 30 +++++ TestRunner/Properties/Settings.settings | 7 ++ TestRunner/TestRunner.csproj | 104 ++++++++++++++++ TestingLib/Assert.cs | 36 ++++++ TestingLib/TestThePaymentDate.cs | 85 +++++++++++++ TestingLib/TestingLib.csproj | 11 ++ 22 files changed, 841 insertions(+) create mode 100644 BrokerageLib/BrokerageLib.csproj create mode 100644 BrokerageLib/CommissionCalculator.cs create mode 100644 BrokerageLib/CommissionConstants.cs create mode 100644 BrokerageLib/PaymentDate.cs create mode 100644 BrokerageLib/Properties/AssemblyInfo.cs create mode 100644 BrokerageLib/Scenarios/CommisionCalcScenario.txt create mode 100644 BrokerageLib/Scenarios/PaymentDateScenario.txt create mode 100644 StartingSolution.sln create mode 100644 TestRunner/App.config create mode 100644 TestRunner/App.xaml create mode 100644 TestRunner/App.xaml.cs create mode 100644 TestRunner/MainWindow.xaml create mode 100644 TestRunner/MainWindow.xaml.cs create mode 100644 TestRunner/Properties/AssemblyInfo.cs create mode 100644 TestRunner/Properties/Resources.Designer.cs create mode 100644 TestRunner/Properties/Resources.resx create mode 100644 TestRunner/Properties/Settings.Designer.cs create mode 100644 TestRunner/Properties/Settings.settings create mode 100644 TestRunner/TestRunner.csproj create mode 100644 TestingLib/Assert.cs create mode 100644 TestingLib/TestThePaymentDate.cs create mode 100644 TestingLib/TestingLib.csproj diff --git a/BrokerageLib/BrokerageLib.csproj b/BrokerageLib/BrokerageLib.csproj new file mode 100644 index 0000000..20ff8b6 --- /dev/null +++ b/BrokerageLib/BrokerageLib.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {07F455FF-CE11-40F2-A66E-95FA497522FB} + Library + Properties + BrokerageLib + BrokerageLib + v4.6 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BrokerageLib/CommissionCalculator.cs b/BrokerageLib/CommissionCalculator.cs new file mode 100644 index 0000000..f6e53e3 --- /dev/null +++ b/BrokerageLib/CommissionCalculator.cs @@ -0,0 +1,35 @@ +using System; + +namespace BrokerageLib { + + public class CommissionCalculator { + + + public decimal DetermineVariableRate(int unitsSold, decimal unitPrice) { + + // Sales representative gets top commission rate + // if they sell over the sales threshold amount + // or if they sell more than the max unit threshold + if (unitsSold < 0) + { + throw new ArgumentOutOfRangeException("UnitsSold cannot be less than zero."); + } + + if (unitPrice < 0) + { + throw new ArgumentOutOfRangeException("unitPrice cannot be less than zero."); + } + + decimal grossSale = unitsSold * unitPrice; + if (grossSale > Constants.CommissionThreshold.SalesAmount || unitsSold > Constants.CommissionThreshold.UnitAmount) + { + return grossSale * Constants.CommissionRate.Top; + } + else + { + + return grossSale * Constants.CommissionRate.Standard; + } + } + } +} \ No newline at end of file diff --git a/BrokerageLib/CommissionConstants.cs b/BrokerageLib/CommissionConstants.cs new file mode 100644 index 0000000..ed8533e --- /dev/null +++ b/BrokerageLib/CommissionConstants.cs @@ -0,0 +1,21 @@ +namespace BrokerageLib { + + public class Constants { + + public class CommissionRate { + public const decimal Standard = 0.08m; + public const decimal Earner = 0.11m; + public const decimal Top = 0.14m; + } + + public class Discount { + public const decimal PreferredCustomer = 0.2m; + public const decimal BulkOrder = 0.5m; + } + + public class CommissionThreshold { + public const decimal SalesAmount = 12000m; + public const decimal UnitAmount = 400m; + } + } +} \ No newline at end of file diff --git a/BrokerageLib/PaymentDate.cs b/BrokerageLib/PaymentDate.cs new file mode 100644 index 0000000..d0fe1c8 --- /dev/null +++ b/BrokerageLib/PaymentDate.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BrokerageLib.PaymentSystem { + public class PaymentDate { + /// + /// Calculates a payment date 30 days in the future + /// from the provided date. + /// If the payment date is on a weekend, + /// then move it to the first work day after the + /// proposed date + /// + /// the date to use as starting date. + /// + public DateTime CalculateFuturePaymentDate(DateTime startingDate) { + var tempDate = startingDate.AddDays(30); + switch (tempDate.DayOfWeek) + { + case DayOfWeek.Saturday: + tempDate = tempDate.AddDays(2); + break; + case DayOfWeek.Sunday: + tempDate = tempDate.AddDays(1); // Error in our code here! + break; + + } + return tempDate; + + } + } +} diff --git a/BrokerageLib/Properties/AssemblyInfo.cs b/BrokerageLib/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fd830e0 --- /dev/null +++ b/BrokerageLib/Properties/AssemblyInfo.cs @@ -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("BrokerageLib")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BrokerageLib")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[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("07f455ff-ce11-40f2-a66e-95fa497522fb")] + +// 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")] diff --git a/BrokerageLib/Scenarios/CommisionCalcScenario.txt b/BrokerageLib/Scenarios/CommisionCalcScenario.txt new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/BrokerageLib/Scenarios/CommisionCalcScenario.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/BrokerageLib/Scenarios/PaymentDateScenario.txt b/BrokerageLib/Scenarios/PaymentDateScenario.txt new file mode 100644 index 0000000..8fba1fc --- /dev/null +++ b/BrokerageLib/Scenarios/PaymentDateScenario.txt @@ -0,0 +1,10 @@ +[ The Given-When-Then pattern ] +To calculate the next payment date for our customer bills + +Given a valid start date + When the future calculated payment date falls on a weekday + Then use the calculated date + +Given a valid start date + When the future calculated payment date falls on a weekend + Then use the first Monday after calculated date diff --git a/StartingSolution.sln b/StartingSolution.sln new file mode 100644 index 0000000..f3a32f6 --- /dev/null +++ b/StartingSolution.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29509.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrokerageLib", "BrokerageLib\BrokerageLib.csproj", "{07F455FF-CE11-40F2-A66E-95FA497522FB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestingLib", "TestingLib\TestingLib.csproj", "{077F4E49-2A80-463A-B2D0-805DACB80469}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestRunner", "TestRunner\TestRunner.csproj", "{65401167-7B49-4C88-AC43-F2B4A213951B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {07F455FF-CE11-40F2-A66E-95FA497522FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {07F455FF-CE11-40F2-A66E-95FA497522FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {07F455FF-CE11-40F2-A66E-95FA497522FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {07F455FF-CE11-40F2-A66E-95FA497522FB}.Release|Any CPU.Build.0 = Release|Any CPU + {077F4E49-2A80-463A-B2D0-805DACB80469}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {077F4E49-2A80-463A-B2D0-805DACB80469}.Debug|Any CPU.Build.0 = Debug|Any CPU + {077F4E49-2A80-463A-B2D0-805DACB80469}.Release|Any CPU.ActiveCfg = Release|Any CPU + {077F4E49-2A80-463A-B2D0-805DACB80469}.Release|Any CPU.Build.0 = Release|Any CPU + {65401167-7B49-4C88-AC43-F2B4A213951B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {65401167-7B49-4C88-AC43-F2B4A213951B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {65401167-7B49-4C88-AC43-F2B4A213951B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {65401167-7B49-4C88-AC43-F2B4A213951B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {06FF9609-A8E6-43CD-8D0D-A55B7459171D} + EndGlobalSection +EndGlobal diff --git a/TestRunner/App.config b/TestRunner/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/TestRunner/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TestRunner/App.xaml b/TestRunner/App.xaml new file mode 100644 index 0000000..ee4c373 --- /dev/null +++ b/TestRunner/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/TestRunner/App.xaml.cs b/TestRunner/App.xaml.cs new file mode 100644 index 0000000..cbb8e22 --- /dev/null +++ b/TestRunner/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace TestRunner +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/TestRunner/MainWindow.xaml b/TestRunner/MainWindow.xaml new file mode 100644 index 0000000..8eea329 --- /dev/null +++ b/TestRunner/MainWindow.xaml @@ -0,0 +1,18 @@ + + + + + + +