public void Before_each_test() { _logger = new Mock <ILogger <UpdateOrganisationTypeHandler> >(); _validator = new Mock <IOrganisationValidator>(); _validator.Setup(x => x.IsValidOrganisationTypeId(It.IsAny <int>())).Returns(true); _validator.Setup(x => x.IsValidOrganisationTypeIdForOrganisation(It.IsAny <int>(), It.IsAny <Guid>())).Returns(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.AuditOrganisationType(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <int>())) .Returns(new AuditData { FieldChanges = new List <AuditLogEntry>() }); _handler = new UpdateOrganisationTypeHandler(_logger.Object, _validator.Object, _updateOrganisationRepository.Object, _auditLogService.Object); _request = new UpdateOrganisationTypeRequest { OrganisationId = Guid.NewGuid(), OrganisationTypeId = 1, UpdatedBy = "test" }; }
public void Handler_does_not_update_audit_history_if_provider_type_not_changed() { _request = new UpdateOrganisationTypeRequest { OrganisationId = Guid.NewGuid(), OrganisationTypeId = 3, UpdatedBy = "test" }; _updateOrganisationRepository.Setup(x => x.UpdateOrganisationType(It.IsAny <Guid>(), 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.UpdateOrganisationType(It.IsAny <Guid>(), It.IsAny <int>(), It.IsAny <string>()), Times.Never()); _updateOrganisationRepository.Verify(x => x.WriteFieldChangesToAuditLog(It.IsAny <AuditData>()), Times.Never); }
public async Task <IActionResult> UpdateType([FromBody] UpdateOrganisationTypeRequest updateStatusRequest) { return(Ok(await _mediator.Send(updateStatusRequest))); }
public async Task <bool> UpdateOrganisationType(UpdateOrganisationTypeRequest request) { HttpStatusCode result = await Put <UpdateOrganisationTypeRequest>($"/api/v1/updateOrganisation/type", request); return(await Task.FromResult(result == HttpStatusCode.OK)); }