コード例 #1
0
        //[Authorize(Roles = Role.Admin)]
        public async Task <ActionResult <User> > GetUser(long id)
        {
            var user = _dbController.FindUserByID(id);

            if (user == null)
            {
                return(NotFound());
            }

            return(user);
        }
コード例 #2
0
        public void GetUserUserNotInDB_Get_ErrorDetected()
        {
            //Arrange
            var UserUnderTest = new User()
            {
                FirstName = "Lars",
                LastName  = "MobbeDreng",
                Email     = "*****@*****.**",
                UserId    = 1
            };

            databaseController.FindUserByID(UserUnderTest.UserId).ReturnsNull();


            //Act
            var result = ((_uut.Get(UserUnderTest.UserId).Result.Result) as NotFoundResult);

            //Assert

            Assert.That(result.StatusCode, Is.EqualTo(404));
        }
コード例 #3
0
        public async Task <ActionResult <UserDto> > Get(long id)
        {
            var user = _dbController.FindUserByID(id);

            if (user == null)
            {
                return(NotFound());
            }
            var userDto = new UserDto();

            userDto.Email     = user.Email;
            userDto.FirstName = user.FirstName;
            userDto.LastName  = user.LastName;
            return(userDto);
        }