public void CheckIfDeleteReturnsValidStatusCode()
        {
            ClassForRestIntegrationTest testModel = new ClassForRestIntegrationTest
            {
                Name = "TestName"
            };
            HttpResponseMessage         addResponse    = DoAddAsync(testModel).Result;
            ClassForRestIntegrationTest addedModel     = addResponse.Content.ReadAsJsonAsync <ClassForRestIntegrationTest>().Result;
            HttpResponseMessage         deleteResponse = DoDeleteAsync(addedModel).Result;

            Assert.Equal(HttpStatusCode.OK, deleteResponse.StatusCode);
        }
        public void CheckIfAddReturnsValidModel()
        {
            ClassForRestIntegrationTest testModel = new ClassForRestIntegrationTest
            {
                Name = "TestName"
            };
            HttpResponseMessage         addResponse = DoAddAsync(testModel).Result;
            ClassForRestIntegrationTest addedModel  = addResponse.Content.ReadAsJsonAsync <ClassForRestIntegrationTest>().Result;

            Assert.NotNull(addedModel);
            Assert.Equal(testModel.Name, addedModel.Name);
        }
        public void CheckIfGetReturnsValidStatusCode()
        {
            HttpResponseMessage addResponse = DoAddAsync(new ClassForRestIntegrationTest
            {
                Name = "TestName"
            }).Result;
            ClassForRestIntegrationTest addedModel = addResponse.Content.ReadAsJsonAsync <ClassForRestIntegrationTest>().Result;
            int addedModelId = addedModel.Id;
            HttpResponseMessage getResponse = DoGetAsync <ClassForRestIntegrationTest>(addedModelId).Result;

            Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
        }
        public void CheckIfAddReturnsValidLocationHeader()
        {
            HttpResponseMessage addResponse = DoAddAsync(new ClassForRestIntegrationTest
            {
                Name = "TestName"
            }).Result;
            ClassForRestIntegrationTest addedModel = addResponse.Content.ReadAsJsonAsync <ClassForRestIntegrationTest>().Result;
            int    addedModelId        = addedModel.Id;
            string addResponseLocation = addResponse.Headers.Location.ToString();
            string expectedLocation    = $"/api/{nameof(ClassForRestIntegrationTest)}/{addedModelId}";

            Assert.Equal(expectedLocation, addResponseLocation);
        }
        public void CheckIfUpdateReturnsValidLocationHeader()
        {
            ClassForRestIntegrationTest testModel = new ClassForRestIntegrationTest
            {
                Name = "TestName"
            };
            HttpResponseMessage         addResponse = DoAddAsync(testModel).Result;
            ClassForRestIntegrationTest addedModel  = addResponse.Content.ReadAsJsonAsync <ClassForRestIntegrationTest>().Result;

            addedModel.Name = "TestName2";
            HttpResponseMessage updateResponse = DoUpdateAsync(addedModel).Result;
            string updateResponseLocation      = updateResponse.Headers.Location.ToString();
            string expectedLocation            = $"/api/{nameof(ClassForRestIntegrationTest)}/{addedModel.Id}";

            Assert.Equal(expectedLocation, updateResponseLocation);
        }
        public void CheckIfUpdateReturnsValidModel()
        {
            string newModelName = "TestName2";
            ClassForRestIntegrationTest testModel = new ClassForRestIntegrationTest
            {
                Name = "TestName"
            };
            HttpResponseMessage         addResponse = DoAddAsync(testModel).Result;
            ClassForRestIntegrationTest addedModel  = addResponse.Content.ReadAsJsonAsync <ClassForRestIntegrationTest>().Result;

            addedModel.Name = newModelName;
            HttpResponseMessage         updateResponse = DoUpdateAsync(addedModel).Result;
            ClassForRestIntegrationTest updatedModel   = updateResponse.Content.ReadAsJsonAsync <ClassForRestIntegrationTest>().Result;

            Assert.Equal(addedModel.Id, updatedModel.Id);
            Assert.Equal(newModelName, updatedModel.Name);
        }