Example #1
0
        public async Task TestUpdate_NonFound()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.PostAsync(RequestUri,
                                                      new StringContent(
                                                          JsonConvert.SerializeObject(new Division()
                {
                    Id = 2,
                    Name = "Division1",
                    CreatedDateTime = DateTime.Now,
                }
                                                                                      ),
                                                          Encoding.UTF8,
                                                          "application/json"
                                                          )
                                                      );

                response = await client.PutAsync(RequestUri,
                                                 new StringContent(
                                                     JsonConvert.SerializeObject(new Division()
                {
                    Id = 2,
                    Name = "Division1",
                    CreatedDateTime = DateTime.Now,
                }
                                                                                 ),
                                                     Encoding.UTF8,
                                                     "application/json"
                                                     )
                                                 );

                Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
            }
        }
Example #2
0
        public async Task TestGet()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.PostAsync(RequestUri,
                                                      new StringContent(
                                                          JsonConvert.SerializeObject(new Realtor()
                {
                    Id = 1,
                    Firstname = "Firstname1",
                    Lastname = "Lastname1",
                    CreatedDateTime = DateTime.Now,
                }
                                                                                      ),
                                                          Encoding.UTF8,
                                                          "application/json"
                                                          )
                                                      );

                response = await client.GetAsync(RequestUri + "/1");

                response.EnsureSuccessStatusCode();
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
Example #3
0
        public async Task TestDelete_NoContent()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.PostAsync(RequestUri,
                                                      new StringContent(
                                                          JsonConvert.SerializeObject(new Division()
                {
                    Id = 6,
                    Name = "Division1",
                    CreatedDateTime = DateTime.Now,
                }
                                                                                      ),
                                                          Encoding.UTF8,
                                                          "application/json"
                                                          )
                                                      );

                response = await client.DeleteAsync(RequestUri + "/6");

                response.EnsureSuccessStatusCode();
                Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
            }
        }
Example #4
0
        public async Task TestDelete_NotFound()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.PostAsync(RequestUri,
                                                      new StringContent(
                                                          JsonConvert.SerializeObject(new Realtor()
                {
                    Id = 4,
                    Firstname = "Firstname2",
                    Lastname = "Lastname2",
                    CreatedDateTime = DateTime.Now,
                }
                                                                                      ),
                                                          Encoding.UTF8,
                                                          "application/json"
                                                          )
                                                      );

                response = await client.DeleteAsync(RequestUri + "/5");

                Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
            }
        }