Beispiel #1
0
                public void WhenCalled_SetsValue()
                {
                    var record = new SingleUseTokenData("value",
                                                        expiration: new UtcDateTime(DateTimeOffset.UtcNow));

                    Assert.Equal("value", record.Value);
                }
Beispiel #2
0
                public void WhenCalled_SetsExpiration()
                {
                    var expiration = DateTimeOffset.UtcNow;

                    var record = new SingleUseTokenData("value",
                                                        new UtcDateTime(expiration));

                    Assert.Equal(expiration.UtcTicks, record.Expiration.Ticks);
                }
Beispiel #3
0
        public virtual Task Create(SingleUseToken token, UtcDateTime expiration)
        {
            Guard.Null(nameof(token), token);

            var record = new SingleUseTokenData(token, expiration);

            if (record.IsExpired(this._clock))
            {
                throw new InvalidOperationException("Unable to create this token because it will have already expired.");
            }

            return(this.Create(record));
        }
Beispiel #4
0
 protected abstract Task Delete(SingleUseTokenData record);
Beispiel #5
0
 protected abstract Task Create(SingleUseTokenData record);