Exemplo n.º 1
0
        public void RemoveExpiredTokens()
        {
            var tokenRepository = new LocalRepository <Token>();
            var userRepository  = new Mock <IRepository <InsideUser> >();
            var provider        = new AccessTokenProvider(tokenRepository, userRepository.Object);
            var expiredToken    = new Token()
            {
                Id             = 1,
                UserId         = "NewGuidString",
                AccessToken    = "Some Random Generated String 1",
                ExpirationDate = DateTime.Today.AddDays(-1)
            };
            var validToken = new Token()
            {
                Id             = 2,
                UserId         = "NewGuidString2",
                AccessToken    = "Some Random Generated String 2",
                ExpirationDate = DateTime.Today.AddDays(1)
            };

            tokenRepository.Add(expiredToken);
            tokenRepository.Add(validToken);

            provider.RemoveExpired();

            Assert.AreEqual(1, tokenRepository.All().Count());
            Assert.AreEqual(validToken.ExpirationDate, tokenRepository.All().Single().ExpirationDate);
        }