Beispiel #1
0
        public async Task IntegrationTest_AddUser_ResultCannotRepeatName()
        {
            var userAll = await _getUserService.GetUserAll();
            var userGot = userAll.Last();
            await _addUserService.AddUser(userGot);
            await _deleteUserService.DeleteUser(userGot.Id);

        }
Beispiel #2
0
        public async Task <IHttpActionResult> Post([FromBody] UserDto user)
        {
            await _addUserService.AddUser(user);

            var userAll = await _getUserService.GetUserAll();

            var lastUser = userAll.OrderBy(u => u.Id).Last();

            return(CreatedAtRoute("GetById", new { id = lastUser.Id }, lastUser));
        }
        public async Task <IHttpActionResult> Put(int id, [FromBody] UserDto user)
        {
            await _updateUserService.UpdateUser(user);

            var userAll = await _getUserService.GetUserAll();

            var lastUser = userAll.OrderBy(u => u.Id).Last();

            return(Ok(user));
        }
Beispiel #4
0
        public async Task IntegrationTest_AddUser_ResultOk()
        {
            _userToAdd = new UserDto
            {
                Name = "Yo mismo",
                BirthDate = new DateTime(1973, 3, 7)
            };
            await _addUserService.AddUser(_userToAdd);
            _getUserService = new GetUserService(_userRepository, _getUserLogic);
            var userAll = await _getUserService.GetUserAll();
            var userGot = userAll.FirstOrDefault(u => u.Name.Contains(_userToAdd.Name));
            Assert.AreEqual(_userToAdd.Name, userGot.Name);
            Assert.AreEqual(_userToAdd.BirthDate, userGot.BirthDate);
            await _deleteUserService.DeleteUser(userGot.Id);

        }
Beispiel #5
0
        // GET: api/User
        public async Task <IHttpActionResult> Get()
        {
            var userAll = await _getUserService.GetUserAll();

            return(Ok(userAll));
        }