Ejemplo n.º 1
0
        public async Task GetCompetenciesAsync_WhenCalled_ReturnCompetenciesWithFilledLevelProperty()
        {
            var pager = new CompetencyPager {
                Results = new List <Competency> {
                    new Competency {
                        LevelId = 1
                    }, new Competency {
                        LevelId = 2
                    }
                }
            };
            var levels = new List <Level> {
                new Level {
                    Id = 1
                }, new Level {
                    Id = 2
                }
            } as IEnumerable <Level>;

            _requestsWrapper
            .Setup(rw => rw.GetAsyncWrapper <CompetencyPager>(It.IsAny <string>()))
            .Returns(Task.FromResult(pager));
            _requestsWrapper
            .Setup(rw => rw.GetAsyncWrapper <IEnumerable <Level> >(It.IsAny <string>())).
            Returns(Task.FromResult(levels));

            var result = await _amSpaceClient.GetCompetenciesAsync();

            CollectionAssert.AllItemsAreNotNull(result.Select(_ => _.Level));
        }
Ejemplo n.º 2
0
        public async Task GetCompetenciesAsync_WhenCalled_ReturnsIEnumerableOfCompetencyInstance()
        {
            var pager = new CompetencyPager {
                Results = new List <Competency>()
            };

            _requestsWrapper
            .Setup(rw => rw.GetAsyncWrapper <CompetencyPager>(It.IsAny <string>()))
            .Returns(Task.FromResult(pager));

            var result = await _amSpaceClient.GetCompetenciesAsync();

            Assert.IsInstanceOf <IEnumerable <Competency> >(result);
        }
Ejemplo n.º 3
0
        public async Task GetCompetenciesAsync_WhenCalled_ReturnContentFromEachPageOfPagers()
        {
            var pager1 = new CompetencyPager {
                Results = new List <Competency> {
                    new Competency {
                        Id = 1
                    }
                },
                Next = "a"
            };
            var pager2 = new CompetencyPager
            {
                Results = new List <Competency>
                {
                    new Competency {
                        Id = 2
                    },
                    new Competency {
                        Id = 3
                    }
                }
            };

            _requestsWrapper
            .SetupSequence(rw => rw.GetAsyncWrapper <CompetencyPager>(It.IsAny <string>()))
            .Returns(Task.FromResult(pager1))
            .Returns(Task.FromResult(pager2));

            var result = await _amSpaceClient.GetCompetenciesAsync();

            var allCompetency = pager1.Results;

            allCompetency.AddRange(pager2.Results);

            Assert.AreEqual(allCompetency, result);
        }