protected MeController GetController()
        {
            RoleDataUtil    roleDataUtil    = new RoleDataUtil();
            AccountDataUtil accountDataUtil = new AccountDataUtil();
            var             roleVM          = roleDataUtil.GetNewViewModel();
            var             accountVM       = accountDataUtil.GetNewViewModel();

            accountVM.roles.Add(roleVM);
            var user   = new Mock <ClaimsPrincipal>();
            var claims = new Claim[]
            {
                new Claim("username", "unittestusername"),
                new Claim("profile", JsonConvert.SerializeObject(accountVM.profile)),
                new Claim("permission", JsonConvert.SerializeObject(accountVM.roles)),
                new Claim("iat", DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString())
            };

            user.Setup(u => u.Claims).Returns(claims);
            MeController controller = (MeController)Activator.CreateInstance(typeof(MeController));

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = user.Object
                }
            };
            controller.ControllerContext.HttpContext.Request.Headers["Authorization"]     = "Bearer unittesttoken";
            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "7";
            controller.ControllerContext.HttpContext.Request.Path = new PathString("/v1/unit-test");
            return(controller);
        }
        public async Task Post_WithoutException_ReturnToken()
        {
            var             mocks           = GetMocks();
            RoleDataUtil    roleDataUtil    = new RoleDataUtil();
            AccountDataUtil accountDataUtil = new AccountDataUtil();
            var             roleModel       = roleDataUtil.GetNewData();
            var             accountModel    = accountDataUtil.GetNewData();

            accountModel.AccountRoles.Add(new AccountRole()
            {
                Role    = roleModel,
                RoleUId = "RoleUId",
                UId     = "UId"
            });
            mocks.Secret.Setup(s => s.SecretString).Returns("secretsecretsecret");
            mocks.Service.Setup(s => s.Authenticate(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(accountModel);
            var roleVM    = roleDataUtil.GetNewViewModel();
            var accountVM = accountDataUtil.GetNewViewModel();

            accountVM.roles.Add(roleVM);
            mocks.Mapper.Setup(s => s.Map <AccountViewModel>(It.IsAny <Account>())).Returns(accountVM);
            AuthenticateController controller = GetController(mocks);
            var result = await controller.Post(new LoginViewModel()
            {
                Password = "******",
                Username = "******"
            });

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(result));
        }