public void WhenAdjustingTotalCostGiveExpectedResults(decimal?fundingCap, int?noOfApprenticeships, decimal?totalCost, decimal?expectedTotalCost)
        {
            ApprenticeshipCourse apprenticeshipCourse = null;

            if (fundingCap.HasValue)
            {
                apprenticeshipCourse = new ApprenticeshipCourse {
                    FundingCap = fundingCap.Value
                }
            }
            ;

            var model = new AddApprenticeshipViewModel
            {
                ApprenticeshipToAdd = new ApprenticeshipToAdd
                {
                    AppenticeshipCourse = apprenticeshipCourse,
                    ApprenticesCount    = noOfApprenticeships,
                    TotalCost           = totalCost
                }
            };


            var vm = _apprenticeshipOrchestrator.AdjustTotalCostApprenticeship(model);

            vm.ApprenticeshipToAdd.TotalCost.Should().Be(expectedTotalCost);
        }
    }
        public void WhenValidatingTheApprenticeshipWithoutCourseItShouldCallValidatorFunctions()
        {
            var vmViewModel = new AddApprenticeshipViewModel
            {
                ApprenticeshipToAdd      = _apprenticeshipToAdd,
                AvailableApprenticeships = null,
                Name = ""
            };

            vmViewModel.ApprenticeshipToAdd.CourseId            = null;
            vmViewModel.ApprenticeshipToAdd.AppenticeshipCourse = null;


            _autoMoq.GetMock <IVirtualApprenticeshipAddValidator>()
            .Setup(x => x.ValidateDetails(It.IsAny <ApprenticeshipToAdd>()))
            .Returns(_addApprenticeshipValidationDetail);

            var vm = _apprenticeshipOrchestrator.ValidateAddApprenticeship(vmViewModel);

            _autoMoq.Verify <IVirtualApprenticeshipAddValidator>(o => o.GetCleanValidationDetail(), Times.Once());
            _autoMoq.Verify <IVirtualApprenticeshipAddValidator>(o => o.ValidateDetails(It.IsAny <ApprenticeshipToAdd>()), Times.Once());
            _autoMoq.Verify <IApprenticeshipCourseService>(o => o.GetApprenticeshipCourse(It.IsAny <string>()), Times.Never());
        }
        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>();
        }