Пример #1
0
            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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        public FastObservableCollection <Action> GetActions()
        {
            FillActionsList();
            FastObservableCollection <Action> actions = new FastObservableCollection <Action>();

            actions.AddItems(_actions);
            return(actions);
        }
Пример #5
0
        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;
 }
Пример #7
0
            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);
            }
Пример #8
0
        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);
        }
Пример #9
0
            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);
        }
Пример #11
0
            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);
            }
Пример #12
0
            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());
            }
Пример #13
0
        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);
            }
        }
Пример #14
0
            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);
                }
            }
        }
Пример #16
0
 public void SelectAllSections()
 {
     SelectedSections.AddItems(FeSectionPipe.GetAllSections(), true);
 }
Пример #17
0
 public void ThrowsArgumentNullExceptionForNullCollection()
 {
     var fastCollection = new FastObservableCollection<int>();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => fastCollection.AddItems(null));
 }
Пример #18
0
            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));
            }
Пример #19
0
 private void ReFillTables()
 {
     _myTables.Clear();
     _myTables.AddItems(_unitOfWork.Tables.GetAll());
 }
Пример #20
0
            public void ThrowsArgumentNullExceptionForNullCollection()
            {
                var fastCollection = new FastObservableCollection <int>();

                ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => fastCollection.AddItems(null));
            }
Пример #21
0
            public void ThrowsInvalidOperationExceptionForInvalidSuspensionMode()
            {
                var fastCollection = new FastObservableCollection <int>();

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                ExceptionTester.CallMethodAndExpectException <InvalidOperationException>(() => fastCollection.AddItems(new[] { 1, 2, 3, 4, 5 }, SuspensionMode.Removing));
            }