コード例 #1
0
                public async Task ValidToken_ReturnsTrue()
                {
                    var token      = new SingleUseToken("token");
                    var clock      = Clock();
                    var expiration = clock.UtcNow.ToOffset().AddHours(1);
                    var service    = new FakeSingleUseTokenServiceBase(clock);

                    await service.Create(token, new UtcDateTime(expiration));

                    Assert.True(await service.Validate(token));
                }
コード例 #2
0
                public async Task TokenNotExists_ReturnsFalse()
                {
                    var token   = new SingleUseToken("token");
                    var clock   = Clock();
                    var service = new FakeSingleUseTokenServiceBase(clock)
                    {
                        Retrieve_ShouldReturnData = false
                    };

                    Assert.False(await service.Validate(token));
                }
コード例 #3
0
                public async Task TokenExpired_ReturnsFalse()
                {
                    var token      = new SingleUseToken("token");
                    var clock      = Clock();
                    var expiration = clock.UtcNow.ToOffset().AddHours(-1);
                    var service    = new FakeSingleUseTokenServiceBase(clock)
                    {
                        Retrieve_Output_Expiration = expiration
                    };

                    Assert.False(await service.Validate(token));
                }
コード例 #4
0
                public async Task TokenExpired_DeletesToken()
                {
                    var token      = new SingleUseToken("token");
                    var clock      = Clock();
                    var expiration = clock.UtcNow.ToOffset().AddHours(-1);
                    var service    = new FakeSingleUseTokenServiceBase(clock)
                    {
                        Retrieve_Output_Expiration = expiration
                    };

                    await service.Validate(token);

                    Assert.Equal(token.Value, service.Delete_InputData_Value);
                    Assert.Equal(expiration, service.Delete_InputData_Expiration);
                }