Ejemplo n.º 1
0
        public async Task Then_The_Commitment_Is_Not_Stored_If_The_Registration_Check_Fails()
        {
            //Arrange
            _commitmentModel = new CommitmentModel
            {
                ApprenticeshipId  = ExpectedApprenticeshipId,
                EmployerAccountId = ExpectedEmployerAccountId,
                ActualEndDate     = null,
                Id = 3322,
                CompletionAmount = 100
            };
            _paymentMapper.Setup(x =>
                                 x.MapToCommitment(It.Is <PaymentCreatedMessage>(c =>
                                                                                 c.EmployerAccountId.Equals(ExpectedEmployerAccountId))))
            .Returns(_commitmentModel);
            _employerCommitment = new EmployerCommitment(_commitmentModel);
            _employerCommitmentRepostiory.Setup(x => x.Get(ExpectedEmployerAccountId, ExpectedApprenticeshipId))
            .ReturnsAsync(_employerCommitment);
            _handler = new Application.Commitments.Handlers.StoreCommitmentHandler(_employerCommitmentRepostiory.Object, _logger.Object, _paymentMapper.Object, new Mock <ITelemetry>().Object, new Apprenticeship.Mapping.ApprenticeshipMapping(), _queueServiceMock.Object);

            //Act
            await _handler.Handle(_message, _allowProjectionQueueName);

            //Assert
            _queueServiceMock.Verify(v => v.SendMessageWithVisibilityDelay(It.Is <PaymentCreatedMessage>(m => m == _message), It.Is <string>(s => s == _allowProjectionQueueName)), Times.Never);
            _employerCommitmentRepostiory.Verify(x => x.Store(It.IsAny <EmployerCommitment>()), Times.Never());
        }
Ejemplo n.º 2
0
        public void Arrange()
        {
            _message = new PaymentCreatedMessage
            {
                EmployerAccountId = ExpectedEmployerAccountId,
                ApprenticeshipId  = ExpectedApprenticeshipId,
                EarningDetails    = new EarningDetails()
            };
            _commitmentModel = new CommitmentModel
            {
                EmployerAccountId = ExpectedEmployerAccountId,
                CompletionAmount  = 100
            };

            _employerCommitment = new EmployerCommitment(_commitmentModel);

            _employerCommitmentRepostiory = new Mock <IEmployerCommitmentRepository>();

            _logger = new Mock <ILog>();

            _paymentMapper = new Mock <IPaymentMapper>();
            _paymentMapper.Setup(x =>
                                 x.MapToCommitment(It.Is <PaymentCreatedMessage>(c =>
                                                                                 c.EmployerAccountId.Equals(ExpectedEmployerAccountId))))
            .Returns(_commitmentModel);
            _employerCommitmentRepostiory.Setup(x => x.Get(ExpectedEmployerAccountId, ExpectedApprenticeshipId))
            .ReturnsAsync(_employerCommitment);

            _queueServiceMock = new Mock <IQueueService>();
            _handler          = new Application.Commitments.Handlers.StoreCommitmentHandler(
                _employerCommitmentRepostiory.Object,
                _logger.Object,
                _paymentMapper.Object,
                new Mock <ITelemetry>().Object,
                new Apprenticeship.Mapping.ApprenticeshipMapping(), _queueServiceMock.Object);
        }