コード例 #1
0
        public void SetUp()
        {
            _mockApprenticeshipEvents     = new Mock <IApprenticeshipEvents>();
            _mockCommitmentRespository    = new Mock <ICommitmentRepository>();
            _mockApprenticeshipRepository = new Mock <IApprenticeshipRepository>();
            _mockHistoryRepository        = new Mock <IHistoryRepository>();
            _mockUlnValidator             = new Mock <IUlnValidator>();
            _mockAcademicYearValidator    = new Mock <IAcademicYearValidator>();

            var validator = new CreateApprenticeshipValidator(new ApprenticeshipValidator(new StubCurrentDateTime(), _mockUlnValidator.Object, _mockAcademicYearValidator.Object));

            _handler = new CreateApprenticeshipCommandHandler(
                _mockCommitmentRespository.Object,
                _mockApprenticeshipRepository.Object,
                validator,
                _mockApprenticeshipEvents.Object,
                Mock.Of <ICommitmentsLogger>(),
                _mockHistoryRepository.Object);

            var fixture = new Fixture();
            var populatedApprenticeship = fixture.Build <Apprenticeship>()
                                          .With(x => x.ULN, "1234567890")
                                          .With(x => x.ULN, ApprenticeshipTestDataHelper.CreateValidULN())
                                          .With(x => x.NINumber, ApprenticeshipTestDataHelper.CreateValidNino())
                                          .With(x => x.FirstName, "First name")
                                          .With(x => x.FirstName, "Last name")
                                          .With(x => x.ProviderRef, "Provider ref")
                                          .With(x => x.EmployerRef, null)
                                          .With(x => x.StartDate, DateTime.Now.AddYears(5))
                                          .With(x => x.EndDate, DateTime.Now.AddYears(7))
                                          .With(x => x.DateOfBirth, DateTime.Now.AddYears(-16))
                                          .With(x => x.TrainingCode, string.Empty)
                                          .With(x => x.TrainingName, string.Empty)
                                          .Create();

            _mockApprenticeshipRepository.Setup(m => m.GetApprenticeship(It.IsAny <long>()))
            .ReturnsAsync(new Domain.Entities.Apprenticeship {
                Id = expectedApprenticeshipId, ProviderId = _providerId, EmployerAccountId = _employerAccountId
            });

            _exampleValidRequest = new CreateApprenticeshipCommand
            {
                Caller = new Caller
                {
                    CallerType = CallerType.Provider,
                    Id         = 111L
                },
                CommitmentId   = 123L,
                Apprenticeship = populatedApprenticeship,
                UserId         = "ABBA123"
            };
        }
コード例 #2
0
        public void Setup()
        {
            Fixture fixture = new Fixture();

            fixture.Customize <Apprenticeship>(ob => ob
                                               .With(x => x.ULN, ApprenticeshipTestDataHelper.CreateValidULN())
                                               );
            _validator = new CreateCommitmentValidator();
            var populatedCommitment = fixture.Build <Domain.Entities.Commitment>().Create();

            _exampleCommand = new CreateCommitmentCommand {
                Commitment = populatedCommitment
            };
        }
        public void BaseSetup()
        {
            MockCurrentDateTime = new Mock <ICurrentDateTime>();
            MockCurrentDateTime.SetupGet(x => x.Now).Returns(new DateTime(2017, 6, 10));

            MockUlnValidator          = new Mock <IUlnValidator>();
            MockAcademicYearValidator = new Mock <IAcademicYearValidator>();

            Validator = new ApprenticeshipValidator(MockCurrentDateTime.Object, MockUlnValidator.Object, MockAcademicYearValidator.Object);

            ExampleValidApprenticeship = new Apprenticeship
            {
                FirstName   = "Bob",
                LastName    = "Smith",
                NINumber    = ApprenticeshipTestDataHelper.CreateValidNino(),
                ULN         = ApprenticeshipTestDataHelper.CreateValidULN(),
                ProviderRef = "Provider ref",
                EmployerRef = null,
                StartDate   = DateTime.Now.AddYears(5),
                EndDate     = DateTime.Now.AddYears(7)
            };
        }
コード例 #4
0
        public void SetUp()
        {
            _mockCommitmentRespository = new Mock <ICommitmentRepository>();
            _mockHashingService        = new Mock <IHashingService>();
            var commandValidator = new CreateCommitmentValidator();

            _mockHistoryRepository = new Mock <IHistoryRepository>();
            _handler = new CreateCommitmentCommandHandler(_mockCommitmentRespository.Object,
                                                          _mockHashingService.Object,
                                                          commandValidator,
                                                          Mock.Of <ICommitmentsLogger>(),
                                                          _mockHistoryRepository.Object);

            Fixture fixture = new Fixture();

            fixture.Customize <Apprenticeship>(ob => ob
                                               .With(x => x.ULN, ApprenticeshipTestDataHelper.CreateValidULN())
                                               .With(x => x.NINumber, ApprenticeshipTestDataHelper.CreateValidNino())
                                               .With(x => x.FirstName, "First name")
                                               .With(x => x.FirstName, "Last name")
                                               .With(x => x.ProviderRef, "Provider ref")
                                               .With(x => x.EmployerRef, null)
                                               .With(x => x.StartDate, DateTime.Now.AddYears(5))
                                               .With(x => x.EndDate, DateTime.Now.AddYears(7))
                                               .With(x => x.DateOfBirth, DateTime.Now.AddYears(-16))
                                               .With(x => x.TrainingCode, string.Empty)
                                               .With(x => x.TrainingName, string.Empty)
                                               );
            _populatedCommitment = fixture.Build <Commitment>().Create();
            _populatedCommitment.Apprenticeships = new List <Apprenticeship>();

            _exampleValidRequest = new CreateCommitmentCommand
            {
                Commitment = _populatedCommitment,
                Caller     = new Caller(1L, CallerType.Employer),
                UserId     = "UserId"
            };
        }
コード例 #5
0
        public void Setup()
        {
            _validator = new CreateApprenticeshipValidator(new ApprenticeshipValidator(new StubCurrentDateTime(), Mock.Of <IUlnValidator>(), Mock.Of <IAcademicYearValidator>()));
            var exampleValidApprenticeship = new Domain.Entities.Apprenticeship
            {
                FirstName   = "Bob", LastName = "Smith", NINumber = ApprenticeshipTestDataHelper.CreateValidNino(),
                ULN         = ApprenticeshipTestDataHelper.CreateValidULN(),
                ProviderRef = "Provider ref", EmployerRef = null,
                StartDate   = DateTime.Now.AddYears(5),
                EndDate     = DateTime.Now.AddYears(7)
            };

            _exampleCommand = new CreateApprenticeshipCommand
            {
                Caller = new Caller
                {
                    CallerType = CallerType.Provider,
                    Id         = 1
                },
                CommitmentId   = 123L,
                Apprenticeship = exampleValidApprenticeship
            };
        }