Example #1
0
        public async Task TestPostDisease()
        {
            var symptoms = await(await client.GetAsync(symptomsRoute)).Content.ReadAsAsync <List <SymptomDTO> >();

            Assume.That((symptoms?.Count ?? 0) >= 3);


            var disease = new DiseaseDTO
            {
                Name     = "TestPostDisease",
                Symptoms = new List <SymptomDTO>()
            };

            for (int i = 0; i < 3; i++)
            {
                disease.Symptoms.Add(symptoms.ElementAt(i));
            }


            var result = await client.PostAsJsonAsync(diseasesRoute, disease);

            var resultDTO = await result.Content.ReadAsAsync <DiseaseDTO>();

            //Proper Status Code
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);


            //Returns all fields
            Assert.NotNull(resultDTO.Id);
            Assert.NotNull(resultDTO.Name);
            Assert.NotNull(resultDTO.Symptoms);

            //Returns with symptoms
            var symptom = resultDTO.Symptoms.FirstOrDefault();

            Assert.NotNull(symptom?.Id);
            Assert.NotNull(symptom?.Name);
        }