public async void Should_Get_All_Companies()
        {
            // given
            Company company_1 = new Company("company_name_1");
            Company company_2 = new Company("company_name_2");

            string        request     = JsonConvert.SerializeObject(company_1);
            StringContent requestBody = new StringContent(request, Encoding.UTF8, "application/json");
            await client.PostAsync("company/companies", requestBody);

            request     = JsonConvert.SerializeObject(company_2);
            requestBody = new StringContent(request, Encoding.UTF8, "application/json");
            await client.PostAsync("company/companies", requestBody);

            CompanyList companyList = new CompanyList();

            companyList.AddCompany(company_1);
            companyList.AddCompany(company_2);

            // when
            var response = await client.GetAsync("company/companies");

            // then
            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            List <Company> actualCompanies = JsonConvert.DeserializeObject <List <Company> >(responseString);
            List <Company> companies       = new List <Company>()
            {
                new Company("company_1", "company_name_1"),
                new Company("company_2", "company_name_2"),
            };

            Assert.Equal(companies, actualCompanies);
        }
Exemplo n.º 2
0
        public Company AddCompany(Company company)
        {
            if (!companies.ContainsCompany(company))
            {
                companies.AddCompany(company);
            }

            return(company);
        }