public void RaisesSingleEventWhileAddingRange() { var counter = 0; var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => counter++; fastCollection.AddItems(new[] { 1, 2, 3, 4, 5 }); Assert.AreEqual(1, counter); fastCollection.AddItems(new[] { 1, 2, 3, 4, 5 }, SuspensionMode.Adding); Assert.AreEqual(2, counter); fastCollection.AddItems(new ArrayList(new[] { 1, 2, 3, 4, 5 })); Assert.AreEqual(3, counter); fastCollection.AddItems(new ArrayList(new[] { 1, 2, 3, 4, 5 }), SuspensionMode.Adding); Assert.AreEqual(4, counter); }
public FastObservableCollection <Dish> LoadAllDishes() { FastObservableCollection <Dish> dishes = new FastObservableCollection <Dish>(); dishes.AddItems(_unitOfWork.Dishes.GetAll()); return(dishes); }
public void CreateOrders(FastObservableCollection <Order> orders) { orders.Clear(); var currentOrders = _unitOfWork.Orders.GetAll().Where(_ordersSelector).ToList(); currentOrders.Sort((o1, o2) => o2.Reservation.Day.CompareTo(o1.Reservation.Day)); orders.AddItems(currentOrders); }
public FastObservableCollection <Action> GetActions() { FillActionsList(); FastObservableCollection <Action> actions = new FastObservableCollection <Action>(); actions.AddItems(_actions); return(actions); }
public void CreateBonusDishes(FastObservableCollection <OrderedDish> bonusDishes) { bonusDishes.Clear(); var currentDishes = _unitOfWork.OrderedDishes.GetAll().Where(_orderedDishesSelector) .Where(od => od.OrderedPrice == 0).ToList(); // фильтруем только бонусы currentDishes.Sort((d1, d2) => d2.Order.Reservation.Day.CompareTo(d1.Order.Reservation.Day)); bonusDishes.AddItems(currentDishes); }
public HistoricItemsViewModel(IList <string> initialItems = null) { MaxHistory = 25; Items = new FastObservableCollection <string>(); if (initialItems != null) { Items.AddItems(initialItems); } CurrentItem = MostRecent; }
public void RaisesTwoEvents() { var eventArgsList = new List <NotifyCollectionChangedEventArgs>(); var fastCollection = new FastObservableCollection <int>(); fastCollection.AddItems(new[] { 1, 2, 3, 4 }); fastCollection.CollectionChanged += (sender, args) => { eventArgsList.Add(args); }; using (fastCollection.SuspendChangeNotifications(SuspensionMode.Mixed)) { fastCollection.RemoveItems(new[] { 4 }); fastCollection.AddItems(new[] { 5 }); } Assert.AreEqual(2, eventArgsList.Count); Assert.Contains(5, eventArgsList.First(args => args.Action == NotifyCollectionChangedAction.Add).NewItems); Assert.Contains(4, eventArgsList.First(args => args.Action == NotifyCollectionChangedAction.Remove).OldItems); }
public void CreateOrderedDishes(FastObservableCollection <OrderedDish> orderedDishes) { orderedDishes.Clear(); var currentDishes = _unitOfWork.OrderedDishes.GetAll().Where(_orderedDishesSelector) .Where(od => od.OrderedPrice != 0).ToList(); // не считаем бонусы currentDishes.Sort((d1, d2) => d2.Order.Reservation.Day.CompareTo(d1.Order.Reservation.Day)); orderedDishes.AddItems(currentDishes); }
public void RaisesSingleEventWhileAddingRange() { int counter = 0; var fastCollection = new FastObservableCollection<int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => counter++; fastCollection.AddItems(new[] { 1, 2, 3, 4, 5 }); Assert.AreEqual(1, counter); }
/// <summary> /// получить все брони указанного столика за указанный день /// </summary> public FastObservableCollection <Reservation> GetDaylyReservationsForTable(string dayStr, int tableId) { DateTime day; FastObservableCollection <Reservation> returnList = new FastObservableCollection <Reservation>(); if (DateTime.TryParse(dayStr, out day)) { // дополняем список броней returnList.AddItems(_unitOfWork.Reservations.GetAll().Where(r => r.Day.Date == day.Date && r.TableId == tableId)); } return(returnList); }
public void RaisesSingleAddEventWhileAddingRangeWithoutSuspensionMode() { var eventArgs = default(NotifyCollectionChangedEventArgs); var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => eventArgs = e; fastCollection.AddItems(new[] { 1, 2, 3, 4, 5 }); Assert.AreEqual(NotifyCollectionChangedAction.Reset, eventArgs.Action); }
public void RaisesSingleRemoveEventIfTheAddedItemsAreASubSetOfTheRemovedItems() { var count = 0; NotifyCollectionChangedEventArgs eventArgs = null; var fastCollection = new FastObservableCollection <int>(); fastCollection.AddItems(new[] { 1, 2, 3, 4 }); fastCollection.CollectionChanged += (sender, args) => { count++; eventArgs = args; }; using (fastCollection.SuspendChangeNotifications(SuspensionMode.Mixed)) { fastCollection.RemoveItems(new[] { 4, 2, 3 }); fastCollection.AddItems(new[] { 2 }); } Assert.AreEqual(NotifyCollectionChangedAction.Remove, eventArgs.Action); Assert.AreEqual(1, count); Assert.AreEqual(new[] { 4, 3 }, eventArgs.OldItems.OfType <int>().ToArray()); }
private void setEntries(params VM[] viewModels) { _subItemList = viewModels.ToList(); FastObservableCollection <VM> all = All as FastObservableCollection <VM>; all.SuspendCollectionChangeNotification(); all.Clear(); all.NotifyChanges(); all.AddItems(viewModels); all.NotifyChanges(); if (EntriesChanged != null) { EntriesChanged(this, EventArgs.Empty); } }
public void RaisesSingleAddEventWhileAddingRangeInSuspensionModeMixed() { var eventArgs = default(NotifyCollectionChangedEventArgs); int count = 0; var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => { eventArgs = e; count++; }; fastCollection.AddItems(new[] { 1, 2, 3, 4, 5 }, SuspensionMode.Mixed); Assert.AreEqual(NotifyCollectionChangedAction.Add, eventArgs.Action); Assert.AreEqual(1, count); }
/// <summary> /// Resets the entries (via Clear and Add) in the ALL items collection /// with the entries in the <param name="viewModels"/> parameter. /// </summary> /// <param name="viewModels"></param> private void ResetAllEntries(params VM[] viewModels) { Logger.InfoFormat("_"); FastObservableCollection <VM> all = this.All as FastObservableCollection <VM>; all.SuspendCollectionChangeNotification(); try { all.Clear(); all.NotifyChanges(); all.AddItems(viewModels); } finally { all.NotifyChanges(); if (this.EntriesChanged != null) { this.EntriesChanged(this, EventArgs.Empty); } } }
public void SelectAllSections() { SelectedSections.AddItems(FeSectionPipe.GetAllSections(), true); }
public void ThrowsArgumentNullExceptionForNullCollection() { var fastCollection = new FastObservableCollection<int>(); ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => fastCollection.AddItems(null)); }
public void ThrowsArgumentNullExceptionForNullCollection() { var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => fastCollection.AddItems(null)); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => fastCollection.AddItems(null, SuspensionMode.Adding)); }
private void ReFillTables() { _myTables.Clear(); _myTables.AddItems(_unitOfWork.Tables.GetAll()); }
public void ThrowsArgumentNullExceptionForNullCollection() { var fastCollection = new FastObservableCollection <int>(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => fastCollection.AddItems(null)); }
public void ThrowsInvalidOperationExceptionForInvalidSuspensionMode() { var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; ExceptionTester.CallMethodAndExpectException <InvalidOperationException>(() => fastCollection.AddItems(new[] { 1, 2, 3, 4, 5 }, SuspensionMode.Removing)); }