public async Task DeleteShouldSucceed() { // Arrange var id = Guid.NewGuid(); var name = "name"; RepositoryHelper.ForLayout.CreateLayout(id, name); // Act await _repository.DeleteAsync(id, 0); // Assert var data = RepositoryHelper.ForLayout.GetLayouts(); data.Should().HaveCount(0); }
public async Task <Result> Handle(DeleteLayoutCommand request, CancellationToken cancellationToken) { Result result; try { await _layoutWriteRepository.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, "Layout"), 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.DeleteLayoutFailure); } return(result); }