예제 #1
0
        public async Task taxaccountnumber_getbyidasync()
        {
            var httpclient = fixture.Client;

            if (String.IsNullOrEmpty(TokenTest.TokenValue))
            {
                await TokenTest.token_get(httpclient);
            }
            //
            var util = new UtilityExt();
            //MANUAL UPDATES REQUIRED!
            //todo - add if any parent of the entity
            //add entity
            var taxaccountnumberid = await util.addTaxAccountNumber(httpclient);

            //
            httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", TokenTest.TokenValue);
            var response = await httpclient.GetAsync("/api/taxaccountnumberasync/" + taxaccountnumberid.ToString());

            response.EnsureSuccessStatusCode();
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var jsonString = await response.Content.ReadAsStringAsync();

            var vmenitity = JsonConvert.DeserializeObject <TaxAccountNumberViewModel>(jsonString);

            Assert.True(vmenitity.TestText == "tt updated");

            //clean
            await util.removeTaxAccountNumber(httpclient, taxaccountnumberid);

            //remove if any parent entity added
        }
예제 #2
0
        public async Task taxaccountnumber_getallasync()
        {
            var httpclient = fixture.Client;

            if (String.IsNullOrEmpty(TokenTest.TokenValue))
            {
                await TokenTest.token_get(httpclient);
            }
            //
            var util = new UtilityExt();
            //MANUAL UPDATES REQUIRED!
            //todo - add parent of the entity if exist
            //add entity
            var taxaccountnumberid = await util.addTaxAccountNumber(httpclient);

            //
            httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", TokenTest.TokenValue);
            var response = await httpclient.GetAsync("/api/taxaccountnumberasync");

            response.EnsureSuccessStatusCode();
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var jsonString = await response.Content.ReadAsStringAsync();

            var vmenititys = (ICollection <UserViewModel>)JsonConvert.DeserializeObject <IEnumerable <UserViewModel> >(jsonString);

            Assert.True(vmenititys.Count > 0);
            // lazy-loading test if entity has children
            response = await httpclient.GetAsync("/api/taxaccountnumberasync/" + taxaccountnumberid.ToString());

            response.EnsureSuccessStatusCode();
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            jsonString = await response.Content.ReadAsStringAsync();

            var vmenitity = JsonConvert.DeserializeObject <TaxAccountNumberViewModel>(jsonString);
            //Assert.True(vmenitity.Kids.Count == 1);
            //clean
            await util.removeTaxAccountNumber(httpclient, taxaccountnumberid);

            //remove if any parent entity added
        }