Ejemplo n.º 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));
                }
Ejemplo n.º 2
0
                public async Task ExpirationAlreadyPassed_Throws()
                {
                    var token      = new SingleUseToken("token");
                    var clock      = Clock();
                    var expiration = clock.UtcNow.ToOffset().AddHours(-1);
                    var service    = new FakeSingleUseTokenServiceBase(clock);

                    await Assert.ThrowsAsync <InvalidOperationException>(async() =>
                    {
                        await service.Create(token, new UtcDateTime(expiration));
                    });
                }
Ejemplo n.º 3
0
                public async Task WhenCalled_CallsCreateOnService()
                {
                    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.Equal(token.Value, service.Create_InputData_Value);
                    Assert.Equal(expiration, service.Create_InputData_Expiration);
                }
Ejemplo n.º 4
0
                public async Task ValidToken_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.Create(token, new UtcDateTime(expiration));

                    await service.Validate(token);

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