static async Task <int> SendAsync(ClientFormSender clientFormSender, Guid guid) { var message = "{}"; var send = await clientFormSender.Send( route : "/SendMessage", message : message, typeName : "DedupMessage", destination : nameof(HttpPassthroughDedupTests), messageId : guid); return(send.httpStatus); }
async Task Foo(HttpClient httpClient) { #region ClientFormSender var clientFormSender = new ClientFormSender(httpClient); await clientFormSender.Send( route : "/SendMessage", message : "{\"Property\": \"Value\"}", typeName : "TheMessageType", typeNamespace : "TheMessageNamespace", destination : "TheDestination", attachments : new Dictionary <string, byte[]> { { "fileName", Encoding.UTF8.GetBytes("fileContents") } }); #endregion }
static async Task SubmitMultipartForm() { #region asptesthost var hostBuilder = new WebHostBuilder(); hostBuilder.UseStartup <Startup>(); using var testServer = new TestServer(hostBuilder); using var httpClient = testServer.CreateClient(); var clientFormSender = new ClientFormSender(httpClient); await clientFormSender.Send( route : "/SendMessage", message : "{\"Property\": \"Value\"}", typeName : "TheMessageType", typeNamespace : "TheMessageNamespace", destination : "TheDestination", attachments : new Dictionary <string, byte[]> { { "fileName", Encoding.UTF8.GetBytes("fileContents") } }); #endregion }
static async Task SubmitMultipartForm() { var hostBuilder = new WebHostBuilder(); hostBuilder.UseStartup <SampleStartup>(); using var server = new TestServer(hostBuilder); using var client = server.CreateClient(); client.DefaultRequestHeaders.Referrer = new Uri("http://TheReferrer"); var message = "{\"Property\": \"Value\"}"; var clientFormSender = new ClientFormSender(client); await clientFormSender.Send( route : "/SendMessage", message : message, typeName : "MyMessage", typeNamespace : "My.Namespace", destination : nameof(HttpPassthroughIntegrationTests), attachments : new Dictionary <string, byte[]> { { "fooFile", Encoding.UTF8.GetBytes("foo") }, { "default", Encoding.UTF8.GetBytes("bar") } }); }