public void VisitedPlacePostTest(IDictionary testData)
        {
            #region Arrange

            var currentEntity = new VisitedPlaceDataObject();
            var include       = "";
            var token         = "";

            currentEntity.IsNew = Convert.ToBoolean(testData["IsNew"].ToString());

            if (!currentEntity.IsNew)
            {
                currentEntity.Id = System.Guid.Parse(testData["Id"].ToString().Trim());
                include          = testData["Include"].ToString().Trim();
            }
            currentEntity.CountryURI     = testData["CountryURI"]?.ToString().Trim() != null ? testData["CountryURI"]?.ToString().Trim().ToString() : null;
            currentEntity.Date           = Convert.ToDateTime(testData["Date"]?.ToString().Trim());
            currentEntity.Description    = testData["Description"]?.ToString().Trim() != null ? testData["Description"]?.ToString().Trim().ToString() : null;
            currentEntity.PlaceURI       = testData["PlaceURI"]?.ToString().Trim() != null ? testData["PlaceURI"]?.ToString().Trim().ToString() : null;
            currentEntity.Typeofplace    = (PlaceTypesEnum)Convert.ToInt32(testData["Type of place"]?.ToString().Trim());
            currentEntity.UserProfileUri = testData["UserProfileUri"]?.ToString().Trim() != null ? testData["UserProfileUri"]?.ToString().Trim().ToString() : null;
            var expected_result = ConvertToStatusCode(testData["Result"]);

            #endregion

            #region Act

            var json    = JsonConvert.SerializeObject(currentEntity);
            var postUrl = APITestManager.doPostRequestBody(json, include);

            APIWebRequest 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.Save, postUrl, token))
            {
                var status_code        = testResponse.StatusCode;
                var status_description = testResponse.Status;
                var response_body      = testResponse.Body;

                #endregion

                #region Assert

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

                if (status_code == HttpStatusCode.OK)
                {
                    // to be implemented
                }

                #endregion
            }
        }
        public void CountryPostTest(IDictionary testData)
        {
            #region Arrange

            var currentEntity = new CountryDataObject();
            var include       = "";
            var token         = "";

            currentEntity.IsNew = Convert.ToBoolean(testData["IsNew"].ToString());

            if (!currentEntity.IsNew)
            {
                currentEntity.URI = testData["URI"].ToString().Trim() != null ? testData["URI"].ToString().Trim().ToString() : null;
                include           = testData["Include"].ToString().Trim();
            }
            currentEntity.Abstract          = testData["Abstract"]?.ToString().Trim() != null ? testData["Abstract"]?.ToString().Trim().ToString() : null;
            currentEntity.Flag              = testData["Flag"]?.ToString().Trim() != null ? testData["Flag"]?.ToString().Trim().ToString() : null;
            currentEntity.LongName          = testData["Long Name"]?.ToString().Trim() != null ? testData["Long Name"]?.ToString().Trim().ToString() : null;
            currentEntity.Name              = testData["Name"]?.ToString().Trim() != null ? testData["Name"]?.ToString().Trim().ToString() : null;
            currentEntity.PopulationDensity = testData["Population Density"]?.ToString().Trim() == null ? (decimal?)null : Convert.ToDecimal(testData["Population Density"]?.ToString().Trim().Replace(".", ","));
            currentEntity.PopulationTotal   = Convert.ToInt64(testData["Population Total"]?.ToString().Trim());
            var expected_result = ConvertToStatusCode(testData["Result"]);

            #endregion

            #region Act

            var json    = JsonConvert.SerializeObject(currentEntity);
            var postUrl = APITestManager.doPostRequestBody(json, include);

            APIWebRequest 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.Save, postUrl, token))
            {
                var status_code        = testResponse.StatusCode;
                var status_description = testResponse.Status;
                var response_body      = testResponse.Body;

                #endregion

                #region Assert

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

                if (status_code == HttpStatusCode.OK)
                {
                    // to be implemented
                }

                #endregion
            }
        }
Example #3
0
        public void GORolePostTest(IDictionary testData)
        {
            #region Arrange

            var currentEntity = new GORoleDataObject();
            var include       = "";
            var token         = "";

            currentEntity.IsNew = Convert.ToBoolean(testData["IsNew"].ToString());

            if (!currentEntity.IsNew)
            {
                currentEntity.Name = testData["Name"].ToString().Trim() != null ? testData["Name"].ToString().Trim().ToString() : null;
                include            = testData["Include"].ToString().Trim();
            }
            currentEntity.Description           = testData["Description"]?.ToString().Trim() != null ? testData["Description"]?.ToString().Trim().ToString() : null;
            currentEntity.DisplayName           = testData["Display name"]?.ToString().Trim() != null ? testData["Display name"]?.ToString().Trim().ToString() : null;
            currentEntity.PasswordExpiry        = Convert.ToInt32(testData["Password Expiry"]?.ToString().Trim());
            currentEntity.PasswordPolicySummary = testData["Password Policy Summary"]?.ToString().Trim() != null ? testData["Password Policy Summary"]?.ToString().Trim().ToString() : null;
            currentEntity.PasswordRegEx         = testData["Password RegEx"]?.ToString().Trim() != null ? testData["Password RegEx"]?.ToString().Trim().ToString() : null;
            var expected_result = ConvertToStatusCode(testData["Result"]);

            #endregion

            #region Act

            var json    = JsonConvert.SerializeObject(currentEntity);
            var postUrl = APITestManager.doPostRequestBody(json, include);

            APIWebRequest 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.Save, postUrl, token))
            {
                var status_code        = testResponse.StatusCode;
                var status_description = testResponse.Status;
                var response_body      = testResponse.Body;

                #endregion

                #region Assert

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

                if (status_code == HttpStatusCode.OK)
                {
                    // to be implemented
                }

                #endregion
            }
        }
Example #4
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
            }
        }
        public void PlaceToLocationDeleteTest(IDictionary testData)
        {
            #region Arrange

            var    list          = new List <string>();
            string pkLocationURI = testData["LocationURI"].ToString().Trim();
            list.Add(pkLocationURI);
            string pkPlaceURI = testData["PlaceURI"].ToString().Trim();
            list.Add(pkPlaceURI);
            string pkString = string.Join("/", list.ToArray());
            string token    = "";

            #endregion

            #region Act

            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.Delete, pkString, 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.NoContent)
                {
                    // to be implemented
                    // add validation that entity was removed from DB, something like:
                    //CustomerDAO customerDAO = CustomerDAOFactory.getInstance();
                    //Customer customerDB = customerDAO.getCustomerByID(customer.id);
                    //Assert.IsNull(customerDB);
                }

                #endregion
            }
        }
Example #6
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
            }
        }
        public void PlaceToLocationGetTest(IDictionary testData)
        {
            #region Arrange

            var    list          = new List <string>();
            string pkLocationURI = testData["LocationURI"].ToString().Trim();
            list.Add(pkLocationURI);
            string pkPlaceURI = testData["PlaceURI"].ToString().Trim();
            list.Add(pkPlaceURI);
            string pkString = string.Join("/", list.ToArray());
            string token    = "";

            #endregion

            #region Act

            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.Get, pkString, 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
                }

                #endregion
            }
        }