public async Task <UsersSampleSets> DeleteUsersSampleSetsAsync(UsersSampleSets usersSampleSets2BDeleted) { _context.UsersSampleSets.Remove(usersSampleSets2BDeleted); await _context.SaveChangesAsync(); return(usersSampleSets2BDeleted); }
//UsersSampleSets public async Task <UsersSampleSets> AddUsersSampleSetsAsync(UsersSampleSets newUsersSampleSets) { await _context.UsersSampleSets.AddAsync(newUsersSampleSets); await _context.SaveChangesAsync(); return(newUsersSampleSets); }
public async Task GetUsersSampleSetsAsync_ShouldReturnOKObject() { UsersSampleSets usersSampleSets = new UsersSampleSets(); _projectBLMock.Setup(i => i.GetUsersSampleSetsAsync()); UsersSampleSetsController usersSampleSetsController = new UsersSampleSetsController(_projectBLMock.Object); var result = await usersSampleSetsController.GetUsersSampleSetsAsync(); Assert.IsType <OkObjectResult>(result); }
//SampleSets public async Task<SampleSets> AddSampleSetsAsync(SampleSets newSampleSets, int userId) { newSampleSets = await _repo.AddSampleSetsAsync(newSampleSets); UsersSampleSets usersSampleSets = new UsersSampleSets(); usersSampleSets.SampleSetsId = newSampleSets.Id; usersSampleSets.UserId = userId; usersSampleSets.IsOwner = true; await _repo.AddUsersSampleSetsAsync(usersSampleSets); return await _repo.GetSampleSetsByIDAsync(newSampleSets.Id); }
public async Task AddUsersSampleSetsAsync_ShouldReturnCreatedAtAction_WhenUsersSampleSetsIsValid() { UsersSampleSets usersSampleSets = new UsersSampleSets(); _projectBLMock.Setup(i => i.AddUsersSampleSetsAsync(usersSampleSets)).ReturnsAsync(usersSampleSets); UsersSampleSetsController usersSampleSetsController = new UsersSampleSetsController(_projectBLMock.Object); var result = await usersSampleSetsController.AddUsersSampleSetsAsync(usersSampleSets); Assert.IsType <CreatedAtActionResult>(result); }
public async Task <UsersSampleSets> UpdateUsersSampleSetsAsync(UsersSampleSets usersSampleSets2BUpdated) { UsersSampleSets oldUsersSampleSets = await _context.UsersSampleSets.Where(s => s.Id == usersSampleSets2BUpdated.Id).FirstOrDefaultAsync(); _context.Entry(oldUsersSampleSets).CurrentValues.SetValues(usersSampleSets2BUpdated); await _context.SaveChangesAsync(); _context.ChangeTracker.Clear(); return(oldUsersSampleSets); }
public async Task GetUsersSampleSetsByIDAsync_ShouldReturnOkObjectResult_WhenIDIsValid() { UsersSampleSets usersSampleSets = new UsersSampleSets(); int id = 1; _projectBLMock.Setup(i => i.GetUsersSampleSetsByIDAsync(id)).ReturnsAsync(usersSampleSets); UsersSampleSetsController usersSampleSetsController = new UsersSampleSetsController(_projectBLMock.Object); var result = await usersSampleSetsController.GetUsersSampleSetsByIDAsync(id); Assert.IsType <OkObjectResult>(result); }
public async Task GetUsersSampleSetsByIDAsync_ShouldReturnNotFound_WhenUserSampleSetsIsInvalid() { UsersSampleSets usersSampleSets = null; int id = -2; _projectBLMock.Setup(i => i.GetUsersSampleSetsByIDAsync(id)).ReturnsAsync(usersSampleSets); UsersSampleSetsController usersSampleSetsController = new UsersSampleSetsController(_projectBLMock.Object); var result = await usersSampleSetsController.GetUsersSampleSetsByIDAsync(id); Assert.IsType <NotFoundResult>(result); }
public async Task DeleteUsersSampleSetsAsync_ShouldReturnNoContent_WhenIDIsValid() { int id = 1; UsersSampleSets usersSampleSets = new UsersSampleSets(); _projectBLMock.Setup(i => i.DeleteUsersSampleSetsAsync(usersSampleSets)).ReturnsAsync(usersSampleSets); UsersSampleSetsController usersSampleSetsController = new UsersSampleSetsController(_projectBLMock.Object); var result = await usersSampleSetsController.DeleteUsersSampleSetsAsync(id); Assert.IsType <NoContentResult>(result); }
public async Task AddUsersSampleSetsAsync_ShouldReturnStatusCode400_WhenUsersSampleSetsIsInvalid() { UsersSampleSets usersSampleSets = null; _projectBLMock.Setup(i => i.AddUsersSampleSetsAsync(usersSampleSets)).Throws(new Exception()); UsersSampleSetsController usersSampleSetsController = new UsersSampleSetsController(_projectBLMock.Object); var result = await usersSampleSetsController.AddUsersSampleSetsAsync(usersSampleSets); Assert.IsType <StatusCodeResult>(result); Assert.Equal(400, ((StatusCodeResult)result).StatusCode); }
public async Task <IActionResult> UpdateUsersSampleSetsAsync(int id, [FromBody] UsersSampleSets sampleSets) { try { await _projectBL.UpdateUsersSampleSetsAsync(sampleSets); return(NoContent()); } catch { return(StatusCode(500)); } }
public async Task DeleteUsersSampleSetsAsync_ShouldReturnStatusCode500_WhenIDIsInvalid() { int id = -1; UsersSampleSets usersSampleSets = null; _projectBLMock.Setup(i => i.DeleteUsersSampleSetsAsync(usersSampleSets)).Throws(new Exception()); UsersSampleSetsController usersSampleSetsController = new UsersSampleSetsController(_projectBLMock.Object); var result = await usersSampleSetsController.DeleteUsersSampleSetsAsync(id); Assert.IsType <StatusCodeResult>(result); Assert.Equal(500, ((StatusCodeResult)result).StatusCode); }
public async Task <IActionResult> AddUsersSampleSetsAsync([FromBody] UsersSampleSets sampleSets) { try { await _projectBL.AddUsersSampleSetsAsync(sampleSets); Log.Logger.Information($"new UsersSampleSets with ID {sampleSets.Id} created"); return(CreatedAtAction("AddUsersSampleSets", sampleSets)); } catch (Exception e) { Log.Logger.Error($"Error thrown: {e.Message}"); return(StatusCode(400)); } }
public async Task UpdateUsersSampleSetsAsync_ShouldReturn_OldUsersSampleSets() { //arrange UsersSampleSets usersSampleSets = new UsersSampleSets { Id = 1, UserId = 99 }; ProjectDBContext projectDBContext = new ProjectDBContext(options); ProjectRepoDB projectRepoDB = new ProjectRepoDB(projectDBContext); //act var result = await projectRepoDB.UpdateUsersSampleSetsAsync(usersSampleSets); //assert Assert.Equal(usersSampleSets.UserId, result.UserId); }
public async Task<UsersSampleSets> DeleteUsersSampleSetsAsync(UsersSampleSets usersSampleSets2BDeleted) { return await _repo.DeleteUsersSampleSetsAsync(usersSampleSets2BDeleted); }
public async Task<UsersSampleSets> UpdateUsersSampleSetsAsync(UsersSampleSets usersSampleSets2BUpdated) { return await _repo.UpdateUsersSampleSetsAsync(usersSampleSets2BUpdated); }
//UsersSampleSets public async Task<UsersSampleSets> AddUsersSampleSetsAsync(UsersSampleSets newUsersSampleSets) { return await _repo.AddUsersSampleSetsAsync(newUsersSampleSets); }