public async Task Then_repository_update_print_status_is_called_for_printed(string status, DateTime statusAt, string reasonForChange, bool updateCertificateStatus, bool updateCertificateBatchLog)
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = BatchNumber,
                CertificateReference = CertificateReference,
                Status          = status,
                StatusAt        = statusAt,
                ReasonForChange = reasonForChange
            };

            // Act
            _response = await _fixture.Handle(request);

            // Assert
            if (updateCertificateBatchLog)
            {
                _fixture.VerifyUpdatePrintStatusCalled(CertificateReference, BatchNumber, request.Status, request.StatusAt, request.ReasonForChange, updateCertificateStatus, updateCertificateBatchLog);
            }
            else
            {
                _fixture.VerifyUpdatePrintStatusNotCalled(CertificateReference, BatchNumber);
            }
        }
Exemplo n.º 2
0
        public async Task Then_repository_update_print_status_is_called_for_printed()
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = PreviousBatchNumber,
                CertificateReference = CertificateReference,
                Status   = CertificateStatus.Printed,
                StatusAt = PreviousBatchSentToPrinterAt.AddMinutes(30)
            };

            // Act
            _response = await _fixture.Handle(request);

            // Assert
            _fixture.VerifyUpdatePrintStatusCalled(CertificateReference, PreviousBatchNumber, request.Status, request.StatusAt, null, false, true);
        }
Exemplo n.º 3
0
        public async Task Arrange()
        {
            // Arrange
            base.BaseArrange();

            var certificatePrintStatusUpdateRequest = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = _batch222,
                CertificateReference = _certificateReference4,
                Status   = CertificateStatus.NotDelivered,
                StatusAt = _statusChangedAt
            };

            // Act
            _response = await _sut.Handle(certificatePrintStatusUpdateRequest,
                                          new CancellationToken());
        }
        public async Task Then_repository_update_print_status_is_not_called()
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = BatchNumber,
                CertificateReference = CertificateReferenceNotExists,
                Status   = CertificateStatus.Printed,
                StatusAt = DateTime.UtcNow
            };

            // Act
            _response = await _fixture.Handle(request);

            // Assert
            _fixture.VerifyUpdatePrintStatusNotCalled(CertificateReferenceNotExists, BatchNumber);
        }
Exemplo n.º 5
0
        public async Task Then_repository_update_print_status_is_called_for_not_delivered()
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = CurrentBatchNumber,
                CertificateReference = CertificateReference,
                Status   = CertificateStatus.NotDelivered,
                StatusAt = CurrentBatchPrintedAt.AddMinutes(30)
            };

            // Act
            _response = await _fixture.Handle(request);

            // Assert
            _fixture.VerifyUpdatePrintStatusCalled(CertificateReference, CurrentBatchNumber, request.Status, request.StatusAt, null, true, true);
        }
Exemplo n.º 6
0
        public async Task Then_validation_response_is_valid_true_for_not_delivered()
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = CurrentBatchNumber,
                CertificateReference = CertificateReference,
                Status   = CertificateStatus.NotDelivered,
                StatusAt = CurrentBatchPrintedAt.AddMinutes(30)
            };

            // Act
            _response = await _fixture.Handle(request);

            // Assert
            _response.IsValid.Should().Be(true);
            _response.Errors.Count.Should().Be(0);
        }
Exemplo n.º 7
0
        public async Task Then_validation_response_is_valid_true_for_printed()
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = BatchNumberFirst,
                CertificateReference = CertificateReferenceFirst,
                Status   = CertificateStatus.Printed,
                StatusAt = BatchNumberFirstSentToPrinterAt.AddMinutes(30)
            };

            // Act
            _response = await _fixture.Handle(request);

            // Assert
            _response.IsValid.Should().Be(true);
            _response.Errors.Count.Should().Be(0);
        }
        public async Task Then_validation_response_is_valid_true_for_status_duplication(string status, DateTime statusAt, string reasonForChange, bool updateCertificateStatus, bool updateCertificateBatchLog)
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = BatchNumber,
                CertificateReference = CertificateReference,
                Status          = status,
                StatusAt        = statusAt,
                ReasonForChange = reasonForChange
            };

            // Act
            _response = await _fixture.Handle(request);

            // Assert
            _response.IsValid.Should().Be(true);
            _response.Errors.Count.Should().Be(0);
        }
        public async Task Arrange()
        {
            // Arrange
            _fixture = new CertificatePrintStatusUpdateHandlerTestsFixture()
                       .WithCertificate(CertificateReference, CertificateStatus.Printed, PrintedAt, BatchNumber, PrintedAt.AddMinutes(-5))
                       .WithCertificateBatchLog(BatchNumber, CertificateReference, CertificateStatus.Printed, PrintedAt, null, PrintedAt.AddMinutes(5))
                       .WithBatchLog(BatchNumber);

            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = BatchNumber,
                CertificateReference = CertificateReference,
                Status   = CertificateStatus.Delivered,
                StatusAt = DeliveredAt
            };

            // Act
            _response = await _fixture.Handle(request);
        }
Exemplo n.º 10
0
        public async Task Then_repository_update_print_status_is_not_called(string invalidPrintStatus)
        {
            // Arrange
            var invalidCertificatePrintStatusUpdateRequest = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = _batch111,
                CertificateReference = _certificateReference1,
                Status   = invalidPrintStatus,
                StatusAt = DateTime.UtcNow
            };

            // Act
            _response = await _sut.Handle(invalidCertificatePrintStatusUpdateRequest,
                                          new CancellationToken());

            // Assert
            _certificateRepository.Verify(r => r.UpdatePrintStatus(
                                              It.IsAny <Certificate>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <string>(), It.IsAny <bool>()),
                                          Times.Never());
        }
Exemplo n.º 11
0
        public async Task Then_repository_update_print_status_is_called_for_printed()
        {
            // Arrange
            var certificatePrintStatusUpdatesPrintedRequest = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = _batch111,
                CertificateReference = _certificateReferenceReprintedAfterPrinted,
                Status   = CertificateStatus.Printed,
                StatusAt = _statusAt
            };

            // Act
            _response = await _sut.Handle(certificatePrintStatusUpdatesPrintedRequest,
                                          new CancellationToken());

            // Assert
            _certificateRepository.Verify(r => r.UpdatePrintStatus(
                                              It.Is <Certificate>(c => c.CertificateReference == _certificateReferenceReprintedAfterPrinted), _batch111, CertificateStatus.Printed, _statusAt, null, false),
                                          Times.Once());
        }
Exemplo n.º 12
0
        public async Task Then_validation_response_is_valid_true_for_not_delivered()
        {
            // Arrange
            var certificatePrintStatusUpdatesNotDeliveredRequest = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = _batch222,
                CertificateReference = _certificateReferenceDeletedAfterPrinted,
                Status          = CertificateStatus.NotDelivered,
                ReasonForChange = string.Empty,
                StatusAt        = _statusAt
            };

            // Act
            _response = await _sut.Handle(certificatePrintStatusUpdatesNotDeliveredRequest,
                                          new CancellationToken());

            // Assert
            _response.IsValid.Should().Be(true);
            _response.Errors.Count.Should().Be(0);
        }
Exemplo n.º 13
0
        public async Task Then_validation_response_is_valid_false()
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = BatchNumber + 999,
                CertificateReference = CertificateReference,
                Status   = CertificateStatus.Printed,
                StatusAt = DateTime.UtcNow
            };

            // Act
            _response = await _fixture.Handle(request);

            _response.IsValid.Should().Be(false);
            _response.Errors.Count.Should().Be(1);

            _response.Errors[0].Field.Should().Be("BatchNumber");
            _response.Errors[0].ErrorMessage.Should().Contain(request.BatchNumber.ToString());
        }
Exemplo n.º 14
0
        public async Task Then_validation_response_is_valid_true_for_printed()
        {
            // Arrange
            var certificatePrintStatusUpdatesPrintedRequest = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = _batch111,
                CertificateReference = _certificateReferenceReprintedAfterPrinted,
                Status   = CertificateStatus.Printed,
                StatusAt = _statusAt
            };

            // Act
            _response = await _sut.Handle(certificatePrintStatusUpdatesPrintedRequest,
                                          new CancellationToken());

            // Assert

            _response.IsValid.Should().Be(true);
            _response.Errors.Count.Should().Be(0);
        }
Exemplo n.º 15
0
        public async Task Then_repository_update_print_status_is_called_for_not_delivered()
        {
            // Arrange
            var certificatePrintStatusUpdatesNotDeliveredRequest = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = _batch222,
                CertificateReference = _certificateReferenceDeletedAfterPrinted,
                Status          = CertificateStatus.NotDelivered,
                ReasonForChange = string.Empty,
                StatusAt        = _statusAt
            };

            // Act
            _response = await _sut.Handle(certificatePrintStatusUpdatesNotDeliveredRequest,
                                          new CancellationToken());

            // Assert
            _certificateRepository.Verify(r => r.UpdatePrintStatus(
                                              It.Is <Certificate>(c => c.CertificateReference == _certificateReferenceDeletedAfterPrinted), _batch222, CertificateStatus.NotDelivered, _statusAt, string.Empty, false),
                                          Times.Once());
        }
Exemplo n.º 16
0
        public async Task Then_validation_response_is_valid_false(string invalidPrintStatus)
        {
            // Arrange
            var request = new CertificatePrintStatusUpdateRequest
            {
                BatchNumber          = BatchNumber,
                CertificateReference = CertificateReference,
                Status   = invalidPrintStatus,
                StatusAt = DateTime.UtcNow
            };

            // Act
            _response = await _fixture.Handle(request);

            // Assert
            _response.IsValid.Should().Be(false);
            _response.Errors.Count.Should().Be(1);

            _response.Errors[0].Field.Should().Be("CertificatePrintStatuses");
            _response.Errors.Should().Contain(p => p.ErrorMessage.Contains(invalidPrintStatus));
        }
Exemplo n.º 17
0
 public async Task <IActionResult> UpdatePrintStatus([FromBody] CertificatePrintStatusUpdateRequest request)
 {
     return(Ok(await _mediator.Send(request)));
 }
 public async Task <ValidationResponse> Handle(CertificatePrintStatusUpdateRequest request)
 {
     return(await _sut.Handle(request, new CancellationToken()));
 }