Example #1
0
        public void ExecuteRequest_Post_Json()
        {
            MPRESTClient client = new MPRESTClient();

            var jsonObject = new JObject();

            jsonObject.Add("firstName", "Clark");
            jsonObject.Add("lastName", "Kent");
            jsonObject.Add("year", 2018);

            DummyClass dummy = new DummyClass("Dummy description", DateTime.Now, 1000);

            WebHeaderCollection headers = new WebHeaderCollection();

            headers.Add("x-idempotency-key", dummy.GetType().GUID.ToString());


            MPAPIResponse response     = client.ExecuteRequest(HttpMethod.POST, "https://httpbin.org/post", PayloadType.JSON, jsonObject, headers, 0, 0);
            JObject       jsonResponse = JObject.Parse(response.StringResponse.ToString());

            List <JToken> lastName = MPCoreUtils.FindTokens(jsonResponse, "lastName");

            Assert.AreEqual("Kent", lastName.First().ToString());

            List <JToken> year = MPCoreUtils.FindTokens(jsonResponse, "year");

            Assert.AreEqual("2018", year.First().ToString());
        }
Example #2
0
        public void IdempotentKey_MustBePresent()
        {
            DummyClass dummy = new DummyClass("Dummy description", DateTime.Now, 1000);

            Assert.IsNotEmpty(dummy.GetType().GUID.ToString());
        }