예제 #1
0
        public async Task CategoryTreeOperations_DeleteCategoryTree_ExpectedUpdatedCategory()
        {
            var response = await JohnApi.DeleteData($"/api/categorytrees/tree/{CategoryId}");

            response.EnsureSuccessStatusCode();
            Harness.WaitWhileCategoryTreeDeletePersisted(CategoryId);

            response = await JohnApi.GetData($"/api/categorytrees/tree/{CategoryId}");

            response.StatusCode.Should().Be(System.Net.HttpStatusCode.NotFound);
        }
예제 #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());
        }
예제 #3
0
        public async Task CategoryTreeOperations_DeleteNodeFromCategoryTree_ExpectedCategoryWithoutDeletedCategory()
        {
            //will be sure that we`re deleting node which exists
            var nodesIds = await GetNodeIdsForCategory(JohnApi, CategoryId);

            nodesIds.Should().Contain(ChildCategoryId);

            var response = await JohnApi.DeleteData($"/api/categorytrees/tree/{CategoryId}/{ChildCategoryId}");

            response.EnsureSuccessStatusCode();
            Harness.WaitWhileCategoryTreeNodeDeletePersisted(ChildCategoryId);

            //And now we got rid from it
            nodesIds = await GetNodeIdsForCategory(JohnApi, CategoryId);

            nodesIds.Should().NotContain(ChildCategoryId);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public async Task CategoryTreeOperations_DeleteNodeFromNonExistantCategoryTree_ReturnsNotFoundCode()
        {
            var response = await JohnApi.DeleteData($"/api/categorytrees/tree/{Guid.NewGuid()}/{ChildCategoryId}");

            response.StatusCode.Should().Be(HttpStatusCode.NotFound);
        }