private bool IsValueOverBudget(Money value) { if (IsPositiveBudget()) { return value >= Budget; } return value <= Budget; }
public BudgetCategory(string name, Money budget, bool isClosed, FinancialTransactions transactions) : this(name, budget) { foreach (FinancialTransaction transaction in transactions) { this.transactions.Add(transaction.Clone()); } this.IsClosed = isClosed; }
public void MoneyCanBeComparedForGreaterThan() { Money money1 = new Money(2); Money money2 = new Money(5); Assert.IsTrue(money2 > money1); Assert.IsFalse(money1 > money2); }
public void MoneyCanBeCloned() { Money money1 = new Money(42); Money money2 = money1.Clone(); Assert.AreEqual(money1, money2); Assert.AreNotSame(money1, money2); }
public BudgetCategory(string name, Money budget) { this.Name = name; this.Budget = budget.Clone(); this.IsClosed = false; this.transactions = new FinancialTransactions(); }
public void MoneyCanBeComparedForGreaterOrEquality() { Money money1 = new Money(2); Money money2 = new Money(5); Money money3 = new Money(5); Assert.IsTrue(money2 >= money3); Assert.IsTrue(money3 >= money1); }
public void MoneyCanBeComparedForLessOrEquality() { Money money1 = new Money(2); Money money2 = new Money(5); Money money3 = new Money(5); Assert.IsTrue(money2 <= money3); Assert.IsTrue(money1 <= money3); }
public void MoneyCanBeComparedForEquality() { Money money1 = new Money(2); Money money2 = new Money(5); Money money3 = new Money(5); Assert.IsTrue(money2 == money3); Assert.AreNotSame(money2, money3); Assert.IsFalse(money1 == money2); }
public void MoneyCanBeAddedWithOperator() { Money money1 = new Money(2); Money money2 = new Money(5); Money money3 = money1 + money2; Assert.AreEqual(new Money(7), money3); Assert.AreNotSame(money1, money3); Assert.AreNotSame(money2, money3); }
public void MoneyCanBeAdded() { Money money1 = new Money(2); Money money2 = new Money(5); Money money3 = money1.Add(money2); Assert.AreEqual(new Money(7), money3); Assert.AreNotSame(money1, money3); Assert.AreNotSame(money2, money3); }
public void MoneyCanBeMultiplied() { Money money = new Money(2); Assert.AreEqual(3 * 2, money.MultiplyBy(3).Value); money = new Money(42); Assert.AreEqual(42 * 42, money.MultiplyBy(42).Value); }
public FinancialTransaction(DateTime date, Money value) { this.Value = value.Clone(); this.Date = date; }
protected override FinancialTransaction Create(DateTime date, Money value) { return new DepositTransaction(date, value); }
public void SetUp() { Money initialBalance = new Money(100); DateTime initialDate = new DateTime(2012, 1, 1); account = new Account(initialDate, initialBalance); }
private void AssertValueIs(Money value) { Assert.AreEqual(value, budgetEntry.GetValue((Month)DateTime.Today.Month, DateTime.Today.Year)); }
public void SetUp() { name = "TestEntry"; budget = TEST_VALUE * factor; budgetEntry = new BudgetCategory(name, budget); }
public void MoneyCanBeComparedForLessThan() { Money money1 = new Money(2); Money money2 = new Money(5); Assert.IsTrue(money1 < money2); Assert.IsFalse(money2 < money1); }
public abstract Money apply(Money value);
public FinancialTransaction SetValue(Money value) { return Create(this.Date, value); }
public WithdrawTransaction(DateTime date, Money value) : base(date, value) { }
public void MoneyCanBeMultipliedWithOperator() { Money money = new Money(2); Assert.AreEqual(new Money(3 * 2), 3 * money); Assert.AreEqual(new Money(3 * 2), money * 3); money = new Money(42); Assert.AreEqual(new Money(42 * 42), 42 * money); Assert.AreEqual(new Money(42 * 42), money * 42); }
public void MoneyCanBeSubtracted() { Money money1 = new Money(5); Money money2 = new Money(3); Money money3 = money1.Subtract(money2); Assert.AreEqual(new Money(2), money3); Assert.AreNotSame(money1, money3); Assert.AreNotSame(money2, money3); }
public void MoneyCanBeComparedForNotEquality() { Money money1 = new Money(2); Money money2 = new Money(5); Money money3 = new Money(5); Assert.IsTrue(money1 != money3); Assert.IsTrue(money1 != money2); Assert.IsFalse(money2 != money3); }
public void MoneyCanBeSubtractedWithOperator() { Money money1 = new Money(5); Money money2 = new Money(3); Money money3 = money1 - money2; Assert.AreEqual(new Money(2), money3); Assert.AreNotSame(money1, money3); Assert.AreNotSame(money2, money3); }
protected abstract FinancialTransaction CreateTransaction(DateTime date, Money value);
public void MoneyWithDifferentAmountShouldNotBeEqual() { Money money1 = new Money(100); Money money2 = new Money(200); Assert.IsFalse(money1.Equals(money2)); }
public BudgetCategoryTestsBase(int factor) { this.factor = factor; this.TEST_VALUE_TIMES_3 = TEST_VALUE * factor * 3; }
public void MoneyWithEqualAmountShouldBeEqual() { Money money1 = new Money(100); Money money2 = new Money(100); Assert.IsTrue(money1.Equals(money2)); }
protected override FinancialTransaction CreateTransaction(DateTime date, Money value) { return new WithdrawTransaction(date, value); }
public override Money apply(Money value) { return value + this.Value; }