Esempio n. 1
0
        public void LocationGetCollectionTest(IDictionary testData)
        {
            #region Arrange

            var _testData = APITestManager.CreateUrlDataParametersDictionary(testData);

            var filter     = _testData["filter"].ToString();
            var sortColumn = _testData["sortColumn"].ToString();
            var sortOrder  = _testData["sortOrder"].ToString();
            var include    = _testData["Include"].ToString();
            var pageNumber = Convert.ToInt32(_testData["PageNumber"]);
            var pageSize   = Convert.ToInt32(_testData["PageSize"]);
            var token      = "";

            #endregion

            #region Act

            var queryString = APITestManager.doURLQueryString(_testData);
            var request     = new APIWebRequest();

            var username = testData["Username"].ToString().Trim();
            var password = testData["Password"].ToString().Trim();
            token = request.getToken(APITestManager.getAuthenticateUrl(), username, password);
            using (var testResponse = request.ProcessAPIWebRequest(appUrl, APIWebRequest.TypeCall.GetCollection, queryString, token))
            {
                var status_code     = testResponse.StatusCode;
                var response_body   = testResponse.Body;
                var expected_result = ConvertToStatusCode(testData["Result"]);

                #endregion

                #region Assert

                Assert.AreEqual(expected_result, status_code);
                APITestManager.displayResponse(testResponse);

                if (status_code == HttpStatusCode.OK)
                {
                    // to be implemented
                    // we have to compare collections from database and returned from API response
                }

                #endregion
            }
        }
Esempio n. 2
0
        public void LocationCountTest(IDictionary testData)
        {
            #region Arrange

            Dictionary <string, string> _testData = APITestManager.CreateUrlDataParametersDictionary(testData);
            var filter = _testData["filter"].ToString();
            var token  = "";

            #endregion

            #region Act

            var queryString = APITestManager.doURLQueryString(_testData);
            var request     = new APIWebRequest();

            var username = testData["Username"].ToString().Trim();
            var password = testData["Password"].ToString().Trim();
            token = request.getToken(APITestManager.getAuthenticateUrl(), username, password);
            using (var testResponse = request.ProcessAPIWebRequest(appUrl, APIWebRequest.TypeCall.Count, queryString, token))
            {
                var status_code     = testResponse.StatusCode;
                var response_body   = testResponse.Body;
                var expected_result = ConvertToStatusCode(testData["Result"]);

                #endregion

                #region Assert

                Assert.AreEqual(expected_result, status_code);
                APITestManager.displayResponse(testResponse);

                if (status_code == HttpStatusCode.OK)
                {
                    // to be implemented, we have to compare count returned from DB and count returned with the API response. Should be something like:
                    // CustomerDAO customerDAO = CustomerDAOFactory.getInstance();
                    // int expected_count = customerDAO.getCountWithFilter(filter);
                    // Assert.AreEqual(expected_count, Convert.ToInt32(response_body));
                }

                #endregion
            }
        }