Exemple #1
0
        public static async Task BeforeFeature()
        {
            _webFixture = new WebFixture();

            try
            {
                await _webFixture.Start();
            }
            catch (Exception)
            {
                _webFixture.Dispose();
                await _webFixture.EnsureNotRunning();

                throw;
            }
        }
Exemple #2
0
        public async Task DeleteOneCategoryToEntity()
        {
            var fileNodeResponse = await JohnApi.GetNodeById(FileId);

            var fileNode = await fileNodeResponse.Content.ReadAsJObjectAsync();

            var fileNodeId = Guid.Parse(fileNode.Value <string>("id"));

            var treeResponse = await JohnApi.GetData($"api/categorytrees/tree/{RootCategoryId}");

            var treeContent = await treeResponse.Content.ReadAsJObjectAsync();

            var categoryId1 = treeContent["nodes"][0]["children"][0]["id"].ToString();
            var categoryId2 = treeContent["nodes"][0]["children"][1]["id"].ToString();

            // add categories to entity
            await JohnApi.PostData($"/api/categoryentities/entities/{fileNodeId}/categories", new List <string> {
                categoryId1, categoryId2
            });

            WebFixture.WaitWhileCategoryIndexed(categoryId1.ToString());
            WebFixture.WaitWhileCategoryIndexed(categoryId2.ToString());
            // check if node exists by categoryId1
            var firstCategoryAddedNodeRequest = await JohnApi.GetData($"/api/categoryentities/categories/{categoryId1}");

            var firstCategoryAddedNode = await firstCategoryAddedNodeRequest.Content.ReadAsJArrayAsync();

            firstCategoryAddedNode.First().Value <string>("id").Should().Be(fileNodeId.ToString());

            // delete first category from node
            await JohnApi.DeleteData($"/api/categoryentities/entities/{fileNodeId}/categories/{categoryId1}");

            WebFixture.WaitWhileCategoryDeleted(categoryId1.ToString());
            // check if node contains categoryId1
            var firstCategoryDeletedNodeRequest = await JohnApi.GetData($"/api/categoryentities/categories/{categoryId1}");

            var firstCategoryDeletedNode = await firstCategoryDeletedNodeRequest.Content.ReadAsJArrayAsync();

            firstCategoryDeletedNode.Should().BeEmpty();

            var secondCategoryAddedNodeRequest = await JohnApi.GetData($"/api/categoryentities/categories/{categoryId2}");

            var secondCategoryAddedNode = await secondCategoryAddedNodeRequest.Content.ReadAsJArrayAsync();

            secondCategoryAddedNode.First().Value <string>("id").Should().Be(fileNodeId.ToString());
        }
        public async Task DeleteCategory_DeleteOneCategoryFromEntity_CategoryIdShouldBeRemovedFromEntity()
        {
            var fileNodeResponse = await JohnApi.GetNodeById(FileId);

            var fileNode = await fileNodeResponse.Content.ReadAsJObjectAsync();

            var fileNodeId = Guid.Parse(fileNode.Value <string>("id"));

            var treeRequest = await JohnApi.GetData($"api/categorytrees/tree/{RootCategoryId}");

            var treeContent = await treeRequest.Content.ReadAsJObjectAsync();

            var categoryId1 = treeContent["nodes"][0]["children"][0]["id"].ToString();
            var categoryId2 = treeContent["nodes"][0]["children"][1]["id"].ToString();

            // add categories to entity
            await JohnApi.PostData($"/api/categoryentities/entities/{fileNodeId}/categories", new List <string> {
                categoryId1, categoryId2
            });

            WebFixture.WaitWhileCategoryIndexed(fileNodeId.ToString());

            var firstCategoryAddedNode = await GetNodeByCategoryId(categoryId1);

            firstCategoryAddedNode.Value <string>("id").Should().Be(fileNodeId.ToString());

            // delete first category from node
            await JohnApi.DeleteData($"/api/categoryentities/entities/{fileNodeId}/categories/{categoryId1}");

            // check if node contains categoryId
            WebFixture.WaitWhileCategoryDeleted(categoryId1);
            var firstCategoryDeletedNode = await GetNodeByCategoryId(categoryId1);

            firstCategoryDeletedNode.Should().BeNull();

            var entityCategoryIdsRequest = await JohnApi.GetData($"/api/categoryentities/entities/{fileNodeId}/categories");

            var entityCategoryIds = await entityCategoryIdsRequest.Content.ReadAsJArrayAsync();

            entityCategoryIds.Should().HaveCount(1);
            entityCategoryIds.Single().Value <string>("id").Should().Be(categoryId2);
        }
        public async Task GetCategoriesIdsByEntityIdTest()
        {
            var fileNodeResponse = await JohnApi.GetNodeById(FileId);

            var fileNode = await fileNodeResponse.Content.ReadAsJObjectAsync();

            var fileNodeId = Guid.Parse(fileNode.Value <string>("id"));

            await JohnApi.PostData($"/api/categoryentities/entities/{fileNodeId}/categories", new List <Guid> {
                CategoryId
            });

            WebFixture.WaitWhileCategoryIndexed(CategoryId.ToString());

            var response = await JohnApi.GetData($"/api/categoryentities/entities/{fileNodeId}/categories");

            var categoriesIds = await response.Content.ReadAsJArrayAsync();

            categoriesIds.Single().Value <string>().Should().Be(CategoryId.ToString());
        }
 public ToDoListControllerTests(WebFixture <StartupStub> fixture)
 {
     _fixture = fixture;
 }
 public Blogs_Tests(WebFixture fixture)
 {
     _fixture = fixture;
 }