public async void EchoPostNonFluentRawJsonContent() { var user = UserData.Create(); var json = JsonConvert.SerializeObject(user); var client = CreateClient(); var request = new HttpRequestMessage(HttpMethod.Post, client.HttpClient.BaseAddress); var builder = new SendBuilder(request).AppendPath("post").Post(); request.Content = new StringContent(json, Encoding.UTF8, "application/json"); var response = client.SendAsync(request); Assert.NotNull(response); var result = await response.Result.DeserializeAsync <EchoResult>(); Assert.NotNull(result); Assert.Equal(json, result.Data); Assert.True(result.Headers.ContainsKey("Content-Type")); var contentType = result.Headers["Content-Type"]; Assert.Equal("application/json; charset=utf-8", contentType); }
protected Task <FluentResponse> SendRequest(Action <SendBuilder> configure) { var request = _client.CreateRequest(); var builder = new SendBuilder(request); configure(builder); if (request.ContentData != null && !(request.ContentData is HttpContent)) { string mediaType = !String.IsNullOrEmpty(request.ContentType) ? request.ContentType : "application/json"; request.ContentData = new StringContent(_serializer.SerializeToString(request.ContentData), Encoding.UTF8, mediaType); } return(_client.SendAsync(request)); }
protected Task <FluentResponse> SendRequest(Action <SendBuilder> configure) { var request = _client.CreateRequest(); var builder = new SendBuilder(request); configure(builder); if (request.ContentData != null && request.ContentData.GetType() != typeof(string)) { request.ContentData = _serializer.SerializeToString(request.ContentData); if (!String.IsNullOrEmpty(request.ContentType)) { request.ContentType = "application/json"; } } return(_client.SendAsync(request)); }
public Task SendMail(Action <ISendBuilder> build, CancellationToken cancellationToken = default) { CancellationTokenSource cts = CancellationTokenSource.CreateLinkedTokenSource(_context.CancellationToken, cancellationToken); using (SendBuilder builder = new SendBuilder()) { if (_context.CorrelationId.HasValue) { builder.WithCorrelationId(_context.CorrelationId.Value); } build(builder); SendMail sendMail = builder.Build(); return(_context.Publish(sendMail, cts.Token)); } }
public TcsSend Direct(SendBuilder builder) { throw new NotImplementedException(); }
public static SendBuilder StatusCodeShouldBeOk(this SendBuilder scenario) { return(scenario.ExpectedStatus(HttpStatusCode.OK)); }
public static SendBuilder StatusCodeShouldBeUnauthorized(this SendBuilder scenario) { return(scenario.ExpectedStatus(HttpStatusCode.Unauthorized)); }
public static SendBuilder StatusCodeShouldBeBadRequest(this SendBuilder scenario) { return(scenario.ExpectedStatus(HttpStatusCode.BadRequest)); }
public static SendBuilder StatusCodeShouldBeAccepted(this SendBuilder scenario) { return(scenario.ExpectedStatus(HttpStatusCode.Accepted)); }