Esempio n. 1
0
        public void Arrange()
        {
            _validCommand = new CreateCommitmentCommand
            {
                Commitment = new Commitment
                {
                    ProviderId      = 1,
                    ProviderName    = "Test Provider",
                    LegalEntityId   = "2",
                    LegalEntityName = "Test Legal Entity"
                }
            };

            _validator = new Mock <IValidator <CreateCommitmentCommand> >();
            _validator.Setup(x => x.Validate(It.IsAny <CreateCommitmentCommand>())).Returns(new ValidationResult());

            _commitmentsApi = new Mock <IProviderCommitmentsApi>();
            _commitmentsApi.Setup(x => x.CreateProviderCommitment(It.IsAny <long>(), It.IsAny <CommitmentRequest>()))
            .ReturnsAsync(new CommitmentView());

            _handler = new CreateCommitmentCommandHandler(_commitmentsApi.Object, _validator.Object);
        }
        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"
            };
        }