public void DictionaryTest() { LedgerBucket instance1 = LedgerBookTestData.HairLedger; var dictionary = new Dictionary<LedgerBucket, LedgerBucket> { { instance1, instance1 } }; LedgerBucket instance2 = new SavedUpForLedger { BudgetBucket = StatementModelTestData.HairBucket, StoredInAccount = LedgerBookTestData.ChequeAccount }; // Should already contain this, its the same code. Assert.IsTrue(dictionary.ContainsKey(instance2)); LedgerBucket instance3 = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket("HAIRCUT", "Foo bar"), StoredInAccount = LedgerBookTestData.ChequeAccount }; Assert.IsTrue(dictionary.ContainsKey(instance3)); }
public void TwoInstancesWithSameBucketAndAccountAreEqual() { var instance1 = new SavedUpForLedger { BudgetBucket = StatementModelTestData.CarMtcBucket, StoredInAccount = StatementModelTestData.SavingsAccount }; var instance2 = new SavedUpForLedger { BudgetBucket = StatementModelTestData.CarMtcBucket, StoredInAccount = StatementModelTestData.SavingsAccount }; Assert.AreEqual(instance1, instance2); Assert.IsTrue(instance1 == instance2); }
public void IsValid_ShouldBeFalse_GivenLedgersAreTheSame() { var ledger = new SavedUpForLedger { BudgetBucket = StatementModelTestData.InsHomeBucket, StoredInAccount = StatementModelTestData.ChequeAccount }; this.subject = new TransferFundsCommand { FromLedger = ledger, ToLedger = ledger, Narrative = "Foo", TransferAmount = 1 }; Assert.IsFalse(this.subject.IsValid()); }
static LedgerBookTestData() { ChequeAccount = StatementModelTestData.ChequeAccount; SavingsAccount = StatementModelTestData.SavingsAccount; RatesLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket(TestDataConstants.RatesBucketCode, "Rates "), StoredInAccount = ChequeAccount }; PowerLedger = new SpentMonthlyLedger { BudgetBucket = new SpentMonthlyExpenseBucket(TestDataConstants.PowerBucketCode, "Power "), StoredInAccount = ChequeAccount }; PhoneLedger = new SpentMonthlyLedger { BudgetBucket = new SpentMonthlyExpenseBucket(TestDataConstants.PhoneBucketCode, "Poo bar"), StoredInAccount = ChequeAccount }; WaterLedger = new SpentMonthlyLedger { BudgetBucket = new SpentMonthlyExpenseBucket(TestDataConstants.WaterBucketCode, "Poo bar"), StoredInAccount = ChequeAccount }; HouseInsLedger = new SpentMonthlyLedger { BudgetBucket = new SpentMonthlyExpenseBucket(TestDataConstants.InsuranceHomeBucketCode, "Poo bar"), StoredInAccount = ChequeAccount }; HouseInsLedgerSavingsAccount = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket(TestDataConstants.InsuranceHomeBucketCode, "Poo bar"), StoredInAccount = SavingsAccount }; CarInsLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket("INSCAR", "Poo bar"), StoredInAccount = ChequeAccount }; LifeInsLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket("INSLIFE", "Poo bar"), StoredInAccount = ChequeAccount }; CarMtcLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket(TestDataConstants.CarMtcBucketCode, "Poo bar"), StoredInAccount = ChequeAccount }; RegoLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket(TestDataConstants.RegoBucketCode, ""), StoredInAccount = ChequeAccount }; HairLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket(TestDataConstants.HairBucketCode, "Hair cuts wheelbarrow."), StoredInAccount = ChequeAccount }; ClothesLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket("CLOTHES", ""), StoredInAccount = ChequeAccount }; DocLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket(TestDataConstants.DoctorBucketCode, ""), StoredInAccount = ChequeAccount }; SurplusLedger = new SurplusLedger { StoredInAccount = ChequeAccount }; SavingsSurplusLedger = new SurplusLedger { StoredInAccount = SavingsAccount }; SavingsLedger = new SavedUpForLedger { BudgetBucket = new SavedUpForExpenseBucket(TestDataConstants.SavingsBucketCode, "Savings"), StoredInAccount = ChequeAccount }; }
public void TwoInstancesWithSameBucketAndNullAccountHaveTheSameHashCode() { var instance1 = new SavedUpForLedger { BudgetBucket = StatementModelTestData.CarMtcBucket, StoredInAccount = null }; var instance2 = new SavedUpForLedger { BudgetBucket = StatementModelTestData.CarMtcBucket, StoredInAccount = null }; Assert.AreEqual(instance1.GetHashCode(), instance2.GetHashCode()); }