public async Task AddAndDeleteNewCaptain_Ok() { //Arrange var id = Guid.NewGuid(); var captain = new Captain { Id = id, Name = "Test" }; //Act await m_repository.CreateAsync(captain); //Assert var(_, captains) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new CaptainFilter { SearchTerm = id.ToString() }); Assert.Equal(id, captains.First().Id); Assert.Equal("Test", captains.First().Name); await m_repository.DeleteAsync(captain); var(_, emptyResponse) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new CaptainFilter { SearchTerm = id.ToString() }); Assert.Empty(emptyResponse); }
public async Task DeleteCaptainAsync(Guid id) { try { var captain = await EnsureCaptainExistAsync(id); await m_repository.DeleteAsync(captain); } catch (ValidationException e) { m_logger.LogWarning(e, "A validation failed"); throw; } catch (Exception e) when(e.GetType() != typeof(ValidationException)) { m_logger.LogCritical(e, $"Unexpected Exception while trying to delete a Captain for id : {id}"); throw; } }