public void GetByIdAsync_Return_Role()
        {
            //Arrange
            int expectedStatusCode = 200;

            RoleDomainModel roleDomainModel = new RoleDomainModel
            {
                Id    = 123,
                Name  = "admin",
                Users = new List <UserDomainModel>()
            };

            Task <RoleDomainModel> responseTask = Task.FromResult(roleDomainModel);

            _roleService = new Mock <IRoleService>();
            _roleService.Setup(x => x.GetByIdAsync(It.IsAny <int>())).Returns(responseTask);
            RolesController rolesController = new RolesController(_roleService.Object);

            //Act
            var             result     = rolesController.GetByIdAsync(roleDomainModel.Id).ConfigureAwait(false).GetAwaiter().GetResult().Result;
            var             resultList = ((OkObjectResult)result).Value;
            RoleDomainModel roleResult = (RoleDomainModel)resultList;

            //Assert
            Assert.IsNotNull(roleResult);
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));
            Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode);
        }
        public void GetByIdAsync_Return_NotFound()
        {
            //Arrange
            int    expectedStatusCode = 404;
            string expectedMessage    = Messages.ROLE_DOES_NOT_EXIST;

            RoleDomainModel roleDomainModel = null;

            Task <RoleDomainModel> responseTask = Task.FromResult(roleDomainModel);

            _roleService = new Mock <IRoleService>();
            _roleService.Setup(x => x.GetByIdAsync(It.IsAny <int>())).Returns(responseTask);
            RolesController rolesController = new RolesController(_roleService.Object);

            //Act
            var    result     = rolesController.GetByIdAsync(123).ConfigureAwait(false).GetAwaiter().GetResult().Result;
            var    resultList = ((NotFoundObjectResult)result).Value;
            string roleResult = (string)resultList;

            //Assert
            Assert.IsNotNull(roleResult);
            Assert.IsInstanceOfType(result, typeof(NotFoundObjectResult));
            Assert.AreEqual(expectedStatusCode, ((NotFoundObjectResult)result).StatusCode);
            Assert.AreEqual(expectedMessage, roleResult);
        }