public async Task DeleteTestAsync() { var test = CreateTest("Logical"); string userName = "******"; ApplicationUser user = new ApplicationUser() { Email = userName, UserName = userName }; await _userManager.CreateAsync(user); var applicationUser = await _userManager.FindByEmailAsync(user.Email); await _testRepository.CreateTestAsync(test, applicationUser.Id); await _testRepository.DeleteTestAsync(test.Id); Assert.Equal(0, _trappistDbContext.Test.Count()); }
public async Task <IActionResult> DeleteTestAsync(int id) { if (!ModelState.IsValid) { return(BadRequest()); } if (!await _testRepository.IsTestExists(id)) { return(NotFound()); } if (await _testRepository.IsTestAttendeeExistAsync(id)) { return(NotFound()); } await _testRepository.DeleteTestAsync(id); return(NoContent()); }