A mock clock which you can get and set its current time.
Inheritance: IClock
        public void IsExpired_True()
        {
            var issued = DateTime.Now;
            var newNow = DateTime.Now.AddSeconds(200);

            var mockClock = new MockClock()
            {
                Now = newNow
            };

            // Issued not set.
            var response = new TokenResponse();
            Assert.True(response.IsExpired(mockClock));

            // ExpiresInSeconds is not set.
            response = new TokenResponse() { Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { ExpiresInSeconds = 1, Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { ExpiresInSeconds = 100, Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { ExpiresInSeconds = 140, Issued = issued };
            Assert.True(response.IsExpired(mockClock));
        }
        public void IsExpired()
        {
            var issued = DateTime.Now;
            var newNow = DateTime.Now.AddSeconds(100);

            var mockClock = new MockClock
            {
                Now = newNow
            };

            // Issued not set.
            var response = new TokenResponse();
            Assert.True(response.IsExpired(mockClock));

            // ExpiresInSeconds is not set.
            response = new TokenResponse() { Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 1, Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 100, Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 158, Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 159, Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 160, Issued = issued };
            Assert.True(response.IsExpired(mockClock));

            response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 161, Issued = issued };
            Assert.False(response.IsExpired(mockClock));

            response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 162, Issued = issued };
            Assert.False(response.IsExpired(mockClock));
        }
        public void IsExpired_False()
        {
            var issued = DateTime.Now;
            var newNow = DateTime.Now.AddSeconds(200);

            var mockClock = new MockClock()
            {
                Now = newNow
            };

            var response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 141, Issued = issued };
            Assert.False(response.IsExpired(mockClock));

            response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 142, Issued = issued };
            Assert.False(response.IsExpired(mockClock));
        }