Example #1
0
        public async Task GetCollection()
        {
            var testItems = new[]
            {
                new TestResource {
                    Foo = "foo1"
                },
                new TestResource {
                    Foo = "foo2", Bar = true
                },
                new TestResource {
                    Foo = "foo3", Bar = false
                },
            };
            var mockRequestExecutor = new MockedCollectionRequestExecutor <TestResource>(pageSize: 2, items: testItems);
            var dataStore           = new DefaultDataStore(
                mockRequestExecutor,
                new DefaultSerializer(),
                new ResourceFactory(null, null),
                NullLogger.Instance);

            var client = new TestableOktaClient(dataStore);

            var items = await client.GetCollection <TestResource>("https://stuff").ToArray();

            items.Count().Should().Be(3);
            items.ElementAt(0).Foo.Should().Be("foo1");
            items.ElementAt(0).Bar.Should().BeNull();

            items.ElementAt(1).Foo.Should().Be("foo2");
            items.ElementAt(1).Bar.Should().Be(true);

            items.ElementAt(2).Foo.Should().Be("foo3");
            items.ElementAt(2).Bar.Should().Be(false);
        }
        public async Task GetCollection()
        {
            // Arrange
            var testItems = new[]
            {
                new TestResource {
                    Foo = "foo1"
                },
                new TestResource {
                    Foo = "foo2", Bar = true
                },
                new TestResource {
                    Foo = "foo3", Bar = false
                },
            };
            var mockRequestExecutor = new MockedCollectionRequestExecutor <TestResource>(pageSize: 2, items: testItems);
            var client = new TestableOktaClient(mockRequestExecutor);

            // Act
            var items = await client.GetCollection <TestResource>("https://stuff").ToArray();

            // Assert
            items.Count().Should().Be(3);
            items.ElementAt(0).Foo.Should().Be("foo1");
            items.ElementAt(0).Bar.Should().BeNull();

            items.ElementAt(1).Foo.Should().Be("foo2");
            items.ElementAt(1).Bar.Should().Be(true);

            items.ElementAt(2).Foo.Should().Be("foo3");
            items.ElementAt(2).Bar.Should().Be(false);
        }