コード例 #1
0
        public async Task <UsersSampleSets> DeleteUsersSampleSetsAsync(UsersSampleSets usersSampleSets2BDeleted)
        {
            _context.UsersSampleSets.Remove(usersSampleSets2BDeleted);
            await _context.SaveChangesAsync();

            return(usersSampleSets2BDeleted);
        }
コード例 #2
0
        //UsersSampleSets
        public async Task <UsersSampleSets> AddUsersSampleSetsAsync(UsersSampleSets newUsersSampleSets)
        {
            await _context.UsersSampleSets.AddAsync(newUsersSampleSets);

            await _context.SaveChangesAsync();

            return(newUsersSampleSets);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        //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);

        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        public async Task <IActionResult> UpdateUsersSampleSetsAsync(int id, [FromBody] UsersSampleSets sampleSets)
        {
            try
            {
                await _projectBL.UpdateUsersSampleSetsAsync(sampleSets);

                return(NoContent());
            }
            catch
            {
                return(StatusCode(500));
            }
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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));
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
 public async Task<UsersSampleSets> DeleteUsersSampleSetsAsync(UsersSampleSets usersSampleSets2BDeleted)
 {
     return await _repo.DeleteUsersSampleSetsAsync(usersSampleSets2BDeleted);
 }
コード例 #16
0
 public async Task<UsersSampleSets> UpdateUsersSampleSetsAsync(UsersSampleSets usersSampleSets2BUpdated)
 {
     return await _repo.UpdateUsersSampleSetsAsync(usersSampleSets2BUpdated);
 }
コード例 #17
0
 //UsersSampleSets
 public async Task<UsersSampleSets> AddUsersSampleSetsAsync(UsersSampleSets newUsersSampleSets)
 {
     return await _repo.AddUsersSampleSetsAsync(newUsersSampleSets);
 }