public void ValidateExistingAndNotExistingToken() { var tokenRepository = new LocalRepository <Token>(); var userRepository = new Mock <IRepository <InsideUser> >(); var provider = new AccessTokenProvider(tokenRepository, userRepository.Object); var client = new Client() { Id = 1 }; var user = new InsideUser() { Id = "Id2", ClientId = client.Id, Client = client }; var validToken = new Token() { Id = 2, UserId = user.Id, AccessToken = "Some Random Generated String 2", ExpirationDate = DateTime.Today.AddDays(1), InsideUser = user }; tokenRepository.Add(validToken); var validResult = provider.Validate((int)validToken.InsideUser.ClientId, validToken.AccessToken); var inValidResult = provider.Validate((int)validToken.InsideUser.ClientId, "Some Invalid Random String"); Assert.IsTrue(validResult); Assert.IsFalse(inValidResult); }