Ejemplo n.º 1
0
        public void Then_An_Invalid_Operation_Exception_Is_Thrown_If_The_Message_Is_Not_Valid()
        {
            //Arrange
            var message = new PaymentCreatedMessage();

            //Act
            Assert.ThrowsAsync <InvalidOperationException>(async() => await _handler.Handle(message, _allowProjectionQueueName));
        }
Ejemplo n.º 2
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());
        }