A Dto object to persist a single Budget Bucket
        public void TestInitialise()
        {
            AutoMapperConfigurationTest.AutoMapperConfiguration();

            SpentMonthlyExpenseBucket testData = StatementModelTestData.CarMtcBucket;
            Result = Mapper.Map<BudgetBucketDto>(testData);
        }
        public BudgetBucket BuildModel([NotNull] BudgetBucketDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }

            switch (dto.Type)
            {
            case BucketDtoType.Income:
                return(new IncomeBudgetBucket());

            case BucketDtoType.PayCreditCard:
            case BucketDtoType.Surplus:
                throw new NotSupportedException("You may not create multiple instances of the Pay Credit Card or Surplus buckets.");

            case BucketDtoType.SavedUpForExpense:
                return(new SavedUpForExpenseBucket());

            case BucketDtoType.SavingsCommitment:
                return(new SavingsCommitmentBucket());

            case BucketDtoType.SpentMonthlyExpense:
                return(new SpentMonthlyExpenseBucket());

            case BucketDtoType.FixedBudgetProject:
                var f = (FixedBudgetBucketDto)dto;
                return(new FixedBudgetProjectBucket(f.Code, f.Description, f.FixedBudgetAmount, f.Created));

            default:
                throw new NotSupportedException("Unsupported Bucket type detected: " + dto);
            }
        }
        public void TestInitialise()
        {
            this.testData = new FixedBudgetProjectBucket(FixedProjectCode, "Foo bar dum-de-dum", 1000);
            PrivateAccessor.SetProperty(this.testData, "Created", this.testDataCreatedDate);

            var subject = new Mapper_BudgetBucketDto_BudgetBucket(new BudgetBucketFactory());
            this.result = subject.ToDto(this.testData);
        }
        /// <summary>
        ///     Builds a <see cref="BudgetBucketDto" /> based on the model passed in.
        /// </summary>
        public BudgetBucketDto BuildDto(BudgetBucket bucket)
        {
            BudgetBucketDto dto;
            var fixedProjectBucket = bucket as FixedBudgetProjectBucket;
            if (fixedProjectBucket != null)
            {
                dto = new FixedBudgetBucketDto
                {
                    Created = fixedProjectBucket.Created,
                    FixedBudgetAmount = fixedProjectBucket.FixedBudgetAmount
                };
            }
            else
            {
                dto = new BudgetBucketDto();
            }

            dto.Type = SerialiseType(bucket);
            return dto;
        }
        /// <summary>
        ///     Builds a <see cref="BudgetBucketDto" /> based on the model passed in.
        /// </summary>
        public BudgetBucketDto BuildDto(BudgetBucket bucket)
        {
            BudgetBucketDto dto;
            var             fixedProjectBucket = bucket as FixedBudgetProjectBucket;

            if (fixedProjectBucket != null)
            {
                dto = new FixedBudgetBucketDto
                {
                    Created           = fixedProjectBucket.Created,
                    FixedBudgetAmount = fixedProjectBucket.FixedBudgetAmount
                };
            }
            else
            {
                dto = new BudgetBucketDto();
            }

            dto.Type = SerialiseType(bucket);
            return(dto);
        }
 public void TestInitialise()
 {
     var testData = StatementModelTestData.CarMtcBucket;
     var subject = new Mapper_BudgetBucketDto_BudgetBucket(new BudgetBucketFactory());
     Result = subject.ToDto(testData);
 }
 // ReSharper disable once RedundantAssignment
 partial void ModelFactory(BudgetBucketDto dto, ref BudgetBucket model)
 {
     model = this.bucketFactory.BuildModel(dto);
 }
 // ReSharper disable once RedundantAssignment
 partial void DtoFactory(ref BudgetBucketDto dto, BudgetBucket model)
 {
     dto = this.bucketFactory.BuildDto(model);
 }
 // ReSharper disable once RedundantAssignment
 partial void ModelFactory(BudgetBucketDto dto, ref BudgetBucket model)
 {
     model = this.bucketFactory.BuildModel(dto);
 }
 // ReSharper disable once RedundantAssignment
 partial void DtoFactory(ref BudgetBucketDto dto, BudgetBucket model)
 {
     dto = this.bucketFactory.BuildDto(model);
 }