Пример #1
0
        public async void Repo_Returns_Second_Page()
        {
            // arrange
            IItemRepository itemRepository     = new ItemRepository(new TestRepositoryContextFactory());
            IGenerationRule testGenerationRule = new TestGenerationRule();
            await itemRepository.FillRepositoryAsync(new ItemGenerator(testGenerationRule));

            // act
            var result = await itemRepository.GetItemsAsync(new GetItemsRequest(null, 2, testGenerationRule.ChildsOnLevel / 2));

            // assert
            Assert.True(result.Items.Count() == testGenerationRule.ChildsOnLevel / 2);
            Assert.True(result.Items.All(item => item.MaxValue == testGenerationRule.MaxDepth));
        }
Пример #2
0
        public void Data_Generated()
        {
            // arrange
            var           testGenerationRule = new TestGenerationRule();
            ItemGenerator generator          = new ItemGenerator(testGenerationRule);

            // act
            List <IItem> items = generator.GenerateItems();

            // assert
            int countOnFirstLevel = items.Count(item => item.Parent == null);

            Assert.True(countOnFirstLevel == testGenerationRule.ChildsOnLevel);
            Assert.True(items.All(item => item.MaxValue == testGenerationRule.MaxDepth));
            Assert.True(items.Count == CountNodesHelper(testGenerationRule.MaxDepth, testGenerationRule.ChildsOnLevel));
        }
Пример #3
0
        public async void Repo_Measure_Depth_Correct()
        {
            // arrange
            IItemRepository itemRepository     = new ItemRepository(new TestRepositoryContextFactory());
            IGenerationRule testGenerationRule = new TestGenerationRule();
            await itemRepository.FillRepositoryAsync(new ItemGenerator(testGenerationRule));

            int depthCounter = 0;

            // act
            var result = await itemRepository.GetItemsAsync(new GetItemsRequest(null, 1, testGenerationRule.ChildsOnLevel));

            while (result.Items.Any())
            {
                IItem item = result.Items.First();
                result = await itemRepository.GetItemsAsync(new GetItemsRequest(item.ItemId, 1, testGenerationRule.ChildsOnLevel));

                depthCounter++;
            }

            Assert.True(depthCounter == testGenerationRule.MaxDepth);
        }