示例#1
0
        public virtual async Task <Location> Save(Location location)
        {
            await _locationRepository.CreateOrUpdateAsync(location);

            await _locationRepository.SaveChangesAsync();

            return(location);
        }
示例#2
0
        public async Task GetAllLocations()
        {
            // Initialize the database
            await _locationRepository.CreateOrUpdateAsync(_location);

            await _locationRepository.SaveChangesAsync();

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

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

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

            json.SelectTokens("$.[*].id").Should().Contain(_location.Id);
            json.SelectTokens("$.[*].streetAddress").Should().Contain(DefaultStreetAddress);
            json.SelectTokens("$.[*].postalCode").Should().Contain(DefaultPostalCode);
            json.SelectTokens("$.[*].city").Should().Contain(DefaultCity);
            json.SelectTokens("$.[*].stateProvince").Should().Contain(DefaultStateProvince);
        }