Esempio n. 1
0
 private bool IsValueOverBudget(Money value)
 {
     if (IsPositiveBudget()) {
         return value >= Budget;
     }
     return value <= Budget;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
        public void MoneyCanBeComparedForGreaterThan()
        {
            Money money1 = new Money(2);
            Money money2 = new Money(5);

            Assert.IsTrue(money2 > money1);
            Assert.IsFalse(money1 > money2);
        }
Esempio n. 4
0
        public void MoneyCanBeCloned()
        {
            Money money1 = new Money(42);
            Money money2 = money1.Clone();

            Assert.AreEqual(money1, money2);
            Assert.AreNotSame(money1, money2);
        }
Esempio n. 5
0
        public BudgetCategory(string name, Money budget)
        {
            this.Name = name;
            this.Budget = budget.Clone();
            this.IsClosed = false;

            this.transactions = new FinancialTransactions();
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
 }
Esempio n. 14
0
 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);
 }
Esempio n. 17
0
        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)
 {
 }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
        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);
Esempio n. 26
0
        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;
 }
Esempio n. 28
0
        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;
 }