コード例 #1
0
 public AuthController(
     IJwtSecurityTokenHelper jwtSecurityTokenHelper,
     IAuthenticationService authenticationService)
 {
     _jwtSecurityTokenHelper = jwtSecurityTokenHelper;
     _authenticationService  = authenticationService;
 }
コード例 #2
0
        public async Task FindAsync_shouldReturnNotFound_WhenNoUserFound()
        {
            //Arrange
            tokenHelper           = Substitute.For <IJwtSecurityTokenHelper>();
            authenticationService = Substitute.For <IAuthenticationService>();
            var viewModel = new AuthViewModel()
            {
                Username  = "******",
                AccessKey = "userAccessKey"
            };

            User userReturn = null;

            authenticationService.FindAsync(viewModel.Username).Returns(userReturn);

            var sut = new AuthController(tokenHelper, authenticationService);

            //Act
            var result = (ObjectResult)await sut.GetTokenAsync(viewModel);

            //Assert
            Assert.Equal((int)HttpStatusCode.Unauthorized, result.StatusCode);
        }
コード例 #3
0
 public AuthControllerTests()
 {
     tokenHelper           = Substitute.For <IJwtSecurityTokenHelper>();
     authenticationService = Substitute.For <IAuthenticationService>();
 }