public async Task PasswordShouldBeIncorrect() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); FluentActions.Invoking(async() => await service.Login("*****@*****.**", "Wrong", false)) .Should().Throw <IncorrectPasswordException>(); } }
public async Task ShouldNotFind() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); FluentActions.Invoking(async() => await service.Login("*****@*****.**", "Wrong", false)) .Should().Throw <UserNotFoundException>(); } }
public async Task ShouldLogin() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); var result = await service.Login("*****@*****.**", "Password", false); result.Should().NotBeNull(); } }
public async Task ShouldReturn1DayToken() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); var result = await service.Login("*****@*****.**", "Password", false); var handler = new JwtSecurityTokenHandler(); var token = handler.ReadJwtToken(result.Token); DateTime validFrom = token.ValidFrom; DateTime validTo = token.ValidTo; validTo.Should().Be(validFrom.AddDays(1)); } }