public void SetUp()
        {
            _testApprenticeship = new Apprenticeship
            {
                FirstName     = "John",
                LastName      = "Smith",
                DateOfBirth   = new DateTime(1988, 4, 5),
                PaymentStatus = PaymentStatus.Active,
                StartDate     = DateTime.UtcNow.AddMonths(1) // Default start date a month in the future.
            };

            _mockMediator             = new Mock <IMediator>();
            _mockDateTime             = new Mock <ICurrentDateTime>();
            _mockApprenticeshipMapper = new ApprenticeshipMapper(Mock.Of <IHashingService>(), _mockDateTime.Object, _mockMediator.Object);

            _cookieStorageService = new Mock <ICookieStorageService <UpdateApprenticeshipViewModel> >();

            _mockMediator.Setup(m => m.SendAsync(It.IsAny <GetApprenticeshipQueryRequest>()))
            .ReturnsAsync(new GetApprenticeshipQueryResponse
            {
                Apprenticeship = _testApprenticeship
            });

            _sut = new EmployerManageApprenticeshipsOrchestrator(
                _mockMediator.Object,
                Mock.Of <IHashingService>(),
                _mockApprenticeshipMapper,
                new ApprovedApprenticeshipViewModelValidator(),
                new CurrentDateTime(),
                Mock.Of <ILogger>(),
                _cookieStorageService.Object);
        }
Пример #2
0
        public void SetUp()
        {
            _mockValidator = new Mock <IValidateApprovedApprenticeship>();
            _mockValidator.Setup(m => m.MapOverlappingErrors(It.IsAny <GetOverlappingApprenticeshipsQueryResponse>()))
            .Returns(new Dictionary <string, string>());
            _mockMapper = new Mock <IApprenticeshipMapper>();

            _mockValidator.Setup(m => m.ValidateToDictionary(It.IsAny <ApprenticeshipViewModel>()))
            .Returns(new Dictionary <string, string>());

            _mockValidator.Setup(m => m.ValidateAcademicYear(It.IsAny <UpdateApprenticeshipViewModel>()))
            .Returns(new Dictionary <string, string>());

            MockMediator.Setup(m => m.SendAsync(It.IsAny <GetOverlappingApprenticeshipsQueryRequest>()))
            .ReturnsAsync(new GetOverlappingApprenticeshipsQueryResponse {
                Overlaps = new List <ApprenticeshipOverlapValidationResult>()
            });

            var academicYearDateProvider = Mock.Of <IAcademicYearDateProvider>();

            Orchestrator = new EmployerManageApprenticeshipsOrchestrator(
                MockMediator.Object,
                Mock.Of <IHashingService>(),
                _mockMapper.Object,
                _mockValidator.Object,
                _currentDateTime.Object,
                new Mock <ILog>().Object,
                new Mock <ICookieStorageService <UpdateApprenticeshipViewModel> >().Object,
                academicYearDateProvider,
                new AcademicYearValidator(_currentDateTime.Object, academicYearDateProvider),
                MockLinkGenerator.Object);
        }
Пример #3
0
        public new void Setup()
        {
            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetApprenticeshipQueryRequest>()))
            .ReturnsAsync(new GetApprenticeshipQueryResponse
            {
                Apprenticeship = new Apprenticeship()
                {
                    StartDate = DateTime.Now
                }
            });

            _apprenticeshipMapper = new Mock <IApprenticeshipMapper>();

            _apprenticeshipMapper
            .Setup(x => x.MapToEditApprenticeshipStopDateViewModel(It.IsAny <Apprenticeship>()))
            .Returns(new EditApprenticeshipStopDateViewModel());

            Orchestrator = new EmployerManageApprenticeshipsOrchestrator(
                MockMediator.Object,
                MockHashingService.Object,
                _apprenticeshipMapper.Object,
                Validator,
                MockDateTime.Object,
                new Mock <ILog>().Object,
                new Mock <ICookieStorageService <UpdateApprenticeshipViewModel> >().Object,
                AcademicYearDateProvider.Object,
                AcademicYearValidator,
                MockLinkGenerator.Object);

            MockHashingService.Setup(x => x.DecodeValue(HashedApprenticeshipId)).Returns(ApprenticeshipId);
            MockHashingService.Setup(x => x.DecodeValue(HashedAccountId)).Returns(AccountId);
        }
        public EmployerManageApprenticesController(
            EmployerManageApprenticeshipsOrchestrator orchestrator,
            IOwinWrapper owinWrapper,
            IFeatureToggle featureToggle,
            IMultiVariantTestingService multiVariantTestingService,
            ICookieStorageService <FlashMessageViewModel> flashMessage)
            : base(owinWrapper, featureToggle, multiVariantTestingService, flashMessage)
        {
            if (orchestrator == null)
            {
                throw new ArgumentNullException(nameof(orchestrator));
            }

            _orchestrator = orchestrator;
        }
        public void Arrange()
        {
            _mediator             = new Mock <IMediator>();
            _hashingService       = new Mock <IHashingService>();
            _apprenticeshipMapper = new Mock <IApprenticeshipMapper>();
            _logger = new Mock <ILogger>();
            _cookieStorageService = new Mock <ICookieStorageService <UpdateApprenticeshipViewModel> >();

            _orchestrator = new EmployerManageApprenticeshipsOrchestrator(
                _mediator.Object,
                _hashingService.Object,
                _apprenticeshipMapper.Object,
                new ApprovedApprenticeshipViewModelValidator(),
                new CurrentDateTime(),
                _logger.Object,
                _cookieStorageService.Object);
        }
        public void SetUp()
        {
            _mockMediator = new Mock <IMediator>();
            _mockDateTime = new Mock <ICurrentDateTime>();

            _cookieStorageService = new Mock <ICookieStorageService <UpdateApprenticeshipViewModel> >();

            _apprenticeshipMapper = new ApprenticeshipMapper(Mock.Of <IHashingService>(), _mockDateTime.Object, _mockMediator.Object);

            _orchestrator = new EmployerManageApprenticeshipsOrchestrator(
                _mockMediator.Object,
                Mock.Of <IHashingService>(),
                _apprenticeshipMapper,
                Mock.Of <ApprovedApprenticeshipViewModelValidator>(),
                new CurrentDateTime(),
                Mock.Of <ILogger>(),
                _cookieStorageService.Object);
        }
        public void Setup()
        {
            MockAcademicYearValidator = new Mock <IAcademicYearValidator>();
            MockMediator = new Mock <IMediator>();

            MockDateTime = new Mock <ICurrentDateTime>();
            MockDateTime.Setup(x => x.Now).Returns(DateTime.UtcNow);

            MockLinkGenerator = new Mock <ILinkGenerator>();
            MockLinkGenerator
            .Setup(x => x.FinanceLink($"accounts/{HashedAccountId}/finance/{MockDateTime.Object.Now.Year}/{MockDateTime.Object.Now.Month}"))
            .Returns("testLink");

            AcademicYearDateProvider = new Mock <IAcademicYearDateProvider>();
            AcademicYearDateProvider.Setup(x => x.CurrentAcademicYearStartDate).Returns(new DateTime(2017, 8, 1));
            AcademicYearDateProvider.Setup(x => x.CurrentAcademicYearEndDate).Returns(new DateTime(2018, 7, 31));
            AcademicYearDateProvider.Setup(x => x.LastAcademicYearFundingPeriod).Returns(new DateTime(2017, 10, 19, 18, 0, 0));

            MockChangeOfProviderToggle = new Mock <IFeatureToggle>();
            MockChangeOfProviderToggle.Setup(c => c.FeatureEnabled).Returns(true);

            MockFeatureToggleService = new Mock <IFeatureToggleService>();
            MockFeatureToggleService.Setup(f => f.Get <ChangeOfProvider>()).Returns(MockChangeOfProviderToggle.Object);

            ApprenticeshipMapper = new ApprenticeshipMapper(Mock.Of <IHashingService>(), MockDateTime.Object,
                                                            MockMediator.Object, Mock.Of <ILog>(), Mock.Of <IAcademicYearValidator>(),
                                                            Mock.Of <IAcademicYearDateProvider>(), MockLinkGenerator.Object, MockFeatureToggleService.Object);

            MockHashingService = new Mock <IHashingService>();
            MockHashingService.Setup(x => x.DecodeValue("ABC123")).Returns(123L);
            MockHashingService.Setup(x => x.DecodeValue("ABC321")).Returns(321L);
            MockHashingService.Setup(x => x.DecodeValue("ABC456")).Returns(456L);

            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetUserAccountRoleQuery>()))
            .ReturnsAsync(new GetUserAccountRoleResponse
            {
                User = new TeamMember()
                {
                    AccountId = AccountId, HashedAccountId = HashedAccountId, Email = Email, Name = Name
                }
            });

            var academicYearProvider = new AcademicYearDateProvider(MockDateTime.Object);

            Validator = new ApprovedApprenticeshipViewModelValidator(
                new WebApprenticeshipValidationText(academicYearProvider),
                academicYearProvider,
                new AcademicYearValidator(MockDateTime.Object, academicYearProvider),
                MockDateTime.Object,
                Mock.Of <IMediator>());

            AcademicYearValidator = new AcademicYearValidator(MockDateTime.Object, academicYearProvider);

            Orchestrator = new EmployerManageApprenticeshipsOrchestrator(
                MockMediator.Object,
                MockHashingService.Object,
                ApprenticeshipMapper,
                Validator,
                MockDateTime.Object,
                new Mock <ILog>().Object,
                new Mock <ICookieStorageService <UpdateApprenticeshipViewModel> >().Object,
                AcademicYearDateProvider.Object,
                AcademicYearValidator,
                MockLinkGenerator.Object);
        }