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)); }