New view for new MStest scenaroio

This commit is contained in:
2019-11-19 23:23:47 +01:00
parent 03d8cf681e
commit d0847b19d2
5 changed files with 64 additions and 12 deletions

60
BrokerageLib/Account.cs Normal file
View File

@ -0,0 +1,60 @@
using System;
namespace BrokerageLib {
public class Account {
private string _customerName;
private decimal _balance;
private bool _frozen = false;
public Account(string customerName, decimal balance) {
_customerName = customerName;
_balance = balance;
}
public string CustomerName {
get { return _customerName; }
}
public decimal Balance {
get { return _balance; }
}
public void Debit(decimal amount) {
if (amount > _balance)
{
throw new ArgumentOutOfRangeException("amount");
}
if (amount < 0)
{
throw new ArgumentOutOfRangeException("amount");
}
_balance -= amount;
}
public void Credit(decimal amount) {
if (amount < 0)
{
throw new ArgumentOutOfRangeException("amount");
}
_balance += amount;
}
private void FreezeAccount() {
_frozen = true;
}
private void UnfreezeAccount() {
_frozen = false;
}
}
}

View File

@ -40,16 +40,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Account.cs" />
<Compile Include="CommissionConstants.cs" />
<Compile Include="CommissionCalculator.cs" />
<Compile Include="PaymentDate.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Scenarios\CommisionCalcScenario.txt" />
<Content Include="Scenarios\PaymentDateScenario.txt" />
</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.

View File

@ -6,10 +6,6 @@ namespace BrokerageLib {
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.");
@ -27,7 +23,6 @@ namespace BrokerageLib {
}
else
{
return grossSale * Constants.CommissionRate.Standard;
}
}

View File

@ -16,13 +16,14 @@ namespace BrokerageLib.PaymentSystem {
/// <returns></returns>
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!
tempDate = tempDate.AddDays(3); // Error in our code here!
break;
}

View File

@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[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")]
[assembly: Guid("9b3faaaa-85bd-4278-bce5-0a2dd632c133")]
// Version information for an assembly consists of the following four values:
//