示例#1
0
        public AddEntityCategoriesFixture(OsdrWebTestHarness harness)
        {
            var categories = new List <TreeNode>()
            {
                new TreeNode("Category Root", new List <TreeNode>()
                {
                    new TreeNode("My Test Category"),
                    new TreeNode("Projects Two")
                })
            };

            var response = harness.JohnApi.PostData("api/categorytrees/tree", categories).Result;

            var content = response.Content.ReadAsStringAsync().Result;

            CategoryId = Guid.Parse(content);

            harness.WaitWhileCategoryTreePersisted(CategoryId);

            BlobId = harness.JohnBlobStorageClient.AddResource(harness.JohnId.ToString(), "Chemical-diagram.png", new Dictionary <string, object>()
            {
                { "parentId", harness.JohnId }
            }).Result;

            FileId = harness.WaitWhileFileProcessed(BlobId);

            var fileNodeResponse = harness.JohnApi.GetNodeById(FileId).Result;
            var fileNode         = JsonConvert.DeserializeObject <JObject>(fileNodeResponse.Content.ReadAsStringAsync().Result);

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

            // add category to entity
            response = harness.JohnApi.PostData($"/api/categoryentities/entities/{FileNodeId}/categories", new List <Guid> {
                CategoryId
            }).Result;
            response.EnsureSuccessStatusCode();
            harness.WaitWhileCategoryIndexed(CategoryId.ToString());
        }