public async Task DeleteIconShouldSucceed() { // Arrange var id = Guid.NewGuid(); var name = "name"; var businessUnit = RepositoryHelper.ForBusinessUnit.CreateBusinessUnit(id, name); // Act await _repository.DeleteAsync(id, 0); // Assert var data = RepositoryHelper.ForBusinessUnit.GetBusinessUnits(); data.Should().HaveCount(0); }
public async Task <Result> Handle(DeleteBusinessUnitCommand request, CancellationToken cancellationToken) { Result result; try { await _businessUnitWriteRepository.DeleteAsync(request.Id, request.Version); result = Result.Ok(); } catch (EntityNotFoundDbException) { result = Result.Fail(new System.Collections.Generic.List <Failure>() { new HandlerFault() { Code = HandlerFaultCode.NotFound.Name, Message = string.Format(HandlerFailures.NotFound, "BusinessUnit"), Target = "id" } } ); } catch (EntityVersionDbException) { result = Result.Fail(new System.Collections.Generic.List <Failure>() { new HandlerFault() { Code = HandlerFaultCode.NotMet.Name, Message = HandlerFailures.NotMet, Target = "version" } } ); } catch { result = Result.Fail(CustomFailures.DeleteBusinessUnitFailure); } return(result); }