Пример #1
0
        public async Task can_get_many_agent_profiles()
        {
            // Arrange
            var request = new GetAgentProfilesRequest()
            {
                Agent = new Agent()
                {
                    Name = AGENT_NAME,
                    MBox = new Uri(AGENT_MBOX)
                },
                Since = SINCE
            };

            this._mockHttp
            .When(HttpMethod.Get, this.GetApiUrl("agents/profile"))
            .WithQueryString("agent", AGENT_QS)
            .WithQueryString("since", SINCE.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"))
            .Respond(HttpStatusCode.OK, "application/json", this.ReadDataFile(Constants.AGENT_PROFILES));

            // Act
            List <string> stateIds = await this._client.AgentProfiles.GetMany(request);

            // Assert
            stateIds.Should().NotBeNullOrEmpty();
        }
Пример #2
0
        private void CompleteOptions(RequestOptions options, GetAgentProfilesRequest request)
        {
            string agentStr = JsonConvert.SerializeObject(request.Agent, new JsonSerializerSettings()
            {
                DefaultValueHandling = DefaultValueHandling.Ignore
            });

            options.QueryStringParameters.Add("agent", agentStr);
            if (request.Since.HasValue)
            {
                options.QueryStringParameters.Add("since", request.Since.Value.ToString(Constants.DATETIME_FORMAT));
            }
        }
Пример #3
0
        async Task <List <string> > IAgentProfilesApi.GetMany(GetAgentProfilesRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            request.Validate();

            var options = new RequestOptions(ENDPOINT);

            this.CompleteOptions(options, request);

            HttpResponseMessage response = await this._client.GetJson(options);

            return(await response.Content.ReadAsAsync <List <string> >(new[] { new StrictJsonMediaTypeFormatter() }));
        }