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()); }
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))); }
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); }); }