public async Task DeleteByIdAsync_ThrowsNotFoundException_WhenIdNotExist() { Exception exception = null; using (var context = new MSLunchesContext(GetDbOptions("DeleteByIdAsync_ThrowsNotFoundException_WhenIdNotExist"))) { var classUnderTest = new UserLunchService(context); try { await classUnderTest.DeleteByIdAsync(Guid.NewGuid()); } catch (Exception ex) { exception = ex; } } var result = Assert.IsType <NotFoundException>(exception); Assert.False(string.IsNullOrEmpty(result.Message)); }
public async Task DeleteByIdAsync_ReturnsCountOfChanges_WhenIdExist() { var userLunch = GetUserLunch(); using (var context = new MSLunchesContext(GetDbOptions("DeleteByIdAsync_ReturnsCountOfChanges_WhenIdExist"))) { await context.UserLunches.AddAsync(userLunch); await context.SaveChangesAsync(); } var result = 0; using (var context = new MSLunchesContext(GetDbOptions("DeleteByIdAsync_ReturnsCountOfChanges_WhenIdExist"))) { var classUnderTest = new UserLunchService(context); result = await classUnderTest.DeleteByIdAsync(userLunch.Id); } Assert.True(result > 0); }