Esempio n. 1
0
        public void HonorsTokenIsValidAbstractMember()
        {
            var sut = new TestExpiringTokenable(forceInvalid: true)
            {
                ExpirationDate = DateTime.UtcNow.AddHours(1)
            };

            Assert.False(sut.Valid);
        }
Esempio n. 2
0
        public void ValidIfWithinExpirationAndTokenReportsValid()
        {
            var sut = new TestExpiringTokenable
            {
                ExpirationDate = DateTime.UtcNow.AddHours(1)
            };

            Assert.True(sut.Valid);
        }
Esempio n. 3
0
        public void InvalidIfPastExpiryDate()
        {
            var sut = new TestExpiringTokenable
            {
                ExpirationDate = DateTime.UtcNow.AddHours(-1)
            };

            Assert.False(sut.Valid);
        }
Esempio n. 4
0
        public void ExpirationSerializationRoundTrip(DateTime expirationDate)
        {
            var sut = new TestExpiringTokenable
            {
                ExpirationDate = expirationDate
            };

            var intermediate = JsonSerializer.Serialize(sut);
            var result       = JsonSerializer.Deserialize <TestExpiringTokenable>(intermediate);

            Assert.Equal(sut.ExpirationDate, result.ExpirationDate, TimeSpan.FromMilliseconds(100));
        }
Esempio n. 5
0
        public void ExpirationSerializesToEpochMilliseconds(DateTime expirationDate)
        {
            var sut = new TestExpiringTokenable
            {
                ExpirationDate = expirationDate
            };

            var result       = JsonSerializer.Serialize(sut);
            var expectedDate = CoreHelpers.ToEpocMilliseconds(expirationDate);

            Assert.Contains($"\"ExpirationDate\":{expectedDate}", result);
        }