예제 #1
0
        private StatementViewModel Arrange()
        {
            StatementViewModel subject = CreateSubject().Initialise(this.mockTransactionService.Object);

            subject.Statement = StatementModelTestData.TestData1();
            return(subject);
        }
예제 #2
0
        public void SetStatement_ShouldThrow_GivenInitialiseHasNotBeenCalled()
        {
            StatementViewModel subject = CreateSubject();

            subject.Statement = StatementModelTestData.TestData1();
            Assert.Fail();
        }
        public void Match_ShouldRemoveSingleUseRulesThatWereUsed()
        {
            IEnumerable <Transaction> testTransactions = StatementModelTestData.TestData1().Transactions;
            var testMatchingRules = new List <MatchingRule>
            {
                new SingleUseMatchingRule(this.mockBucketRepo)
                {
                    Amount     = -95.15M,
                    And        = true,
                    BucketCode = StatementModelTestData.PhoneBucket.Code,
                    Reference1 = "skjghjkh",
                    MatchCount = 1 // Artificially set to simulate a match
                },
                new MatchingRule(this.mockBucketRepo)
                {
                    Amount     = -11.11M,
                    BucketCode = StatementModelTestData.CarMtcBucket.Code
                }
            };

            this.mockMatchMaker.Setup(m => m.Match(testTransactions, testMatchingRules)).Returns(true);
            this.mockBucketRepo.GetOrCreateNew(TestDataConstants.PowerBucketCode, () => new SpentMonthlyExpenseBucket(TestDataConstants.PowerBucketCode, "Foo"));
            this.mockBucketRepo.GetOrCreateNew(TestDataConstants.PhoneBucketCode, () => new SpentMonthlyExpenseBucket(TestDataConstants.PhoneBucketCode, "Foo"));
            PrivateAccessor.InvokeMethod(this.subject, "InitialiseTheRulesCollections", testMatchingRules);
            PrivateAccessor.SetField <TransactionRuleService>(this.subject, "rulesStorageKey", "lksjgjklshgjkls");

            var success = this.subject.Match(testTransactions);

            Assert.IsTrue(success);
            Assert.IsFalse(this.subject.MatchingRules.Any(r => r is SingleUseMatchingRule));
        }
예제 #4
0
        public void PerformanceOfValidateTest()
        {
            StatementModel subject   = StatementModelTestData.TestData1();
            Stopwatch      stopwatch = Stopwatch.StartNew();

            subject.ValidateAgainstDuplicates();
            stopwatch.Stop();
            Console.WriteLine("{0:N0} ms", stopwatch.ElapsedMilliseconds);
            Assert.IsTrue(stopwatch.ElapsedMilliseconds < 250);
        }
 public void TestInitialise()
 {
     this.testDataBudget    = BudgetModelTestData.CreateTestData1();
     this.testDataStatement = StatementModelTestData.TestData1();
     this.subject           = LedgerBookTestData.TestData1();
 }
예제 #6
0
 public void CalculateOverSpentLedgersShouldThrowGivenNullLedger()
 {
     Subject.CalculateOverspentLedgers(StatementModelTestData.TestData1(), null, new DateTime(2014, 07, 01));
     Assert.Fail();
 }
예제 #7
0
        public void CalculateOverSpentLedgersShouldReturnEmptyGivenNoLedgerLineForGivenDate()
        {
            IEnumerable <ReportTransaction> result = Subject.CalculateOverspentLedgers(StatementModelTestData.TestData1(), TestData, new DateTime(2014, 07, 01));

            Assert.IsTrue(result.Count() == 0);
        }
예제 #8
0
        private TransactionGroupedByBucket Arrange()
        {
            StatementModel statementModel = StatementModelTestData.TestData1();

            return(new TransactionGroupedByBucket(statementModel.AllTransactions, StatementModelTestData.PowerBucket));
        }