Ejemplo n.º 1
0
        public void AddLocationTest()
        {
            ILocationService <LocationInfo> locatioService = new LocationService(propertiesMock.Object);

            locatioService.AddItemAsync(location).Wait();

            var itemsResult = locatioService.GetItemsAsync();

            itemsResult.Wait();

            Assert.AreEqual(1, itemsResult.Result.Count());
            Assert.AreEqual(location, itemsResult.Result.First());
        }
Ejemplo n.º 2
0
        public void DeleteLocationTest()
        {
            ILocationService <LocationInfo> locatioService = new LocationService(propertiesMock.Object);

            locatioService.AddItemAsync(location).Wait();
            locatioService.DeleteItemAsync(location.Key).Wait();
            var itemsResult = locatioService.GetItemsAsync();

            itemsResult.Wait();

            Assert.AreEqual(0, itemsResult.Result.Count());
            Assert.IsFalse(itemsResult.Result.Any(item => item.Equals(location)));
        }
Ejemplo n.º 3
0
        private void InitializeItemsViewModel()
        {
            Title              = "Your Locations List";
            LocationInfos      = new ObservableCollection <LocationInfo>();
            LoadItemsCommand   = new Command(async() => await ExecuteLoadItemsCommand());
            DeleteItemsCommand = new Command(async location => await ExecuteDeleteLocationCommand(location));

            MessagingCenter.Subscribe <SearchPage, LocationInfo>(this, "AddItem", async(obj, item) =>
            {
                if (LocationInfos.Any(element => element.Key.Equals(item.Key)))
                {
                    return;
                }
                var weather      = await WeatherApiClient.GetCurrentWeather(item.Key);
                item.WeatherInfo = weather;
                LocationInfos.Add(item);
                await LocationService.AddItemAsync(item);
            });
        }