Exemple #1
0
        public async Task AddPerson()
        {
            Setup();

            HCatalyst.Models.HCperson hcPerson = new HCatalyst.Models.HCperson {
                FirstName = "Bernard", LastName = "King", Street = "5 Valley Road", City = "Franklin Lakes", State = "NJ", Zip = "07321", Age = 50, Interests = "Basketball, Reading"
            };
            string sJSON = JsonConvert.SerializeObject(hcPerson);

            // Set the request message
            var request = new HttpRequestMessage(HttpMethod.Post, "api/HCpersons/");

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            StringContent stringContent = new StringContent(sJSON, Encoding.UTF8, "application/json");

            request.Content = stringContent;

            // Call API and get the response
            using (var response = await m_client.SendAsync(request))
            {
                // Ensure we have a Success Status Code
                response.EnsureSuccessStatusCode();

                // Read Response Content
                var content = await response.Content.ReadAsStringAsync();

                HCatalyst.Models.HCperson hcPersonAdded = JsonConvert.DeserializeObject <HCatalyst.Models.HCperson>(content);
                Assert.AreNotEqual(hcPersonAdded.ID, 0);
            }
        }
Exemple #2
0
        public async Task SearchContainsPerson()
        {
            Setup();

            HCatalyst.Models.HCperson hcPerson = new HCatalyst.Models.HCperson {
                LastName = "Smith"
            };
            string sJSON = JsonConvert.SerializeObject(hcPerson);

            // Set the request message
            var request = new HttpRequestMessage(HttpMethod.Post, "api/HCpersons/SearchContains");

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            StringContent stringContent = new StringContent(sJSON, Encoding.UTF8, "application/json");

            request.Content = stringContent;

            // Call API and get the response
            using (var response = await m_client.SendAsync(request))
            {
                // Ensure we have a Success Status Code
                response.EnsureSuccessStatusCode();

                // Read Response Content
                var content = await response.Content.ReadAsStringAsync();

                List <HCatalyst.Models.HCperson> ahcPerson = JsonConvert.DeserializeObject <List <HCatalyst.Models.HCperson> >(content);
            }
        }
Exemple #3
0
        public async Task GetPerson()
        {
            const int ID_VALUE_FOR_TESTING = 1;

            Setup();

            // Set the request message
            var request = new HttpRequestMessage(HttpMethod.Get, "api/HCpersons/" + ID_VALUE_FOR_TESTING.ToString());

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            // Call API and get the response
            using (var response = await m_client.SendAsync(request))
            {
                // Ensure we have a Success Status Code
                response.EnsureSuccessStatusCode();

                // Read Response Content
                var content = await response.Content.ReadAsStringAsync();

                HCatalyst.Models.HCperson hcPerson = JsonConvert.DeserializeObject <HCatalyst.Models.HCperson>(content);
                Assert.AreEqual(hcPerson.ID, ID_VALUE_FOR_TESTING);
            }
        }