コード例 #1
0
        public async Task Edit()
        {
            var config = await this.Add();

            var template = await this._templateController.Add();

            var message = new HttpRequestMessage(HttpMethod.Put, API);
            var commond = new ConfigChangeCommand
            {
                Id         = config.Id,
                Name       = template.Name,
                Content    = template.Format,
                TemplateId = template.Id
            };

            message.AddJsonContent(commond);
            var responseMessage = await this.HttpClient.SendAsync(message);

            await responseMessage.AsResult();

            var newConfig = await this.Get(config.Id);

            Assert.NotEqual(commond.Name, config.Name);
            Assert.NotEqual(commond.Content, config.Content);
            Assert.NotEqual(commond.TemplateId, config.TemplateId);
            Assert.Equal(commond.Name, newConfig.Name);
            Assert.Equal(commond.TemplateId, newConfig.TemplateId);
            Assert.Equal(commond.Content, newConfig.Content);
        }
コード例 #2
0
        public async Task <Config> Add()
        {
            var solution = await this._solutionController.Add();

            var template = await this._templateController.Add();

            var commond = new ConfigCreateCommand
            {
                Name       = template.Name,
                Content    = template.Format,
                TemplateId = template.Id,
                SolutionId = solution.Id
            };
            var message = new HttpRequestMessage(HttpMethod.Post, API);

            message.AddJsonContent(commond);
            var responseMessage = await this.HttpClient.SendAsync(message);

            var id = await responseMessage.AsResult <string>();

            var config = await this.Get(id);

            Assert.Equal(commond.Name, config.Name);
            Assert.Equal(commond.Content, config.Content);
            Assert.Equal(commond.SolutionId, config.SolutionId);
            Assert.Equal(commond.TemplateId, config.TemplateId);
            return(config);
        }
コード例 #3
0
        private async Task SetConfigAsync(string url, object data)
        {
            var message = new HttpRequestMessage(HttpMethod.Post, url);

            message.AddJsonContent(data);

            var httpResponse = await this._client.SendAsync(message);

            httpResponse.EnsureSuccessStatusCode();
        }
コード例 #4
0
        public async Task<IEnumerable<BitmapEndpoint>> FindsAsync(IEnumerable<IPathDescriptor> descriptors)
        {
            var client = new HttpClient();

            var requestMessage = new HttpRequestMessage(HttpMethod.Get, this._options.BitmapEndpoint);

            requestMessage.AddJsonContent(descriptors);

            var responseMessage = await client.SendAsync(requestMessage);

            return await responseMessage.AsAsync<IEnumerable<BitmapEndpoint>>();
        }
コード例 #5
0
        public async Task <Solution> Add()
        {
            var command = new SolutionCreateCommand
            {
                Name = this.GetRandom()
            };
            var message = new HttpRequestMessage(HttpMethod.Post, API);

            message.AddJsonContent(command);
            var responseMessage = await this.HttpClient.SendAsync(message);

            var id = await responseMessage.AsResult <string>();

            var Solution = await this.Get(id);

            Assert.Equal(command.Name, Solution.Name);
            return(Solution);
        }
コード例 #6
0
        /// <summary>
        /// Internal method for building an HttpRequestMessage from a parent HttpRequest
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="client"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        private static HttpRequestMessage ToHttpRequestMessage <TRequestBody>(this HttpRequest httpRequest, HttpClient client, TRequestBody body, RequestForwardingOptions options = null)
        {
            var msg = new HttpRequestMessage();

            msg
            .CopyMethod(httpRequest)
            .CopyHeaders(httpRequest, client, options)
            .CopyCookies(httpRequest, options);

            if (options?.ForwardQueryString ?? true)
            {
                msg.CopyQueryString(httpRequest);
            }

            msg.AddJsonContent(body);

            return(msg);
        }
コード例 #7
0
        public async Task <Project> Add(string solutionId = "00000000000000000000")
        {
            var command = new ProjectCreateCommand
            {
                Name       = this.GetRandom(),
                SolutionId = solutionId
            };
            var message = new HttpRequestMessage(HttpMethod.Post, API);

            message.AddJsonContent(command);
            var responseMessage = await this.HttpClient.SendAsync(message);

            var id = await responseMessage.AsResult <string>();

            var project = await this.Get(id);

            Assert.Equal(command.Name, project.Name);
            Assert.Equal(command.Version, project.Version);
            return(project);
        }
コード例 #8
0
        public async Task Edit()
        {
            var Solution = await this.Add();

            var message = new HttpRequestMessage(HttpMethod.Put, API);
            var command = new SolutionChangeCommand
            {
                Id   = Solution.Id,
                Name = this.GetRandom()
            };

            message.AddJsonContent(command);
            var responseMessage = await this.HttpClient.SendAsync(message);

            await responseMessage.AsResult();

            var newSolution = await this.Get(Solution.Id);

            Assert.NotEqual(command.Name, Solution.Name);
            Assert.Equal(command.Name, newSolution.Name);
        }
コード例 #9
0
        public async Task <Template> Add()
        {
            var command = new TemplateCreateCommand
            {
                Name   = this.GetRandom(),
                Format = this.GetConfig()
            };
            var message = new HttpRequestMessage(HttpMethod.Post, API);

            message.AddJsonContent(command);
            var responseMessage = await this.HttpClient.SendAsync(message);

            var id = await responseMessage.AsResult <string>();

            var template = await this.Get(id);

            Assert.Equal(command.Name, template.Name);
            Assert.Equal(command.Format, template.Format);

            return(template);
        }
コード例 #10
0
        public async Task Edit()
        {
            var project = await this.Add();

            var message = new HttpRequestMessage(HttpMethod.Put, API);
            var command = new ProjectChangeCommand
            {
                Id      = project.Id,
                Name    = this.GetRandom(),
                Version = project.Version + 1
            };

            message.AddJsonContent(command);
            var responseMessage = await this.HttpClient.SendAsync(message);

            await responseMessage.AsResult();

            var newProject = await this.Get(project.Id);

            Assert.NotEqual(command.Name, project.Name);
            Assert.NotEqual(command.Version, project.Version);
            Assert.Equal(command.Name, newProject.Name);
            Assert.Equal(command.Version, newProject.Version);
        }
コード例 #11
0
        public async Task Edit()
        {
            var template = await this.Add();

            var message = new HttpRequestMessage(HttpMethod.Put, API);
            var command = new TemplateChangeCommand
            {
                Id     = template.Id,
                Format = this.GetConfig(),
                Name   = this.GetRandom()
            };

            message.AddJsonContent(command);
            var responseMessage = await this.HttpClient.SendAsync(message);

            await responseMessage.AsResult();

            var newTemplate = await this.Get(template.Id);

            Assert.NotEqual(command.Name, template.Name);
            Assert.NotEqual(command.Format, template.Format);
            Assert.Equal(command.Name, newTemplate.Name);
            Assert.Equal(command.Format, newTemplate.Format);
        }