Ejemplo n.º 1
0
        public void AskingPartner_WithoutPartnerLoaded_GetsIt()
        {
            var expectedToken = new PartnerAccessTokenDtoBuilder().Build();
            var decorated     = new PartnerAccessTokenStubBuilder().WithGet(expectedToken).Build();
            var sut           = new MemoryCachedPartnerAccessTokenBuilder().WithPartner(decorated).Build();

            var actualToken = sut.Get().Result;

            Assert.AreEqual(expectedToken, actualToken);
            decorated.Received(1).Get();
        }
Ejemplo n.º 2
0
        public void AskingPartner_WithPartnerDtoExpired_GetsItAgain()
        {
            var decorated = new PartnerAccessTokenStubBuilder().WithGet(new PartnerAccessTokenDtoBuilder().WithExpiresIn(60)).Build();
            var sut       = new MemoryCachedPartnerAccessTokenBuilder()
                            .WithPartner(decorated)
                            .WithTime(new TimeProviderStubBuilder()
                                      .WithUtcNowInOrder(new DateTime(2000, 1, 1, 0, 0, 0))
                                      .WithUtcNowInOrder(new DateTime(2000, 1, 1, 0, 1, 0))
                                      .Build())
                            .Build();

            sut.Get().Wait();
            sut.Get().Wait();

            decorated.Received(2).Get();
        }