Esempio n. 1
0
 public void Before_each_test()
 {
     _logger    = new Mock <ILogger <UpdateOrganisationProviderTypeHandler> >();
     _validator = new Mock <IOrganisationValidator>();
     _validator.Setup(x => x.IsValidProviderTypeId(It.IsAny <int>())).Returns(true);
     _validator.Setup(x => x.IsValidOrganisationTypeIdForProvider(It.IsAny <int>(), It.IsAny <int>()))
     .ReturnsAsync(true);
     _updateOrganisationRepository = new Mock <IUpdateOrganisationRepository>();
     _auditLogService = new Mock <IAuditLogService>();
     _auditLogService.Setup(x => x.CreateAuditData(It.IsAny <Guid>(), It.IsAny <string>()))
     .Returns(new AuditData {
         FieldChanges = new List <AuditLogEntry>()
     });
     _auditLogService.Setup(x => x.AuditProviderType(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
     .Returns(new AuditData {
         FieldChanges = new List <AuditLogEntry>()
     });
     _handler = new UpdateOrganisationProviderTypeHandler(_logger.Object, _validator.Object,
                                                          _updateOrganisationRepository.Object, _auditLogService.Object);
     _request = new UpdateOrganisationProviderTypeRequest
     {
         OrganisationId     = Guid.NewGuid(),
         OrganisationTypeId = 1,
         ProviderTypeId     = 2,
         UpdatedBy          = "test"
     };
 }
Esempio n. 2
0
        public void Handler_does_not_update_audit_history_if_provider_type_not_changed()
        {
            _request = new UpdateOrganisationProviderTypeRequest
            {
                OrganisationId     = Guid.NewGuid(),
                OrganisationTypeId = 3,
                ProviderTypeId     = ProviderType.MainProvider,
                UpdatedBy          = "test"
            };

            _updateOrganisationRepository.Setup(x =>
                                                x.UpdateProviderTypeAndOrganisationType(It.IsAny <Guid>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()))
            .ReturnsAsync(true).Verifiable();

            _updateOrganisationRepository.Setup(x => x.WriteFieldChangesToAuditLog(It.IsAny <AuditData>()))
            .ReturnsAsync(true).Verifiable();

            var result = _handler.Handle(_request, new CancellationToken()).Result;

            result.Should().BeFalse();
            _updateOrganisationRepository.Verify(x => x.UpdateProviderTypeAndOrganisationType(It.IsAny <Guid>(), It.IsAny <int>(),
                                                                                              It.IsAny <int>(), It.IsAny <string>()), Times.Never());
            _updateOrganisationRepository.Verify(x => x.WriteFieldChangesToAuditLog(It.IsAny <AuditData>()), Times.Never);
        }
 public async Task <IActionResult> UpdateProviderType([FromBody] UpdateOrganisationProviderTypeRequest updateProviderTypeRequest)
 {
     return(Ok(await _mediator.Send(updateProviderTypeRequest)));
 }
Esempio n. 4
0
        public async Task <bool> UpdateOrganisationProviderType(UpdateOrganisationProviderTypeRequest request)
        {
            HttpStatusCode result = await Put <UpdateOrganisationProviderTypeRequest>($"/api/v1/updateOrganisation/providerType", request);

            return(await Task.FromResult(result == HttpStatusCode.OK));
        }