コード例 #1
0
        public async Task UpdateAsync(CancellationToken cancellationToken)
        {
            Mvx.TaggedTrace(Tag, "Update requested");

            if (!Outdated)
            {
                Mvx.TaggedTrace(Tag, "All data is up to date, update not required");

                return;
            }

            ClearData();

            var zipCodesGroupping = await LoadZipCodesGroupsAsync(cancellationToken);

            var cities = GetCities(zipCodesGroupping);

            CitiesRepository.AddAll(cities);

            var zipCodes = GetZipCodes(zipCodesGroupping, cities);

            ZipCodesRepository.AddAll(zipCodes);

            UpdateRepository.Updated = DateTime.UtcNow;

            Mvx.TaggedTrace(Tag, "Update completed");
        }
コード例 #2
0
        public void AddAll_CallsDataStore()
        {
            // arrange
            var dataStoreMock = new Mock <IDataStore>(MockBehavior.Loose);

            var repository = new CitiesRepository(
                dataStoreMock.Object
                );

            // act
            repository.AddAll(new[]
            {
                new CityModel
                {
                    Id   = 1,
                    Name = "1"
                }
            });

            // assert
            dataStoreMock.Verify(mock => mock.InsertAll(It.Is <IEnumerable <CityModel> >(item => item.First().Id == 1)), Times.Once());
        }