public async Task AddAndDeleteNewShuttle_Ok() { //Arrange var id = Guid.NewGuid(); var shuttle = new Shuttle { Id = id, Name = "Test" }; //Act await m_repository.CreateAsync(shuttle); //Assert var(_, shuttles) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new ShuttleFilter { SearchTerm = id.ToString() }); Assert.Equal(id, shuttles.First().Id); Assert.Equal("Test", shuttles.First().Name); await m_repository.DeleteAsync(shuttle); var(_, emptyResponse) = await m_repository.SearchAsync(new Pagination(), new Ordering(), new ShuttleFilter { SearchTerm = id.ToString() }); Assert.Empty(emptyResponse); }
public async Task DeleteShuttleAsync(Guid id) { try { var shuttle = await EnsureShuttleExistAsync(id); await m_repository.DeleteAsync(shuttle); } 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 Shuttle for id : {id}"); throw; } }