Ejemplo n.º 1
0
        public TestT BuildFrom(MethodInfo method, TestT parentSuite)
        {
            TestSuite testT = new TestSuite(method.Name);
            NUnitFramework.ApplyCommonAttributes(method, testT);

            ArrayList hierachyNodeList = new ArrayList();
            foreach (ProviderReference reference in GetBuildersFor(method, parentSuite))
            {
                System.Collections.Specialized.ListDictionary contextProperties
                     = new System.Collections.Specialized.ListDictionary();
                //테스트 함수에 지정된 특성값을 계층노드의 속성으로 복사합니다.
                foreach (DictionaryEntry entry in testT.Properties)
                {
                    if ((string)entry.Key != DESCRIPTION
                        && (string)entry.Key != CATEGORIES)
                    {
                        contextProperties[entry.Key] = entry.Value;
                    }
                }

                HierachyNode baseNode = new HierachyNode(method.Name);
                baseNode = reference.GetInstance(baseNode, contextProperties) as HierachyNode;
                if (baseNode != null)
                {
                    hierachyNodeList.Add(baseNode);
                }
            }

            ArrayList testSuiteList = new ArrayList();
            foreach (HierachyNode hierachyNode in hierachyNodeList)
            {
                TestSuite testSuite = new TestSuite(hierachyNode.Name);
                this.BuildTestSuiteTree(method, ref testSuite, hierachyNode);
                testSuiteList.Add(testSuite);
            }

            if (testSuiteList.Count > 0)
            {
                if (testSuiteList.Count == 1)
                {
                    testT = testSuiteList[0] as TestSuite;
                }
                else
                {
                    testT = new TestSuite(method.Name);
                    NUnitFramework.ApplyCommonAttributes(method, testT);
                    foreach (TestSuite testSuite in testSuiteList)
                    {
                        testT.Add(testSuite);
                    }
                }
            }

            return testT;
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Create()
        {
            List <string> orgNames = new List <string>();

            HierachyNode node = new HierachyNode()
            {
                IncludeAncestors = true, IncludeChildren = true, IncludeDescendents = 0, IncludeSiblings = true, IncludeSubItems = true
            };

            node.ObjectKey = new ObjectKey()
            {
                ObjectType = "ObjectType_OrganisationUnit", Int32Value = 0
            };
            // POST request
            HttpResponseMessage response = await client.PostAsJsonAsync(API_LIST_HIERACHY, node);

            // Check response
            if (!response.IsSuccessStatusCode)
            {
                throw new System.ArgumentException(response.StatusCode.ToString(), "original");
            }
            // Get headers which contain organisation units
            var        responseDetail = response.Content.ReadAsStringAsync().Result;
            AllHeaders netObjects     = JsonConvert.DeserializeObject <AllHeaders>(responseDetail);

            // Get organisation ID from first header for each department
            for (int i = 0; i < netObjects.Headers.Length; i++)
            {
                orgNames.Add(netObjects.Headers[i].ObjectName);
            }
            Updated update = new Updated()
            {
                OrganisationName = GetSelectListItems(orgNames)
            };

            return(View(update));
        }
Ejemplo n.º 3
0
 private void HandleDragHierachyNodes(TreeData treeData, List<HierachyNode> nodes)
 {
     if (this.dragNode == null)
     {
         this.isDragging = false;
         this.dropNode = null;
     }
     int controlID = GUIUtility.GetControlID(FocusType.Passive);
     EventType typeForControl = Event.current.GetTypeForControl(controlID);
     if ((typeForControl == EventType.MouseDown) && (Event.current.button == 0))
     {
         for (int i = 0; i < nodes.Count; i++)
         {
             if ((nodes[i].rect.Contains(Event.current.mousePosition) && !this.GetHierachyNodeVisRect(nodes[i].rect).Contains(Event.current.mousePosition)) && !(nodes[i].group is TreeGroupRoot))
             {
                 this.dragClickPos = Event.current.mousePosition;
                 this.dragNode = nodes[i];
                 GUIUtility.hotControl = controlID;
                 Event.current.Use();
                 break;
             }
         }
     }
     if (this.dragNode != null)
     {
         this.dropNode = null;
         for (int j = 0; j < nodes.Count; j++)
         {
             if (nodes[j].rect.Contains(Event.current.mousePosition))
             {
                 TreeGroup ancestor = this.dragNode.group;
                 TreeGroup group = nodes[j].group;
                 if (((group != ancestor) && group.CanHaveSubGroups()) && ((treeData.GetGroup(ancestor.parentGroupID) != group) && !treeData.IsAncestor(ancestor, group)))
                 {
                     this.dropNode = nodes[j];
                     break;
                 }
             }
         }
         switch (typeForControl)
         {
             case EventType.MouseMove:
             case EventType.MouseDrag:
             {
                 Vector2 vector = this.dragClickPos - Event.current.mousePosition;
                 if (vector.magnitude > 10f)
                 {
                     this.isDragging = true;
                 }
                 Event.current.Use();
                 break;
             }
             default:
                 if ((typeForControl == EventType.MouseUp) && (GUIUtility.hotControl == controlID))
                 {
                     if (this.dropNode != null)
                     {
                         this.UndoStoreSelected(EditMode.Everything);
                         TreeGroup g = this.dragNode.group;
                         TreeGroup parent = this.dropNode.group;
                         treeData.SetGroupParent(g, parent);
                         this.m_WantCompleteUpdate = true;
                     }
                     else
                     {
                         base.Repaint();
                     }
                     this.dragNode = null;
                     this.dropNode = null;
                     GUIUtility.hotControl = 0;
                     Event.current.Use();
                 }
                 break;
         }
     }
 }
Ejemplo n.º 4
0
 private void BuildHierachyNodes(TreeData treeData, List<HierachyNode> nodes, TreeGroup group, int depth)
 {
     HierachyNode item = new HierachyNode {
         group = group,
         pos = new Vector3(0f, depth * this.hierachySpread.y, 0f)
     };
     nodes.Add(item);
     for (int i = 0; i < group.childGroupIDs.Length; i++)
     {
         TreeGroup group2 = treeData.GetGroup(group.childGroupIDs[i]);
         this.BuildHierachyNodes(treeData, nodes, group2, depth - 1);
     }
 }
Ejemplo n.º 5
0
        public async System.Threading.Tasks.Task CreateRequestImageUploadAsync()
        {
            var    ACCESS_TOKEN       = WebConfigurationManager.AppSettings["access_token"];
            var    API_LIST_HIERACHY  = WebConfigurationManager.AppSettings["api_list_hierachy"];
            var    API_CREATE_REQUEST = WebConfigurationManager.AppSettings["api_create_request"];
            var    API_ADD_DOCUMENT   = WebConfigurationManager.AppSettings["api_add_document"];
            string responseDetail     = "";

            HttpClient client = new HttpClient
            {
                BaseAddress = new Uri(WebConfigurationManager.AppSettings["apiBaseAddress"])
            };

            // Address SSL and TLS security issue.
            #region
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 |
                                                   SecurityProtocolType.Tls |
                                                   SecurityProtocolType.Tls11 |
                                                   SecurityProtocolType.Tls12;
            #endregion
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ACCESS_TOKEN);

            // Post to get organisation unit to a list of units.
            HierachyNode node = new HierachyNode()
            {
                IncludeAncestors = true, IncludeChildren = true, IncludeDescendents = 0, IncludeSiblings = true, IncludeSubItems = true
            };
            node.ObjectKey = new ObjectKey()
            {
                ObjectType = "ObjectType_OrganisationUnit", Int32Value = 0
            };
            // POST request
            HttpResponseMessage response = await client.PostAsJsonAsync(API_LIST_HIERACHY, node);

            // Check response
            if (!response.IsSuccessStatusCode)
            {
                throw new System.ArgumentException(response.StatusCode.ToString(), "Cannot get organisation units");
            }
            // Get headers which contain organisation units
            responseDetail = response.Content.ReadAsStringAsync().Result;
            AllHeaders netObjects = JsonConvert.DeserializeObject <AllHeaders>(responseDetail);


            // Get organisation ID from first header for each department
            int orgUnitId = netObjects.Headers[0].ObjectKey.Int32Value;
            // Create user object and changing the necessary fields.
            string[] changes = { "RequestDetail", "RequestorName", "OrganisationUnitID" };
            User     user    = new User();
            user.ChangeSet = new ChangeSet()
            {
                Changes = changes
            };
            user.ChangeSet.Updated = new Updated {
                RequestDetail = "This a request" + netObjects.Headers[0].ObjectName, RequestorName = "Jason Lee", OrganisationUnitID = orgUnitId
            };
            // POST request
            HttpResponseMessage createUserResponse = await client.PostAsJsonAsync(API_CREATE_REQUEST, user);

            // Check response
            if (!createUserResponse.IsSuccessStatusCode)
            {
                throw new System.ArgumentException(createUserResponse.StatusCode.ToString(), "Cannot create user");
            }
            // Get request ID
            string requestID = createUserResponse.Content.ReadAsStringAsync().Result;
            Debug.WriteLine(String.Format("Request ID: {0}    |     Organisation Name: {1}", requestID, netObjects.Headers[0].ObjectName));

            // Create Container for chosen Request. Change path to "Request" and use requestID.
            DocContainer con = new DocContainer()
            {
                DocumentDescription = "Request Image", Address = $"file://conquest_documents/Request/{requestID}/JasonTestImage.png", ContentType = "image/png",
            };
            con.ObjectKey = new ObjectKey()
            {
                ObjectType = "ObjectType_Request", Int32Value = int.Parse(requestID)
            };
            HttpResponseMessage createFileResponse = await client.PostAsJsonAsync(API_ADD_DOCUMENT, con);

            // Check response
            if (!createFileResponse.IsSuccessStatusCode)
            {
                throw new System.ArgumentException(createFileResponse.StatusCode.ToString(), "Cannot create file response");
            }
            Debug.WriteLine(createFileResponse.Content.ReadAsStringAsync().Result);

            // Upload image to container
            DocDataObject docDataObject = JsonConvert.DeserializeObject <DocDataObject>(createFileResponse.Content.ReadAsStringAsync().Result);

            var f         = System.IO.File.OpenRead("..\\..\\B.png");
            var content   = new StreamContent(f);
            var mpcontent = new MultipartFormDataContent();
            content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
            mpcontent.Add(content);

            HttpResponseMessage uploadDocumentResponse = await client.PutAsync(docDataObject.UploadUri, mpcontent);

            //Check response
            if (!uploadDocumentResponse.IsSuccessStatusCode)
            {
                throw new System.ArgumentException(uploadDocumentResponse.StatusCode.ToString(), "Cannot upload image");
            }
        }
Ejemplo n.º 6
0
        private void BuildTestSuiteTree(MethodInfo method, ref TestSuite testSuite, HierachyNode hierachyNode)
        {
            NUnitFramework.ApplyCommonAttributes(method, testSuite);
            //try
            //{
            //    NUnitFramework.ApplyCommonAttributes(method, testSuite);
            //}
            //catch
            //{
            //}
            foreach (DictionaryEntry entry in hierachyNode.Properties)
            {
                if (entry.Value is HierachyNodeProperty)
                {
                    HierachyNodeProperty prop = entry.Value as HierachyNodeProperty;
                    testSuite.Properties[entry.Key] = prop.Value;
                    if (string.IsNullOrEmpty(prop.Description) == false)
                    {
                        string key = string.Format(
                            "{0}_{1}",
                            HierachyNode.DESCRIPTION,
                            prop.Description);
                        testSuite.Properties[entry.Key] = prop.Value;
                    }
                }
                else
                {
                    testSuite.Properties[entry.Key] = entry.Value;
                }
            }

            if (hierachyNode.Nodes.Count > 0)
            {
                for (int index = 0; index < hierachyNode.Nodes.Count; index++)
                {
                    HierachyNode childNode = (HierachyNode)hierachyNode.Nodes[index];
                    TestSuite childTestSuite = new TestSuite(childNode.Name);
                    this.BuildTestSuiteTree(method, ref childTestSuite, childNode);
                    testSuite.Add(childTestSuite);
                }
            }
            else
            {
                ParameterizedMethodSuite methodSuite
                    = NUnitTestCaseBuilder.BuildParameterizedMethodSuite(method, testSuite)
                    as ParameterizedMethodSuite;

                if (methodSuite != null)
                {
                    if (methodSuite.Tests.Count > 0)
                    {
                        foreach (TestT item in methodSuite.Tests)
                        {
                            testSuite.Add(item);

                        }
                    }
                    else
                    {
                        //methodSuite..TestName = testSuite.TestName;
                        testSuite = methodSuite;
                    }
                }
            }
        }