예제 #1
0
        public void GetTagsByTraces_VerifyTags()
        {
            string           json    = @"{
                              ""success"": true,
                              ""messages"": [
                                ""Unique tags for organization loaded successfully""
                              ],
                              ""tags"": [
                                ""Infinite Scroll Test"",
                                ""Different test too""
                              ],
                              ""totalLibraryHashes"": 0
                            }";
            TagsTraceRequest request = new TagsTraceRequest();

            request.TracesId = new List <string> {
                "traceId1", "traceId2"
            };

            var mockSdkHttpClient = new Mock <IContrastRestClient>();

            mockSdkHttpClient.Setup(client => client.PostMessage("api/ng/orgId/tags/traces/bulk", JsonConvert.SerializeObject(request), null)).Returns(
                PostUtil.GetPostResponse(System.Net.HttpStatusCode.OK, json)
                );
            var teamServerClient = new TeamServerClient(mockSdkHttpClient.Object);
            var response         = teamServerClient.GetTagsByTraces("orgId", request);

            Assert.AreEqual(2, response.Tags.Count);
            Assert.AreEqual("Infinite Scroll Test", response.Tags[0]);
            Assert.AreEqual("Different test too", response.Tags[1]);
        }
        /// <summary>
        /// Get all tags by traces.
        /// </summary>
        /// <param name="organizationUuid">Organization UUID.</param>
        /// <param name="requestBody">A TagsTraceRequest object with a list of traces UUIDs.</param>
        /// <returns>A response with all the tags found.</returns>
        public TagsResponse GetTagsByTraces(string organizationUuid, TagsTraceRequest requestBody)
        {
            string endpoint = String.Format(NgEndpoints.TRACES_TAG_BULK, organizationUuid);

            return(GetResponseAndDeserialize <TagsResponse>(endpoint, JsonConvert.SerializeObject(requestBody), RequestMethod.Post));
        }