public void MobileServiceCollectionCanContainsAndNotNotifies() { // Get the Books table MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection <Book, Book> collection = new MobileServiceCollection <Book, Book>(query); List <string> properties = new List <string>(); List <string> expectedProperties = new List <string>() { }; List <NotifyCollectionChangedAction> actions = new List <NotifyCollectionChangedAction>(); List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>() { }; Book book = new Book(); collection.Add(book); ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); bool contains = collection.Contains(book); Assert.AreEqual(true, contains); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }
public void MobileServiceCollectionCanContainsAndNotNotifies() { // Get the Books table MobileServiceTableQueryMock<Book> query = new MobileServiceTableQueryMock<Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection<Book, Book> collection = new MobileServiceCollection<Book, Book>(query); List<string> properties = new List<string>(); List<string> expectedProperties = new List<string>() { }; List<NotifyCollectionChangedAction> actions = new List<NotifyCollectionChangedAction>(); List<NotifyCollectionChangedAction> expectedActions = new List<NotifyCollectionChangedAction>() { }; Book book = new Book(); collection.Add(book); ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); bool contains = collection.Contains(book); Assert.AreEqual(true, contains); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }
private async void Geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { if (myBool || first) { pos = args.Position; try { string pur = App.u.TourPurchases; string[] purchases = pur.Split(','); items4 = await Table4.Where(t => purchases.Contains(t.Id)).ToCollectionAsync(); List <string> scrapeId = new List <string>(); foreach (Tour t in items4) { string[] temp = t.Scrap_List.Split(','); for (int i = 0; i < temp.Length; i++) { scrapeId.Add(temp[i]); } } myBool = false; first = false; items3 = await Table3.Where(t => (t.lat - pos.Coordinate.Latitude <0.0018018018 && t.lat - pos.Coordinate.Latitude> -0.0018018018 && t.lon - pos.Coordinate.Longitude <0.0018018020 && t.lon - pos.Coordinate.Longitude> -0.0018018020 && (t.UserId == App.userId || scrapeId.Contains(t.Id)) )).ToCollectionAsync(); myBool = true; first = true; //TODO : add logic to get only those he has bought or created // query updated , testing left if (items3.Count != 0) { first = false; myBool = false; foreach (Scrap s in items3) { if (id.Contains(s.Id)) { } else { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { textBox.Text = "Loading new Scrapes"; }); id.Add(s.Id); li.Add(s); string[] str = s.Point_List.Split(','); for (int i = 0; i < str.Length; i++) { string po = str[i]; items2 = await Table2.Where(t => t.Id == po).ToCollectionAsync(); Pointer p = new Pointer(); if (items2.Count > 0) { p = items2[0]; li3.Add(p); } }//all pointers loaded for one scrap for (int i = 0; i < li3.Count; i++) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { PointerViewAR p = new PointerViewAR(); p.Id = li3[i].Id; p.lat = li3[i].lat; p.lon = li3[i].lon; p.Pitch = li3[i].Pitch; p.Title = li3[i].Title; p.Yaw = li3[i].Yaw; p.Desc = li3[i].Desc; p.Media = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(li3[i].Media_Url)); li2.Add(p); }); } await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { textBox.Text = "Done"; }); } } foreach (Scrap s in li) { if (items3.Contains(s)) { } else { myBool = false; li.Remove(s); id.Remove(s.Id); string[] str = s.Point_List.Split(','); for (int i = 0; i < str.Length; i++) { string po = str[i]; //items2 = await Table2.Where(t => t.Id == po).ToCollectionAsync(); List <Pointer> p = new List <Pointer>(); p = li3.Where(tr => tr.Id == str[i]).ToList <Pointer>(); li3.Remove(p[0]); List <PointerViewAR> pt = new List <PointerViewAR>(); pt = li2.Where(tr => tr.Id == str[i]).ToList <PointerViewAR>(); li2.Remove(pt[0]); }//all pointers removed for one scrap } } myBool = true; } } catch (Exception ex) { myBool = true; } } }