예제 #1
0
        public UpdateCategoryTreeViaPatchFixture(OsdrWebTestHarness harness)
        {
            var categories = new List <TreeNode>()
            {
                new TreeNode("Projects", new List <TreeNode>()
                {
                    new TreeNode("Projects One"),
                    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);

            var nodeIds = GetNodeIdsForCategory(harness, CategoryId).Result.ToList();

            var guidOne   = nodeIds.ElementAt(0);
            var guidTwo   = nodeIds.ElementAt(1);
            var guidThree = nodeIds.ElementAt(2);

            var json = $@"[
              {{
                'id': '{guidOne}',
                'title': 'Level 0: Main Node 1',
                'children': [
                  {{ 'id': '{guidTwo}', 'title': 'Level 1: Node 1', 'children': null }},
                  {{ 'id': '{guidThree}', 'title': 'Level 1: Node 2', 'children': null }}
                ]
              }},
              {{ 'title': 'NoNameNode' }},
              {{ 'title': '1' }},
              {{ 'title': '2' }},
              {{ 'title': '3' }},
              {{ 'title': '4', 'children': [{{ 'title': '4-1' }}, {{ 'title': '4-2', 'children': [{{ 'title': '4-2-1' }}] }}] }}
            ]";

            var url  = $"/api/categorytrees/tree/{CategoryId}";
            var data = $"[{{'op':'replace','path':'nodes','value': {json} }}]";

            response = harness.JohnApi.PatchData(url, data).Result;
            harness.WaitWhileCategoryTreeUpdatedPersisted(CategoryId);
        }
예제 #2
0
        public UpdateCategoryTreeFixture(OsdrWebTestHarness harness)
        {
            var categories = new List <TreeNode>()
            {
                new TreeNode("Projects", new List <TreeNode>()
                {
                    new TreeNode("Projects One"),
                    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);

            var nodeIds = GetNodeIdsForCategory(harness, CategoryId).Result.ToList();

            var guidOne   = nodeIds.ElementAt(0);
            var guidTwo   = nodeIds.ElementAt(1);
            var guidThree = nodeIds.ElementAt(2);

            var json = $@"[
              {{
                'id': '{guidOne}',
                'title': 'Level 0: Main Node 1',
                'children': [
                  {{ 'id': '{guidTwo}', 'title': 'Level 1: Node 1', 'children': null }},
                  {{ 'id': '{guidThree}', 'title': 'Level 1: Node 2', 'children': null }}
                ]
              }},
              {{ 'title': 'NoNameNode' }},
              {{ 'title': '1' }},
              {{ 'title': '2' }},
              {{ 'title': '3' }},
              {{ 'title': '4', 'children': [{{ 'title': '4-1' }}, {{ 'title': '4-2', 'children': [{{ 'title': '4-2-1' }}] }}] }}
            ]";

            categories = JsonConvert.DeserializeObject <List <TreeNode> >(json);

            response = harness.JohnApi.PutData($"/api/categorytrees/tree/{CategoryId}", categories).Result;

            harness.WaitWhileCategoryTreeUpdatedPersisted(CategoryId);
        }