public async Task Collection_access_is_not_cached()
        {
            var cacheProvider = Caches.NewInMemoryCacheProvider().Build();

            this.BuildDataStore(FakeJson.AccountList, cacheProvider);

            IAsyncQueryable <IAccount> accounts = new CollectionResourceQueryable <IAccount>("/accounts", this.dataStore);
            await accounts.MoveNextAsync();

            IAsyncQueryable <IAccount> accounts2 = new CollectionResourceQueryable <IAccount>("/accounts", this.dataStore);
            await accounts2.MoveNextAsync();

            await this.dataStore.RequestExecutor.Received(2).ExecuteAsync(
                Arg.Any <IHttpRequest>(),
                Arg.Any <CancellationToken>());
        }
Ejemplo n.º 2
0
        public void Collection_access_is_not_cached()
        {
            var cacheProvider = Caches.NewInMemoryCacheProvider().Build();

            this.BuildDataStore(FakeJson.AccountList, cacheProvider);

            IQueryable <IAccount> accounts = new CollectionResourceQueryable <IAccount>("/accounts", this.dataStore).Synchronously();

            accounts.First();

            IQueryable <IAccount> accounts2 = new CollectionResourceQueryable <IAccount>("/accounts", this.dataStore);

            accounts2.First();

            this.dataStore.RequestExecutor.Received(2).Execute(
                Arg.Any <IHttpRequest>());
        }
        public async Task Collection_items_are_cached()
        {
            var cacheProvider = Caches.NewInMemoryCacheProvider().Build();

            this.BuildDataStore(FakeJson.AccountList, cacheProvider);

            IAsyncQueryable <IAccount> accounts = new CollectionResourceQueryable <IAccount>("/accounts", this.dataStore);
            await accounts.MoveNextAsync();

            var han = await this.dataStore.GetResourceAsync <IAccount>("/accounts/account1");

            han.Email.ShouldBe("*****@*****.**");
            han.FullName.ShouldBe("Han Solo");

            await this.dataStore.RequestExecutor.Received(1).ExecuteAsync(
                Arg.Any <IHttpRequest>(),
                Arg.Any <CancellationToken>());
        }
Ejemplo n.º 4
0
        public void Collection_items_are_cached()
        {
            var cacheProvider = Caches.NewInMemoryCacheProvider().Build();

            this.BuildDataStore(FakeJson.AccountList, cacheProvider);

            IQueryable <IAccount> accounts = new CollectionResourceQueryable <IAccount>("/accounts", this.dataStore);

            accounts.First();

            var han = this.dataStore.GetResource <IAccount>("/accounts/account1");

            han.Email.ShouldBe("*****@*****.**");
            han.FullName.ShouldBe("Han Solo");

            this.dataStore.RequestExecutor.Received(1).Execute(
                Arg.Any <IHttpRequest>());
        }
Ejemplo n.º 5
0
        public async Task Collection_resource_data_is_deserialized_properly()
        {
            var dataStore = TestDataStore.Create(new StubRequestExecutor(FakeJson.AccountList).Object);

            IAsyncQueryable <IAccount> accounts = new CollectionResourceQueryable <IAccount>("/accounts", dataStore);
            await accounts.MoveNextAsync();

            // Verify against data from FakeJson.AccountList
            (accounts as CollectionResourceQueryable <IAccount>).Size.ShouldBe(6);
            (accounts as CollectionResourceQueryable <IAccount>).Offset.ShouldBe(0);
            (accounts as CollectionResourceQueryable <IAccount>).Limit.ShouldBe(25);
            accounts.CurrentPage.Count().ShouldBe(6);

            var account = accounts.CurrentPage.First();

            account.CreatedAt.ShouldBe(Iso8601.Parse("2015-07-21T23:50:49.078Z"));
            account.Email.ShouldBe("*****@*****.**");
            account.FullName.ShouldBe("Han Solo");
            account.GivenName.ShouldBe("Han");
            account.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1");
            account.MiddleName.ShouldBeNull();
            account.ModifiedAt.ShouldBe(Iso8601.Parse("2015-07-21T23:50:49.078Z"));
            account.Status.ShouldBe(AccountStatus.Enabled);
            account.Surname.ShouldBe("Solo");
            account.Username.ShouldBe("*****@*****.**");

            (account as DefaultAccount).AccessTokens.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/accessTokens");
            (account as DefaultAccount).ApiKeys.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/apiKeys");
            (account as DefaultAccount).Applications.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/applications");
            (account as DefaultAccount).CustomData.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/customData");
            (account as DefaultAccount).Directory.Href.ShouldBe("https://api.stormpath.com/v1/directories/directory1");
            (account as DefaultAccount).EmailVerificationToken.Href.ShouldBeNull();
            (account as DefaultAccount).GroupMemberships.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/groupMemberships");
            (account as DefaultAccount).Groups.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/groups");
            (account as DefaultAccount).ProviderData.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/providerData");
            (account as DefaultAccount).RefreshTokens.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/refreshTokens");
            (account as DefaultAccount).Tenant.Href.ShouldBe("https://api.stormpath.com/v1/tenants/foobarTenant");
        }
        public async Task Collection_resource_data_is_deserialized_properly()
        {
            var dataStore = TestDataStore.Create(new StubRequestExecutor(FakeJson.AccountList).Object);

            IAsyncQueryable<IAccount> accounts = new CollectionResourceQueryable<IAccount>("/accounts", dataStore);
            await accounts.MoveNextAsync();

            // Verify against data from FakeJson.AccountList
            (accounts as CollectionResourceQueryable<IAccount>).Size.ShouldBe(6);
            (accounts as CollectionResourceQueryable<IAccount>).Offset.ShouldBe(0);
            (accounts as CollectionResourceQueryable<IAccount>).Limit.ShouldBe(25);
            accounts.CurrentPage.Count().ShouldBe(6);

            var account = accounts.CurrentPage.First();
            account.CreatedAt.ShouldBe(Iso8601.Parse("2015-07-21T23:50:49.078Z"));
            account.Email.ShouldBe("*****@*****.**");
            account.FullName.ShouldBe("Han Solo");
            account.GivenName.ShouldBe("Han");
            account.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1");
            account.MiddleName.ShouldBeNull();
            account.ModifiedAt.ShouldBe(Iso8601.Parse("2015-07-21T23:50:49.078Z"));
            account.Status.ShouldBe(AccountStatus.Enabled);
            account.Surname.ShouldBe("Solo");
            account.Username.ShouldBe("*****@*****.**");

            (account as DefaultAccount).AccessTokens.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/accessTokens");
            (account as DefaultAccount).ApiKeys.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/apiKeys");
            (account as DefaultAccount).Applications.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/applications");
            (account as DefaultAccount).CustomData.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/customData");
            (account as DefaultAccount).Directory.Href.ShouldBe("https://api.stormpath.com/v1/directories/directory1");
            (account as DefaultAccount).EmailVerificationToken.Href.ShouldBeNull();
            (account as DefaultAccount).GroupMemberships.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/groupMemberships");
            (account as DefaultAccount).Groups.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/groups");
            (account as DefaultAccount).ProviderData.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/providerData");
            (account as DefaultAccount).RefreshTokens.Href.ShouldBe("https://api.stormpath.com/v1/accounts/account1/refreshTokens");
            (account as DefaultAccount).Tenant.Href.ShouldBe("https://api.stormpath.com/v1/tenants/foobarTenant");
        }
        public async Task Collection_items_are_cached()
        {
            var cacheProvider = Caches.NewInMemoryCacheProvider().Build();
            this.BuildDataStore(FakeJson.AccountList, cacheProvider);

            IAsyncQueryable<IAccount> accounts = new CollectionResourceQueryable<IAccount>("/accounts", this.dataStore);
            await accounts.MoveNextAsync();

            var han = await this.dataStore.GetResourceAsync<IAccount>("/accounts/account1");
            han.Email.ShouldBe("*****@*****.**");
            han.FullName.ShouldBe("Han Solo");

            await this.dataStore.RequestExecutor.Received(1).ExecuteAsync(
                Arg.Any<IHttpRequest>(),
                Arg.Any<CancellationToken>());
        }
        public async Task Collection_access_is_not_cached()
        {
            var cacheProvider = Caches.NewInMemoryCacheProvider().Build();
            this.BuildDataStore(FakeJson.AccountList, cacheProvider);

            IAsyncQueryable<IAccount> accounts = new CollectionResourceQueryable<IAccount>("/accounts", this.dataStore);
            await accounts.MoveNextAsync();

            IAsyncQueryable<IAccount> accounts2 = new CollectionResourceQueryable<IAccount>("/accounts", this.dataStore);
            await accounts2.MoveNextAsync();

            await this.dataStore.RequestExecutor.Received(2).ExecuteAsync(
                Arg.Any<IHttpRequest>(),
                Arg.Any<CancellationToken>());
        }
        public void Collection_items_are_cached()
        {
            var cacheProvider = Caches.NewInMemoryCacheProvider().Build();
            this.BuildDataStore(FakeJson.AccountList, cacheProvider);

            IQueryable<IAccount> accounts = new CollectionResourceQueryable<IAccount>("/accounts", this.dataStore);
            accounts.First();

            var han = this.dataStore.GetResource<IAccount>("/accounts/account1");
            han.Email.ShouldBe("*****@*****.**");
            han.FullName.ShouldBe("Han Solo");

            this.dataStore.RequestExecutor.Received(1).Execute(
                Arg.Any<IHttpRequest>());
        }
        public void Collection_access_is_not_cached()
        {
            var cacheProvider = Caches.NewInMemoryCacheProvider().Build();
            this.BuildDataStore(FakeJson.AccountList, cacheProvider);

            IQueryable<IAccount> accounts = new CollectionResourceQueryable<IAccount>("/accounts", this.dataStore).Synchronously();
            accounts.First();

            IQueryable<IAccount> accounts2 = new CollectionResourceQueryable<IAccount>("/accounts", this.dataStore);
            accounts2.First();

            this.dataStore.RequestExecutor.Received(2).Execute(
                Arg.Any<IHttpRequest>());
        }