public void GetActiveAccessTokens_UserSpecified_ActiveTokensForUser() { var context = new AlvTimeDbContextBuilder() .WithUsers() .CreateDbContext(); var storage = new AccessTokenStorage(context); var tokens = storage.GetActiveTokens(1); Assert.Equal(context.AccessTokens.Where(x => x.UserId == 1).ToList().Count(), tokens.Count()); }
public void DeleteToken_TokenIdSpecified_TokenWithIdDeleted() { var context = new AlvTimeDbContextBuilder() .WithPersonalAccessTokens() .WithUsers() .CreateDbContext(); var storage = new AccessTokenStorage(context); storage.DeleteActiveTokens(1, 1); var tokens = storage.GetActiveTokens(1); Assert.Empty(tokens); }
public void CreateLifetimeToken_FriendlyNameSpecified_TokenWithFriendlyNameCreated() { var context = new AlvTimeDbContextBuilder() .WithPersonalAccessTokens() .WithUsers() .CreateDbContext(); var storage = new AccessTokenStorage(context); storage.CreateLifetimeToken("new token", 1); var tokens = storage.GetActiveTokens(1); Assert.Equal(context.AccessTokens.Where(x => x.UserId == 1).ToList().Count(), tokens.Count()); }