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); }
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); }
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(); }
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>>(); }
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); }
/// <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); }
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); }
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); }
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); }
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); }
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); }