Exemple #1
0
        public static void ClassInitialize(TestContext context)
        {
            RestApiHelper <Parameters> restApi = new RestApiHelper <Parameters>("3.0");
            string operationName = "stations";
            string id            = "5d3afec76c634e000131c036";
            NameValueCollection paramCollection = new NameValueCollection();

            paramCollection.Add("APPID", appid);

            string jsonRequest = @"{
                                    ""external_id"": ""SF_TEST001"",
                                    ""name"": ""San Francisco Test Station"",
                                    ""longitude"": -122.43,
                                    ""latitude"": 37.76,
                                    ""altitude"": 150
                                  }";

            var restUrl     = restApi.SetUrl(restApi.QueryBuilder(operationName, id, paramCollection));
            var restRequest = restApi.CreatePutRequest(jsonRequest);

            restApi.GetResponse(restUrl, restRequest);
        }
Exemple #2
0
        public void RestSharpTestStationsPut()
        {
            RestApiHelper <Parameters> restApi = new RestApiHelper <Parameters>("3.0");
            string operationName = "stations";
            string id            = "5d3afec76c634e000131c036";
            NameValueCollection paramCollection = new NameValueCollection();

            paramCollection.Add("APPID", appid);

            var        restUrl     = restApi.SetUrl(restApi.QueryBuilder(operationName, id, paramCollection));
            var        restRequest = restApi.CreateGetRequest();
            var        response    = restApi.GetResponse(restUrl, restRequest);
            Parameters content     = restApi.GetContent <Parameters>(response);

            Assert.AreEqual("San Francisco Test Station", content.name); string nameValueBefore = content.name;
            Assert.AreEqual(-122.43, content.longitude); double longitudeValueBefore            = content.longitude;
            Assert.AreEqual(37.76, content.latitude); double    latitudeValueBefore             = content.latitude;
            Assert.AreEqual(150, content.altitude); int         altitudeValueBefore             = content.altitude;


            string jsonRequest = @"{
                                    ""external_id"": ""SF_UPD001"",
                                    ""name"": ""Wowa-City"",
                                    ""latitude"": 20.20,
                                    ""longitude"": -20.20,
                                    ""altitude"": 20
                                  }";


            restRequest = restApi.CreatePutRequest(jsonRequest);
            response    = restApi.GetResponse(restUrl, restRequest);
            content     = restApi.GetContent <Parameters>(response);
            Assert.AreNotEqual(nameValueBefore, content.name);
            Assert.AreNotEqual(longitudeValueBefore, content.longitude);
            Assert.AreNotEqual(latitudeValueBefore, content.latitude);
            Assert.AreNotEqual(altitudeValueBefore, content.altitude);
        }