示例#1
0
        public async void WebRequestBase_PostRequestTest()
        {
            const string endpoint = "https://httpbin.org/anything";
            const string jsonText = @"{ 
                    ""CaseID"": ""Unique File Name"",
                    ""Content"": ""StreamValue""
                    }";

            var request = new TestWebRequest <JObject>("https://httpbin.org/anything");

            var jsonBody = JToken.Parse(jsonText);

            var json = await request.PostAsync(jsonBody);

            Assert.NotNull(json);

            var result = json.ToObject <BinResult>();

            Assert.NotNull(result);
            Assert.Equal("POST", result.Method);
            Assert.Equal(endpoint, result.Url);
            Assert.Equal("Unique File Name", result.Json["CaseID"]?.Value <string>());
            Assert.Equal("StreamValue", result.Json["Content"]?.Value <string>());
        }