示例#1
0
        public async Task TestPost()
        {
            //arrange
            Restaurant rest = new Restaurant();

            rest.Name      = "Xpto";
            rest.CountryId = 1;
            rest.Address   = "1234, Road Street";

            //act
            var ret = await client.CreateAsync(rest);

            //assert
            Assert.AreEqual(rest.Name, ret.Name);
        }
示例#2
0
        public async Task TestDelete()
        {
            //arrange
            Restaurant rest = new Restaurant();

            rest.Name      = "Test DeleteAsync Restaurant";
            rest.CountryId = 1;
            rest.Address   = "1234, Road Street";

            //Creates the new restaurant
            var ret = await client.CreateAsync(rest);

            //act
            Assert.DoesNotThrow(async() => await client.DeleteAsync(ret.Id));

            try
            {
                //assert that deleted restaurant doesn't exist anymore
                var test = await this.client.GetOneAsync(ret.Id, "get");

                Assert.Fail("WebApiException expected");
            }
            catch (WebApiClientException e)
            {
                Assert.AreEqual(HttpStatusCode.NotFound, e.StatusCode);
            }
        }
示例#3
0
        public async Task TestCreateTooShortTimeoutUsingOptions()
        {
            //arrange
            Restaurant rest = new Restaurant();

            rest.Name      = "Xpto";
            rest.CountryId = 1;
            rest.Address   = "1234, Road Street";

            try
            {
                var resp = await client.CreateAsync(rest);

                Assert.Fail();
            }
            catch (WebApiClientException e)
            {
                Assert.AreEqual(HttpStatusCode.RequestTimeout, e.StatusCode);
            }
        }