Inheritance: IBudgetBucketRepository
        public static void ConvertToDomainAndGenerateCSharp(IEnumerable<MatchingRuleDto> dataRules)
        {
            var bucketRepo = new InMemoryBudgetBucketRepository(new DtoToBudgetBucketMapper());

            var mapper = new DtoToMatchingRuleMapper();

            List<MatchingRule> domainRules = dataRules.Select(mapper.Map).ToList();

            Console.WriteLine(@"
/// <summary> THIS CODE IS GENERATED  </summary>
[GeneratedCode(""MatchingRulesTestData.ConvertToDomainAndGenerateCSharp"", ""{0}"")]
public static IEnumerable<MatchingRule> TestData999()
{{
    return new List<MatchingRule>
        {{", DateTime.Now);

            foreach (MatchingRule rule in domainRules)
            {
                Console.WriteLine(@"
            new MatchingRule(BucketRepo)");
                Console.WriteLine(@"
                {");
                Console.WriteLine(@"
                    Amount = {0},", NullDecimalOrValue(rule.Amount));
                Console.WriteLine(@"
                    BucketCode = ""{0}"",", rule.BucketCode);
                Console.WriteLine(@"
                    Created = new DateTime({0}, {1}, {2}),", rule.Created.Year, rule.Created.Month, rule.Created.Day);
                Console.WriteLine(@"
                    Description = {0},", NullStringOrQuotedValue(rule.Description));
                Console.WriteLine(@"
                    LastMatch = {0},", NullDateTimeOrValue(rule.LastMatch));
                Console.WriteLine(@"
                    MatchCount = {0},", rule.MatchCount);
                Console.WriteLine(@"
                    Reference1 = {0},", NullStringOrQuotedValue(rule.Reference1));
                Console.WriteLine(@"
                    Reference2 = {0},", NullStringOrQuotedValue(rule.Reference2));
                Console.WriteLine(@"
                    Reference3 = {0},", NullStringOrQuotedValue(rule.Reference3));
                Console.WriteLine(@"
                    RuleId = new Guid(""{0}""),", rule.RuleId);
                Console.WriteLine(@"
                    TransactionType = {0},", NullStringOrQuotedValue(rule.TransactionType));


                Console.WriteLine(@"
                },"); // Close new Rule initialiser
            }


            Console.WriteLine(@"
        };"); // Close new List Initialiser
            Console.WriteLine(@"
    }"); // Close Method
        }
        public void SaveShouldWriteOutBuckets()
        {
            var bucketRepo = new InMemoryBudgetBucketRepository(new DtoToBudgetBucketMapper());
            var subject = new XamlOnDiskBudgetRepositoryTestHarness(bucketRepo);

            string savedData = null;
            subject.WriteToDiskMock = (filename, data) => { savedData = data; };
            subject.FileExistsMock = f => true;
            subject.LoadFromDiskMock = OnLoadFromDiskMock;

            BudgetCollection collection = subject.Load(DemoBudgetFileName);
            subject.Save(collection);

            XNamespace ns = "clr-namespace:BudgetAnalyser.Engine.Budget.Data;assembly=BudgetAnalyser.Engine";
            XDocument document = XDocument.Parse(savedData);
            IEnumerable<XElement> bucketCollectionElements = document.Descendants(ns + "BudgetBucketDto");
            foreach (XElement element in bucketCollectionElements)
            {
                Console.WriteLine(element.FirstAttribute);
            }

            Assert.AreEqual(10, bucketCollectionElements.Count());
        }
        private XamlOnDiskBudgetRepositoryTestHarness Arrange(IBudgetBucketRepository bucketRepo = null)
        {
            if (bucketRepo == null)
            {
                bucketRepo = new InMemoryBudgetBucketRepository(new DtoToBudgetBucketMapper());
            }

            return new XamlOnDiskBudgetRepositoryTestHarness(bucketRepo);
        }
        private XamlOnDiskBudgetRepository Arrange(IBudgetBucketRepository bucketRepo = null)
        {
            if (bucketRepo == null)
            {
                bucketRepo = new InMemoryBudgetBucketRepository(new Mapper_BudgetBucketDto_BudgetBucket(new BudgetBucketFactory()));
            }

            return new XamlOnDiskBudgetRepository(
                bucketRepo,
                new Mapper_BudgetCollectionDto_BudgetCollection(
                    bucketRepo,
                    new Mapper_BudgetBucketDto_BudgetBucket(new BudgetBucketFactory()),
                    new Mapper_BudgetModelDto_BudgetModel(bucketRepo)),
                this.mockFileSelector.Object);
        }