예제 #1
0
        /// <summary>
        /// To Get all companies as a list
        /// </summary>
        /// <param name="expectedStatusCode"></param>
        /// <returns></returns>
        public async Task <List <Company> > GetAllCompanies(HttpStatusCode expectedStatusCode)
        {
            var response = await Get($"{BaseUri}/companies/", "Company");

            var responseAsString = await response.Content.ReadAsStringAsync();

            ReportAssert.AreEqual(response.StatusCode, expectedStatusCode, "Expected and Actual Status Codes");
            return(JsonConvert.DeserializeObject <List <Company> >(responseAsString));
        }
예제 #2
0
        /// <summary>
        /// Deletes a company from the system
        /// </summary>
        /// <param name="name"></param>
        /// <param name="expectedStatusCode"></param>
        /// <returns></returns>
        public async Task <string> DeleteAddress(string name, HttpStatusCode expectedStatusCode)
        {
            var response = await Delete($"{BaseUri}/companies/{name}", "company");

            var responseAsString = await response.Content.ReadAsStringAsync();

            ReportAssert.AreEqual(response.StatusCode, expectedStatusCode, "Expected and Actual Status Codes");
            return(JsonConvert.DeserializeObject <string>(responseAsString));
        }
예제 #3
0
        /// <summary>
        /// Posts a new company to the system
        /// </summary>
        /// <param name="company"></param>
        /// <param name="expectedStatusCode"></param>
        /// <returns></returns>
        public async Task <List <Company> > PostCompany(Company company, HttpStatusCode expectedStatusCode)
        {
            Dictionary <string, object> newCompany = new Dictionary <string, object>();

            newCompany.Add("name", company.Name.TrimEnd());
            newCompany.Add("tel", company.Tel.TrimEnd());
            newCompany.Add("email", company.Email.TrimEnd());

            var companyString = JsonConvert.SerializeObject(newCompany, Formatting.Indented);
            var formValues    = new StringContent(companyString);
            var response      = await Post($"{BaseUri}/companies/", formValues, "Company");

            var responseAsString = await response.Content.ReadAsStringAsync();

            ReportAssert.AreEqual(response.StatusCode, expectedStatusCode, "Expected and Actual Status Codes");
            return(JsonConvert.DeserializeObject <List <Company> >(responseAsString));
        }