|
/*
* Created by: Maruis Marais
* Created: Saturday, 11 November 2006
*/
using NMock2;
using NUnit.Framework;
namespace BusinessRules.Evolution_Five.Tests
{
[TestFixture]
public class InvestorFixture
{
private Mockery mocks = null;
private ICurrentCultureInfo currentCulture = null;
private IIncomeTaxEngine incomeTaxEngine = null;
/// <summary>
/// The Setup method is called before each test method is called.
/// </summary>
[SetUp]
public void Setup()
{
mocks = new Mockery();
currentCulture = mocks.NewMock<ICurrentCultureInfo>();
}
[Test]
public void ValidateInvestorFromTheStates()
{
// Setup expectations for our mock.
Expect.Once.On(currentCulture).GetProperty("CurrentCultureName").Will(Return.Value("en-US"));
// Create the instance of the income tax engine
incomeTaxEngine = new IncomeTaxEngine(currentCulture);
// Create the instance of the investor
IInvestor investor = new Investor(50000.00);
investor.TaxEngine = incomeTaxEngine;
Assert.AreEqual(0.25, investor.TaxRate);
Assert.AreEqual(9057.35, investor.TaxLiability, 2.0);
investor.Income = 75895.25;
Assert.AreEqual(0.28, investor.TaxRate);
Assert.AreEqual(15581.99, investor.TaxLiability, 2.0);
}
[Test]
public void ValidateInvestorFromAustralia()
{
// Setup expectations for our mock.
Expect.Once.On(currentCulture).GetProperty("CurrentCultureName").Will(Return.Value("en-AU"));
// Create the instance of the income tax engine
incomeTaxEngine = new IncomeTaxEngine(currentCulture);
// Create the instance of the investor
IInvestor investor = new Investor(50000.00);
investor.TaxEngine = incomeTaxEngine;
Assert.AreEqual(0.30, investor.TaxRate);
Assert.AreEqual(10349.70, investor.TaxLiability, 2.0);
investor.Income = 75895.25;
Assert.AreEqual(0.40, investor.TaxRate);
Assert.AreEqual(18207.70, investor.TaxLiability, 2.0);
}
[Test]
public void ValidateInvestorFromNewZealand()
{
// Setup expectations for our mock.
Expect.Once.On(currentCulture).GetProperty("CurrentCultureName").Will(Return.Value("en-NZ"));
// Create the instance of the income tax engine
incomeTaxEngine = new IncomeTaxEngine(currentCulture);
// Create the instance of the investor
IInvestor investor = new Investor(50000.00);
investor.TaxEngine = incomeTaxEngine;
Assert.AreEqual(0.33, investor.TaxRate);
Assert.AreEqual(13867.36, investor.TaxLiability, 2.0);
investor.Income = 75895.25;
Assert.AreEqual(0.39, investor.TaxRate);
Assert.AreEqual(23366.45, investor.TaxLiability, 2.0);
}
[Test]
public void ValidateInvestorFromSouthAfrica()
{
// Setup expectations for our mock.
Expect.Once.On(currentCulture).GetProperty("CurrentCultureName").Will(Return.Value("en-ZA"));
// Create the instance of the income tax engine
incomeTaxEngine = new IncomeTaxEngine(currentCulture);
// Create the instance of the investor
IInvestor investor = new Investor(50000.00);
investor.TaxEngine = incomeTaxEngine;
Assert.AreEqual(0.0, investor.TaxRate);
Assert.AreEqual(0.0, investor.TaxLiability, 2.0);
investor.Income = 75895.25;
Assert.AreEqual(0.0, investor.TaxRate);
Assert.AreEqual(0.0, investor.TaxLiability, 2.0);
}
/// <summary>
/// The Teardown method is called after each test method is called.
/// So we validate all the expectations have been met.
/// </summary>
[TearDown]
public void Teardown()
{
mocks.VerifyAllExpectationsHaveBeenMet();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.