public void Setup()
        {
            _autoMoq = new AutoMoqer();

            var _model = new AccountEstimationModel
            {
                Id = Guid.NewGuid().ToString("N"),
                Apprenticeships   = new List <VirtualApprenticeship>(),
                EmployerAccountId = AccountId,
                EstimationName    = "default"
            };

            var p = _autoMoq.GetMock <IAccountEstimationProjection>();

            p.Setup(x => x.BuildProjections()).Verifiable();


            IList <AccountProjectionReadModel> projectionModel = new List <AccountProjectionReadModel>
            {
                new AccountProjectionReadModel
                {
                    EmployerAccountId = 10000,
                    Month             = 4,
                    Year                = 2018,
                    FutureFunds         = 15000m,
                    TotalCostOfTraining = 0m
                }
            };

            p.Setup(o => o.Projections)
            .Returns(new ReadOnlyCollection <AccountProjectionReadModel>(projectionModel));

            _autoMoq.SetInstance(_model);

            _autoMoq.GetMock <IHashingService>()
            .Setup(o => o.DecodeValue(HashedAccountId))
            .Returns(AccountId);

            _autoMoq.GetMock <IAccountEstimationRepository>()
            .Setup(x => x.Get(It.IsAny <long>()))
            .Returns(Task.FromResult(_autoMoq.Resolve <AccountEstimation>()));

            _autoMoq.GetMock <IAccountEstimationProjectionRepository>()
            .Setup(x => x.Get(It.IsAny <AccountEstimation>()))
            .Returns(Task.FromResult(p.Object));

            _estimationOrchestrator = _autoMoq.Resolve <EstimationOrchestrator>();
        }
예제 #2
0
 public void SetUp()
 {
     _moqer = new AutoMoqer();
     _model = new AccountEstimationModel
     {
         Id = Guid.NewGuid().ToString("N"),
         Apprenticeships   = new List <VirtualApprenticeship>(),
         EmployerAccountId = 12345,
         EstimationName    = "default"
     };
     _moqer.SetInstance(_model);
     _moqer.GetMock <IVirtualApprenticeshipValidator>()
     .Setup(x => x.Validate(It.IsAny <VirtualApprenticeship>()))
     .Returns(new List <ValidationResult>());
     _moqer.GetMock <IAccountEstimationRepository>()
     .Setup(x => x.Get(It.IsAny <long>()))
     .Returns(Task.FromResult(_moqer.Resolve <AccountEstimation>()));
     _moqer.GetMock <IDateTimeService>()
     .Setup(x => x.GetCurrentDateTime())
     .Returns(new DateTimeService().GetCurrentDateTime());
 }
예제 #3
0
        public async Task UpsertApprenticeshipModel(IEnumerable <TestApprenticeship> apprenticeships)
        {
            var vas = apprenticeships.Select(m =>
            {
                return(new VirtualApprenticeship
                {
                    Id = Guid.NewGuid().ToString("N"),
                    ApprenticesCount = m.NumberOfApprentices,
                    CourseId = "rockstar-999",
                    CourseTitle = m.Apprenticeship,
                    Level = 3,
                    StartDate = DateTime.Parse($"{m.StartDateYear}-{m.NumberOfMonths}-1"),
                    TotalCost = int.Parse(m.TotalCost),
                    TotalCompletionAmount = 800,
                    TotalInstallments = m.NumberOfMonths,
                    TotalInstallmentAmount = 700,
                    FundingSource = m.FundingSource == "Levy" ? Models.Payments.FundingSource.Levy : Models.Payments.FundingSource.Transfer
                });
            });

            var model = new AccountEstimationModel
            {
                Id                = "12345",
                EstimationName    = "default",
                EmployerAccountId = 12345,
                Apprenticeships   = vas.ToList()
            };

            var document = new
            {
                id       = $"{nameof(AccountEstimationModel)}-{model.Id}",
                type     = $"{typeof(AccountEstimationModel)}",
                Document = model
            };

            await Run(async (c, dc) =>
            {
                await c.UpsertDocumentAsync(dc.SelfLink, document);
            });
        }
        // Private


        private async Task UpsertApprenticeshipModel()
        {
            var model = new AccountEstimationModel
            {
                Id                = "12345",
                EstimationName    = "default",
                EmployerAccountId = 12345,
                Apprenticeships   = new List <VirtualApprenticeship>
                {
                    new VirtualApprenticeship
                    {
                        Id = Guid.NewGuid().ToString("N"),
                        ApprenticesCount       = 2,
                        CourseId               = "rockstar-999",
                        CourseTitle            = "Rockstar Developer",
                        Level                  = 3,
                        StartDate              = new DateTime(DateTime.Now.Year + 1, 2, 1),
                        TotalCost              = 10000,
                        TotalCompletionAmount  = 800,
                        TotalInstallments      = 24,
                        TotalInstallmentAmount = 700,
                        FundingSource          = Models.Payments.FundingSource.Transfer
                    }
                }
            };

            var document = new
            {
                id       = $"{nameof(AccountEstimationModel)}-{model.Id}",
                type     = $"{typeof(AccountEstimationModel)}",
                Document = model
            };

            await Run(async (c, dc) =>
            {
                await c.UpsertDocumentAsync(dc.SelfLink, document);
            });
        }
예제 #5
0
 public AccountEstimation(AccountEstimationModel model, IVirtualApprenticeshipValidator validator, IDateTimeService dateTimeService)
 {
     Model            = model ?? throw new ArgumentNullException(nameof(model));
     _validator       = validator ?? throw new ArgumentNullException(nameof(validator));
     _dateTimeService = dateTimeService;
 }
예제 #6
0
 public async Task Store(AccountEstimationModel model)
 {
     await _documentSession.Store(model);
 }
        public void Setup()
        {
            _autoMoq = new AutoMoqer();

            var model = new AccountEstimationModel
            {
                Id = Guid.NewGuid().ToString("N"),
                Apprenticeships = new List <VirtualApprenticeship>
                {
                    new VirtualApprenticeship
                    {
                        Id               = VirtualApprenticeshipId,
                        CourseTitle      = "Wood work",
                        Level            = 2,
                        ApprenticesCount = 5
                    }
                },
                EmployerAccountId = AccountId,
                EstimationName    = "default"
            };

            _autoMoq.SetInstance(model);

            _courseTitle = "Seafaring Level 2";
            _level       = 2;
            _courseId    = "ABC";
            _totalCost   = 1234;

            _addApprenticeshipValidationDetail = new AddApprenticeshipValidationDetail();

            _apprenticeshipCourses = new List <ApprenticeshipCourse>
            {
                new ApprenticeshipCourse
                {
                    Duration   = 12,
                    FundingCap = 7000,
                    Id         = _courseId,
                    Level      = _level,
                    Title      = _courseTitle
                }
            };

            _apprenticesCount = 5;
            _numberOfMonths   = 12;
            _startYear        = DateTime.Now.Year;
            _startMonth       = 12;


            _apprenticeshipCourse = new ApprenticeshipCourse {
                Id = _courseId, Title = _courseTitle, Level = _level
            };
            _apprenticeshipToAdd = new ApprenticeshipToAdd
            {
                ApprenticesCount    = _apprenticesCount,
                NumberOfMonths      = _numberOfMonths,
                StartYear           = _startYear,
                StartMonth          = _startMonth,
                TotalCost           = _totalCost,
                AppenticeshipCourse = _apprenticeshipCourse,
                CourseId            = _courseId
            };

            _addApprenticeshipViewModel = new AddApprenticeshipViewModel
            {
                ApprenticeshipToAdd      = _apprenticeshipToAdd,
                AvailableApprenticeships = null,
                Name = ""
            };

            _autoMoq.GetMock <IHashingService>()
            .Setup(o => o.DecodeValue(HashedAccountId))
            .Returns(AccountId);

            _autoMoq.GetMock <IAccountEstimationRepository>()
            .Setup(x => x.Get(It.IsAny <long>()))
            .Returns(Task.FromResult(_autoMoq.Resolve <AccountEstimation>()));

            _autoMoq.GetMock <IApprenticeshipCourseService>()
            .Setup(x => x.GetApprenticeshipCourses())
            .Returns(_apprenticeshipCourses);

            _autoMoq.GetMock <IApprenticeshipCourseService>()
            .Setup(x => x.GetApprenticeshipCourse(_courseId))
            .Returns(_apprenticeshipCourse);

            _autoMoq.GetMock <IVirtualApprenticeshipAddValidator>()
            .Setup(x => x.GetCleanValidationDetail())
            .Returns(_addApprenticeshipValidationDetail);


            _apprenticeshipOrchestrator = _autoMoq.Resolve <ApprenticeshipOrchestrator>();
        }