public async Task SignIn_ForUser_Registered() { // Arrange var userName = "******"; var password = "******"; var authHolder = AuthorizationMockFactory.GetAuthHolder(); var authService = AuthorizationMockFactory.GetAuthService(authHolder); var exception = default(Exception); //Act try { await authService.SignInAsync(userName, password, CancellationToken.None); } catch (Exception e) { exception = e; } //Assert exception.Should().BeNull(); authHolder.GetLastSession().Should().NotBeNull(); authHolder.GetLastSession().Token.Should().NotBeNullOrEmpty(); authHolder.GetLastSession().ExpireAt.Should().BeAfter(DateTimeOffset.Now); authHolder.GetLastSession().CanBeUpdatedTill.Should().BeAfter(DateTimeOffset.Now); }
public async Task SignUp_ForUser_NoRegistered_Validation(string userName, string password) { // Arrange var authHolder = AuthorizationMockFactory.GetAuthHolder(); var authService = AuthorizationMockFactory.GetAuthService(authHolder); var exception = default(Exception); //Act try { await authService.SignUpAsync(userName, password, CancellationToken.None); } catch (Exception e) { exception = e; } //Assert exception.Should().BeOfType <InvalidDataException>(); }
public async Task SignIn_ForUser_NoRegistered(string userName, string password) { // Arrange var authHolder = AuthorizationMockFactory.GetAuthHolder(); var authService = AuthorizationMockFactory.GetAuthService(authHolder); var exception = default(Exception); //Act try { await authService.SignInAsync(userName, password, CancellationToken.None); } catch (Exception e) { exception = e; } //Assert exception.Should().BeOfType <AuthenticationException>(); authHolder.GetLastSession().Should().BeNull(); }
public async Task SignUp_ForUser_Registered() { // Arrange var userName = "******"; var password = "******"; var authHolder = AuthorizationMockFactory.GetAuthHolder(); var authService = AuthorizationMockFactory.GetAuthService(authHolder); var exception = default(Exception); //Act try { await authService.SignUpAsync(userName, password, CancellationToken.None); } catch (Exception e) { exception = e; } //Assert exception.Should().BeOfType <AuthorizationException>(); authHolder.GetLastSession().Should().BeNull(); }