Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            //RestClientLib rcl = new RestClientLib();
            //rcl.

            //https://th-project.herokuapp.com/api/users
            string endPoint = @"https://th-project.herokuapp.com/api/users";
            var    client   = new RestClientLib(endPoint);
            var    json     = client.MakeRequest();


            Console.ReadLine();

            //var json = client.MakeRequest("?param=0");

            //var client = new RestClient(endpoint: endPoint,
            //                method: HttpVerb.POST,
            //                postData: "{'someValueToPost': 'The Value being Posted'}");

            //var client = new RestClient();
            //client.EndPoint = @"http:\\myRestService.com\api\"; ;
            //client.Method = HttpVerb.POST;
            //client.PostData = "{postData: value}";
            //var json = client.MakeRequest();
        }
Beispiel #2
0
        public void TestMethod1()
        {
            string endPoint = @"https://th-project.herokuapp.com/api/users";
            var    client   = new RestClientLib(endPoint);
            var    json     = client.MakeRequest();

            Assert.AreEqual("[]", json);
        }
Beispiel #3
0
        public void TestMethod4()
        {
            string endPoint = @"https://th-project.herokuapp.com/api/users/" + _id;
            var    client   = new RestClientLib(endPoint);

            client.Method = HttpVerb.DELETE;
            var json = client.MakeRequest();

            dynamic jsonObj = JsonConvert.DeserializeObject(json);
            string  msg     = jsonObj.message.ToString();

            Assert.AreEqual(msg, "user deleted successfully!");
        }
Beispiel #4
0
        public void TestMethod3()
        {
            string endPoint = @"https://th-project.herokuapp.com/api/users/" + _id;
            var    client   = new RestClientLib(endPoint);

            client.Method = HttpVerb.GET;
            var json = client.MakeRequest();

            dynamic jsonObj = JsonConvert.DeserializeObject(json);
            string  id      = jsonObj._id.ToString();

            Assert.AreEqual(_id, id);
        }
Beispiel #5
0
        public void TestMethod2()
        {
            var client = new RestClientLib();

            client.EndPoint = @"https://th-project.herokuapp.com/api/users";
            client.Method   = HttpVerb.POST;

            Jsonuser JU = new Jsonuser();

            JU.first_name = "Tom";
            JU.last_name  = "Dick";
            JU.email      = "*****@*****.**";
            JU.phone      = "05612345678";

            client.PostData = JsonConvert.SerializeObject(JU);
            var json = client.MakeRequest();

            dynamic jsonObj = JsonConvert.DeserializeObject(json);

            _id = jsonObj._id.ToString();

            Assert.AreNotEqual("", _id);
        }