コード例 #1
0
        public virtual async Task <Country> Save(Country country)
        {
            await _countryRepository.CreateOrUpdateAsync(country);

            await _countryRepository.SaveChangesAsync();

            return(country);
        }
コード例 #2
0
        public async Task GetAllCountries()
        {
            // Initialize the database
            await _countryRepository.CreateOrUpdateAsync(_country);

            await _countryRepository.SaveChangesAsync();

            // Get all the countryList
            var response = await _client.GetAsync("/api/countries?sort=id,desc");

            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var json = JToken.Parse(await response.Content.ReadAsStringAsync());

            json.SelectTokens("$.[*].id").Should().Contain(_country.Id);
            json.SelectTokens("$.[*].countryName").Should().Contain(DefaultCountryName);
        }