public void SortTest()
        {
            SortableObservableCollection <TournamentVw> Tournaments = new SortableObservableCollection <TournamentVw>();

            Tournaments.Add(new TournamentVw(1, 1, "AMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(3, 1, "CMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(4, 1, "AMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(2, 1, "AMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(5, 1, "DMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(6, 1, "GMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(8, 1, "ZMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(7, 1, "KMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(10, 1, "LMyTournament", 0, 0, null, ""));
            Tournaments.Add(new TournamentVw(9, 1, "AMyTournament", 0, 0, null, ""));

            Tournaments.Sort(TournamentsViewModel.Comparison);

            Assert.AreEqual(1, Tournaments[0].Id);
            Assert.AreEqual(2, Tournaments[1].Id);
            Assert.AreEqual(4, Tournaments[2].Id);
            Assert.AreEqual(9, Tournaments[3].Id);
            Assert.AreEqual(3, Tournaments[4].Id);
            Assert.AreEqual(5, Tournaments[5].Id);
            Assert.AreEqual(6, Tournaments[6].Id);
            Assert.AreEqual(7, Tournaments[7].Id);
            Assert.AreEqual(10, Tournaments[8].Id);
            Assert.AreEqual(8, Tournaments[9].Id);
        }
Exemple #2
0
        // Поиск потомков узла дерева сыслающегося на строку с ключом node_id
        private SortableObservableCollection <INode> GetChildren(int node_id, IEnumerable <Collect> list)
        {
            SortableObservableCollection <INode> tree = new SortableObservableCollection <INode>();

            foreach (Collect t in list.Where(n => n.Parent_id == node_id))
            {
                if (t.Type == "sheet") // конечный узел дерева - "лист"
                {
                    CSheet sheet = new CSheet();
                    sheet.Id       = t.Id;
                    sheet.ParentId = t.Parent_id;
                    sheet.Name     = t.Collect_name;
                    sheet.Dat      = t.DDate;
                    tree.Add(sheet);
                }
                else
                {
                    CNode node = new CNode();
                    node.Id       = t.Id;
                    node.Name     = t.Collect_name;
                    node.Children = GetChildren(t.Id, list);
                    tree.Add(node);
                }
            }
            tree.Sort(t => t.Name);
            return(tree);
        }
		public ScheduleZoneDetailsViewModel(Schedule schedule, Organisation organisation)
		{
			Title = "Добавить новые зоны";
			ScheduleZone = new List<ScheduleZone>();

			Zones = new SortableObservableCollection<SelectationScheduleZoneViewModel>();
			var organisationResult = OrganisationHelper.GetSingle(organisation.UID);
			_doorUIDs = organisationResult != null ? organisationResult.DoorUIDs : new List<Guid>();

			var gkDoors = GKManager.Doors.Where(x => _doorUIDs.Any(y => y == x.UID));
			foreach (var door in gkDoors)
			{
				if (door.EnterZoneUID != Guid.Empty)
				{
					var enterZone = GKManager.SKDZones.FirstOrDefault(x => x.UID == door.EnterZoneUID);
					if (enterZone != null && !Zones.Any(x => x.ZoneUID == enterZone.UID))
						Zones.Add(new SelectationScheduleZoneViewModel(enterZone, schedule, door.UID));
				}

				if (door.ExitZoneUID != Guid.Empty)
				{
					var exitZone = GKManager.SKDZones.FirstOrDefault(x => x.UID == door.ExitZoneUID);
					if (exitZone != null && !Zones.Any(x => x.ZoneUID == exitZone.UID))
						Zones.Add(new SelectationScheduleZoneViewModel(exitZone, schedule, door.UID));
				}
			}

			Zones = new ObservableCollection<SelectationScheduleZoneViewModel>(Zones.OrderBy(x => x.No)); //TODO: 
			SelectedZone = Zones.FirstOrDefault();
		}
        public void SortPausedSoccerLiveMonitor()
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection.Add(new TestMatchVw()
            {
                SportDescriptor = SportSr.SPORT_DESCRIPTOR_SOCCER, IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinuteEx = 45, LivePeriodInfo = eLivePeriodInfo.Soccer_1st_Period, Name = "test1", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 2)
            });                                                                                                                                                                                                                                                                                                                                                                                         //should be third
            collection.Add(new TestMatchVw()
            {
                SportDescriptor = SportSr.SPORT_DESCRIPTOR_SOCCER, IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinuteEx = 45, LivePeriodInfo = eLivePeriodInfo.Paused, Name = "test2", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 1)
            });                                                                                                                                                                                                                                                                                                                                                                              //should be second
            collection.Add(new TestMatchVw()
            {
                SportDescriptor = SportSr.SPORT_DESCRIPTOR_SOCCER, IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinuteEx = 20, LivePeriodInfo = eLivePeriodInfo.Soccer_1st_Period, Name = "test3", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 2)
            });                                                                                                                                                                                                                                                                                                                                                                                         //should be forth
            collection.Add(new TestMatchVw()
            {
                SportDescriptor = SportSr.SPORT_DESCRIPTOR_SOCCER, IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinuteEx = 50, LivePeriodInfo = eLivePeriodInfo.Soccer_2nd_Period, Name = "test4", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 1)
            });                                                                                                                                                                                                                                                                                                                                                                                         //should be first

            var groupln = new GroupLn {
                Sort = { Value = 1 }
            };

            collection.Sort(LiveMonitorsService.Comparison);

            Assert.AreEqual("test4", collection[0].Name); //s
            Assert.AreEqual("test2", collection[1].Name); //s
            Assert.AreEqual("test1", collection[2].Name); //s
            Assert.AreEqual("test3", collection[3].Name); //s
        }
        /// <summary>
        /// Add a new filter argument to the list of filters and
        /// select this filter if <paramref name="bSelectNewFilter"/>
        /// indicates it.
        /// </summary>
        /// <param name="filterString"></param>
        /// <param name="bSelectNewFilter"></param>
        public void AddFilter(string filterString,
                              bool bSelectNewFilter = false)
        {
            var item = new FilterItemViewModel(filterString);

            _CurrentItems.Add(item);
            _CurrentItems.Sort(i => i.FilterDisplayName, ListSortDirection.Ascending);

            if (bSelectNewFilter == true)
            {
                this.SelectedItem = item;
            }
        }
		public GuardZonesSelectationViewModel(List<GKGuardZone> guardZones)
		{
			Title = "Выбор охранных зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			GuardZones = guardZones;
			TargetZones = new SortableObservableCollection<GKGuardZone>();
			SourceZones = new SortableObservableCollection<GKGuardZone>();

			foreach (var guardZone in GKManager.GuardZones)
			{
				if (GuardZones.Contains(guardZone))
					TargetZones.Add(guardZone);
				else
					SourceZones.Add(guardZone);
			}
			TargetZones.Sort(x => x.No);
			SourceZones.Sort(x => x.No);

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
		void UpdateDevices()
		{
			AvailableDevices = new SortableObservableCollection<GKDevice>();
			Devices = new SortableObservableCollection<GKDevice>();
			SelectedAvailableDevice = null;
			SelectedDevice = null;

			foreach (var device in SourceDevices)
			{
				if (!device.Driver.IsGroupDevice)
				{
					if (DevicesList.Contains(device))
						Devices.Add(device);
					else
						AvailableDevices.Add(device);
				}
			}
			Devices.Sort(x => x.IntDottedPresentationAddress);
			AvailableDevices.Sort(x => x.IntDottedPresentationAddress);

			SelectedDevice = Devices.FirstOrDefault();
			SelectedAvailableDevice = AvailableDevices.FirstOrDefault();

			OnPropertyChanged(() => Devices);
			OnPropertyChanged(() => AvailableDevices);
		}
		public DelaysSelectationViewModel(List<GKDelay> delays)
		{
			Title = "Выбор задержек";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Delays = delays;
			TargetDelays = new SortableObservableCollection<GKDelay>();
			SourceDelays = new SortableObservableCollection<GKDelay>();

			foreach (var delay in GKManager.DeviceConfiguration.Delays)
			{
				if (Delays.Contains(delay))
					TargetDelays.Add(delay);
				else
					SourceDelays.Add(delay);
			}
			TargetDelays.Sort(x => x.No);
			SourceDelays.Sort(x => x.No);

			SelectedTargetDelay = TargetDelays.FirstOrDefault();
			SelectedSourceDelay = SourceDelays.FirstOrDefault();
		}
		public MPTsSelectationViewModel(List<GKMPT> mpts, bool canCreateNew = false)
		{
			Title = "Выбор МПТ";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			MPTs = mpts;
			CanCreateNew = canCreateNew;
			TargetMPTs = new SortableObservableCollection<GKMPT>();
			SourceMPTs = new SortableObservableCollection<GKMPT>();

			foreach (var mpt in GKManager.DeviceConfiguration.MPTs)
			{
				if (MPTs.Contains(mpt))
					TargetMPTs.Add(mpt);
				else
					SourceMPTs.Add(mpt);
			}
			TargetMPTs.Sort(x => x.No);
			SourceMPTs.Sort(x => x.No);

			SelectedTargetMPT = TargetMPTs.FirstOrDefault();
			SelectedSourceMPT = SourceMPTs.FirstOrDefault();
		}
        private void ConvertMatchesToButtons(SortableObservableCollection <IMatchVw> matches, SortableObservableCollection <VFLMatchButton> vflMatchButtons)
        {
            SortableObservableCollection <VFLMatchButton> buttons = new SortableObservableCollection <VFLMatchButton>();
            int channel = 0;

            foreach (MatchVw match in matches.OrderBy(x => x.LineObject.BtrMatchId))
            {
                VFLMatchButton button = new VFLMatchButton(match.HomeCompetitorName, match.AwayCompetitorName, match.LineObject.BtrMatchId, match);
                button.Channel = channel++;
                buttons.Add(button);
            }

            if (vflMatchButtons.Count != 0)
            {
                if (buttons.Count == 0)
                {
                    vflMatchButtons.Clear();
                }

                if (vflMatchButtons[0].MatchVw.VirtualDay != buttons[0].MatchVw.VirtualDay)
                {
                    vflMatchButtons.Clear();
                }
            }
            if (vflMatchButtons.Count == 0)
            {
                foreach (var vflMatchButton in buttons)
                {
                    vflMatchButtons.Add(vflMatchButton);
                }
                vflMatchButtons.ElementAt(0).IsSelected = true;
                OnOpenVflPage(vflMatchButtons.ElementAt(0));
            }
        }
		public ZonesSelectationViewModel(List<GKZone> zones, bool canCreateNew = false)
		{
			Title = "Выбор зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Zones = zones;
			CanCreateNew = canCreateNew;
			TargetZones = new SortableObservableCollection<GKZone>();
			SourceZones = new SortableObservableCollection<GKZone>();

			foreach (var zone in GKManager.DeviceConfiguration.SortedZones)
			{
				if (Zones.Contains(zone))
					TargetZones.Add(zone);
				else
					SourceZones.Add(zone);
			}
			TargetZones.Sort(x => x.No);
			SourceZones.Sort(x => x.No);

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
Exemple #12
0
        /// <summary>
        /// Method can be invoked in PRISM MEF module registration to register a new document (viewmodel)
        /// type and its default file extension. The result of this call is an <seealso cref="IDocumentType"/>
        /// object and a <seealso cref="RegisterDocumentTypeEvent"/> event to inform listers about the new
        /// arrival of the new document type.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="description"></param>
        /// <param name="fileFilterName"></param>
        /// <param name="defaultFilter"></param>
        /// <param name="fileOpenMethod"></param>
        /// <param name="createDocumentMethod"></param>
        /// <param name="t"></param>
        /// <param name="sortPriority"></param>
        /// <returns></returns>
        public IDocumentType RegisterDocumentType(string key,
                                                  string description,
                                                  string fileFilterName,
                                                  string defaultFilter,
                                                  FileOpenDelegate fileOpenMethod,
                                                  CreateNewDocumentDelegate createDocumentMethod,
                                                  Type t,
                                                  int sortPriority = 0)
        {
            try
            {
                Messaging.Output.Append(string.Format("{0} Registering document type: {1} ...",
                                                      DateTime.Now.ToLongTimeString(), description));

                var newFileType = new DocumentType(key, description, fileFilterName, defaultFilter,
                                                   fileOpenMethod, createDocumentMethod,
                                                   t, sortPriority);

                _DocumentTypes.Add(newFileType);
                _DocumentTypes.Sort(i => i.SortPriority, ListSortDirection.Ascending);

                return(newFileType);
            }
            catch (Exception exp)
            {
                Messaging.Output.AppendLine(exp.Message);
                Messaging.Output.AppendLine(exp.StackTrace);
            }
            finally
            {
                Messaging.Output.AppendLine("Done.");
            }

            return(null);
        }
        private void Timer_Elapsed(object sender, EventArgs e)
        {
            if (ChangeTracker.Is34Mode || ChangeTracker.IsLandscapeMode)
            {
                var foundMatchdayMatches = new SortableObservableCollection <IMatchVw>();
                Repository.FindMatches(foundMatchdayMatches, "", SelectedLanguage, PrevMatchFilter, Comparison);
                if (foundMatchdayMatches.Count > 0)
                {
                    var previousMatchdayMatches = new SortableObservableCollection <IMatchVw>();
                    PrevMatchDay = foundMatchdayMatches.Last().VirtualDay;
                    PrevSeason   = foundMatchdayMatches.Last().VirtualSeason;
                    for (int i = foundMatchdayMatches.Count - 1; i >= 0; i--)
                    {
                        if (foundMatchdayMatches[i].VirtualDay == PrevMatchDay && foundMatchdayMatches[i].VirtualSeason == PrevSeason)
                        {
                            previousMatchdayMatches.Add(foundMatchdayMatches[i]);
                        }
                        else
                        {
                            break;
                        }
                    }


                    ConvertMatchesToButtons(previousMatchdayMatches, VflMatchButtons);
                }
            }
        }
		public DirectionsSelectationViewModel(List<GKDirection> directions)
		{
			Title = "Выбор направлений";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Directions = directions;
			TargetDirections = new SortableObservableCollection<GKDirection>();
			SourceDirections = new SortableObservableCollection<GKDirection>();

			foreach (var direction in GKManager.Directions)
			{
				if (Directions.Contains(direction))
					TargetDirections.Add(direction);
				else
					SourceDirections.Add(direction);
			}
			TargetDirections.Sort(x => x.No);
			SourceDirections.Sort(x => x.No);

			SelectedTargetDirection = TargetDirections.FirstOrDefault();
			SelectedSourceDirection = SourceDirections.FirstOrDefault();
		}
Exemple #15
0
		public void Initialize()
		{
			IsNowPlaying = false;
			Sounds = new SortableObservableCollection<SoundViewModel>();
			var stateClasses = new List<Tuple<XStateClass, SoundType>>();

			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire1, SoundType.Fire1));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire2, SoundType.Fire2));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Attention, SoundType.Attention));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire1, SoundType.Alarm));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Failure, SoundType.Failure));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Off, SoundType.Off));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.TurningOn, SoundType.TurningOn));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.TurningOff, SoundType.StopStart));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.AutoOff, SoundType.AutoOff));

			foreach (var stateClass in stateClasses)
			{
				var newSound = new Sound() { StateClass = stateClass.Item1, Type = stateClass.Item2 };

				var sound = ClientManager.SystemConfiguration.Sounds.FirstOrDefault(x => x.Type == stateClass.Item2);
				if (sound == null)
					ClientManager.SystemConfiguration.Sounds.Add(newSound);
				else
					newSound = sound;

				Sounds.Add(new SoundViewModel(newSound));
			}

			Sounds.Sort(x => EnumHelper.GetEnumDescription(x.SoundType));
			SelectedSound = Sounds.FirstOrDefault();

			if (ClientManager.SystemConfiguration.Sounds.RemoveAll(x => !Sounds.Any(y => y.SoundType == x.Type)) > 0)
				ServiceFactory.SaveService.SoundsChanged = true;
		}
		public PumpStationsSelectationViewModel(List<GKPumpStation> pumpStations)
		{
			Title = "Выбор насосных станций";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			PumpStations = pumpStations;
			TargetPumpStations = new SortableObservableCollection<GKPumpStation>();
			SourcePumpStations = new SortableObservableCollection<GKPumpStation>();

			foreach (var pumpStation in GKManager.PumpStations)
			{
				if (PumpStations.Contains(pumpStation))
					TargetPumpStations.Add(pumpStation);
				else
					SourcePumpStations.Add(pumpStation);
			}
			TargetPumpStations.Sort(x => x.No);
			SourcePumpStations.Sort(x => x.No);

			SelectedTargetPumpStation = TargetPumpStations.FirstOrDefault();
			SelectedSourcePumpStation = SourcePumpStations.FirstOrDefault();
		}
Exemple #17
0
		public void Update()
		{
			Parts = new SortableObservableCollection<SchedulePartViewModel>();
			foreach (var schedulePart in Schedule.ScheduleParts.OrderBy(x => x.DayNo))
			{
				var schedulePartViewModel = new SchedulePartViewModel(Schedule, schedulePart);
				Parts.Add(schedulePartViewModel);
			}
			SelectedPart = Parts.FirstOrDefault();
		}
        private void SelectedItemChanged(RoutedPropertyChangedEventArgs <object> obj)
        {
            object selected = obj.NewValue;

            if (selected == null)
            {
                return;
            }

            if (selected is SimpleTreeNodeViewModel)
            {
                SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)selected;
                _selectedNode = tvm;
                if (tvm.Node is Model.Feed)
                {
                    Articles = new SortableObservableCollection <Model.Article>(((Model.Feed)tvm.Node).Articles);
                }
                else if (tvm.Node is Model.Host)
                {
                    List <Model.Article> intermediate = new List <Model.Article>();
                    foreach (Model.Feed feed in ((Model.Host)tvm.Node).Feeds)
                    {
                        foreach (Model.Article a in feed.Articles)
                        {
                            intermediate.Add(a);
                        }
                    }
                    Articles = new SortableObservableCollection <Model.Article>(intermediate);
                }
                else
                {
                    if (_articles == null)
                    {
                        _articles = new SortableObservableCollection <Article>();
                    }
                    _articles.Clear();
                    foreach (Model.Host h in _allData)
                    {
                        foreach (Model.Feed feed in h.Feeds)
                        {
                            foreach (Model.Article a in feed.Articles)
                            {
                                _articles.Add(a);
                            }
                        }
                    }
                }
                SortedArticles.SortDescriptions.Clear();                                                           // Clear all
                SortedArticles.SortDescriptions.Add(new SortDescription("SortKey", ListSortDirection.Descending)); // Sort descending by "PropertyName"
                //Articles.OrderByDescending(el => el.SortKey);
            }
            RaisePropertyChanged("SortedArticles");
        }
Exemple #19
0
        public void Add(double r, double h)
        {
            Point p = new Point(r, h);

            if (_profile.Contains(p))
            {
                return;
            }
            else
            {
                _profile.Add(p);
            }

            if (_profile.Count > 1)
            {
                _profile.Sort <Point>((Point pt) => pt, _xascending);
            }
        }
		public GuardZonesWithFuncSelectationViewModel(GKDevice device, bool canCreateNew = false)
		{
			Title = "Выбор охранных зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Device = device;
			DeviceGuardZones = new ObservableCollection<DeviceGuardZoneViewModel>();
			foreach (var zone in device.GuardZones)
			{
				var guardZoneDevice = zone.GuardZoneDevices.FirstOrDefault(x => x.Device == device);
				if (guardZoneDevice != null)
				{
					var deviceGuardZone = new GKDeviceGuardZone();
					deviceGuardZone.GuardZone = zone;
					deviceGuardZone.GuardZoneUID = zone.UID;
					deviceGuardZone.ActionType = guardZoneDevice.ActionType;
					deviceGuardZone.CodeReaderSettings = guardZoneDevice.CodeReaderSettings;
					DeviceGuardZones.Add(new DeviceGuardZoneViewModel(deviceGuardZone, device));
				}
			}

			CanCreateNew = canCreateNew;
			TargetZones = new SortableObservableCollection<DeviceGuardZoneViewModel>();
			SourceZones = new SortableObservableCollection<DeviceGuardZoneViewModel>();

			foreach (var guardZone in GKManager.GuardZones)
			{
				var deviceGuardZone = DeviceGuardZones.FirstOrDefault(x => x.DeviceGuardZone.GuardZone == guardZone);
				if (deviceGuardZone != null)
					TargetZones.Add(deviceGuardZone);
				else
				{
					var gkDeviceGuardZone = new GKDeviceGuardZone();
					gkDeviceGuardZone.GuardZone = guardZone;
					gkDeviceGuardZone.GuardZoneUID = guardZone.UID;
					SourceZones.Add(new DeviceGuardZoneViewModel(gkDeviceGuardZone, device));
				}
			}

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
Exemple #21
0
        /// <summary>
        /// Method can be invoked in PRISM MEF module registration to register a new document (viewmodel)
        /// type and its default file extension. The result of this call is an <seealso cref="IDocumentType"/>
        /// object and a <seealso cref="RegisterDocumentTypeEvent"/> event to inform listers about the new
        /// arrival of the new document type.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="description"></param>
        /// <param name="fileFilterName"></param>
        /// <param name="defaultFilter"></param>
        /// <param name="fileOpenMethod"></param>
        /// <param name="createDocumentMethod"></param>
        /// <param name="t"></param>
        /// <param name="sortPriority"></param>
        /// <returns></returns>
        public IDocumentType RegisterDocumentType(string key,
                                                  string description,
                                                  string fileFilterName,
                                                  string defaultFilter,
                                                  FileOpenDelegate fileOpenMethod,
                                                  CreateNewDocumentDelegate createDocumentMethod,
                                                  Type t,
                                                  int sortPriority = 0)
        {
            var newFileType = new DocumentType(key, description, fileFilterName, defaultFilter,
                                               fileOpenMethod, createDocumentMethod,
                                               t, sortPriority);

            _mDocumentTypes.Add(newFileType);
            _mDocumentTypes.Sort(i => i.SortPriority, ListSortDirection.Ascending);

            return(newFileType);
        }
Exemple #22
0
        // Герерация структуры дерева из таблицы БД
        public void GenerateTree()
        {
            db.Collects.Load();

            IEnumerable <Collect> list = db.Collects.Local;

            SortableObservableCollection <INode> tree = new SortableObservableCollection <INode>();

            foreach (Collect t in db.Collects.Local.Where(t => t.Parent_id is null)) // выбираем корневые узлы дерева
            {
                CNode node = new CNode();
                node.Id       = t.Id;
                node.Name     = t.Collect_name;
                node.Children = GetChildren(t.Id, list); // поискпотомков корневого узла
                tree.Add(node);
            }
            tree.Sort(t => t.Name);
            treeColl.ItemsSource = tree;
        }
		public DoorsSelectationViewModel(List<GKDoor> doors, List<GKDoorType> doorsTypes = null)
		{
			Title = "Выбор точек доступа";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Doors = doors;
			TargetDoors = new SortableObservableCollection<GKDoor>();
			SourceDoors = new SortableObservableCollection<GKDoor>();

			var allDoors = GKManager.DeviceConfiguration.Doors;
			if (doorsTypes != null)
			{
				var filteredDoors = new List<GKDoor>();
				foreach (var door in allDoors)
					foreach (var doorType in doorsTypes)
					{
						if (door.DoorType == doorType)
						{
							filteredDoors.Add(door);
							break;
						}
					}
				allDoors = filteredDoors;
			}
			foreach (var door in allDoors)
			{
				if (Doors.Contains(door))
					TargetDoors.Add(door);
				else
					SourceDoors.Add(door);
			}
			TargetDoors.Sort(x => x.No);
			SourceDoors.Sort(x => x.No);

			SelectedTargetDoor = TargetDoors.FirstOrDefault();
			SelectedSourceDoor = SourceDoors.FirstOrDefault();
		}
Exemple #24
0
        private SortableObservableCollection <IMatchVw> FillCategoryWithTournaments(TestGroupVw category, int amount)
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            for (int i = 0; i < amount; i++)
            {
                collection.Add(new TestMatchVw()
                {
                    SportDescriptor = "SPRT_SOCCER",
                    DefaultSorting  = i,
                    IsLiveBet       = false,
                    IsOutright      = false,
                    Name            = "test1",
                    CategoryView    = category,
                    SportView       = new TestGroupVw()
                    {
                        DisplayName = "s", LineObject = new GroupLn()
                        {
                            GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = 3
                            }
                        }
                    },
                    StartDate      = new DateTime(2015, 1, 2),
                    TournamentView = new TestGroupVw()
                    {
                        DisplayName = "tournament" + i.ToString(), LineObject = new GroupLn()
                        {
                            GroupId = i, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = i
                            }
                        }
                    },
                    ExpiryDate = DateTime.Now.AddDays(365)
                });
            }

            return(collection);
        }
Exemple #25
0
        public void SortingTest()
        {
            var icehockeyresult = new MatchResultVw(new MatchResultLn()
            {
                MatchId = 2
            });

            SortableObservableCollection <MatchResultVw> icehockey = new SortableObservableCollection <MatchResultVw>();

            icehockey.Add(icehockeyresult);


            SyncList <MatchResultVw> basketballIcehockey = new SyncList <MatchResultVw>();

            basketballIcehockey.Add(new MatchResultVw(new MatchResultLn()
            {
                MatchId = 1
            }));
            basketballIcehockey.Add(icehockeyresult);

            icehockey.ApplyChanges(basketballIcehockey);

            Assert.AreEqual(2, icehockey.Count);
        }
        private void LoadDataInBackground()
        {
            if (App.RtmClient.TaskLists != null)
            {
                var tempTaskLists = new SortableObservableCollection<TaskList>();

                var tempOverdueTasks = new SortableObservableCollection<Task>();
                var tempTodayTasks = new SortableObservableCollection<Task>();
                var tempTomorrowTasks = new SortableObservableCollection<Task>();
                var tempWeekTasks = new SortableObservableCollection<Task>();
                var tempNoDueTasks = new SortableObservableCollection<Task>();

                var tempTags = new SortableObservableCollection<string>();

                foreach (TaskList l in App.RtmClient.TaskLists)
                {
                    tempTaskLists.Add(l);

                    if (l.IsNormal && l.Tasks != null)
                    {
                        foreach (Task task in l.Tasks)
                        {
                            // add tags
                            foreach (string tag in task.Tags)
                            {
                                if (!tempTags.Contains(tag)) tempTags.Add(tag);
                            }

                            if (task.IsIncomplete)
                            {
                                if (task.DueDateTime.HasValue)
                                {
                                    // overdue
                                    if (task.DueDateTime.Value < DateTime.Today || (task.HasDueTime && task.DueDateTime.Value < DateTime.Now))
                                    {
                                        tempOverdueTasks.Add(task);
                                    }
                                    // today
                                    else if (task.DueDateTime.Value.Date == DateTime.Today)
                                    {
                                        tempTodayTasks.Add(task);
                                    }
                                    // tomorrow
                                    else if (task.DueDateTime.Value.Date == DateTime.Today.AddDays(1))
                                    {
                                        tempTomorrowTasks.Add(task);
                                    }
                                    // this week
                                    else if (task.DueDateTime.Value.Date > DateTime.Today.AddDays(1) && task.DueDateTime.Value.Date <= DateTime.Today.AddDays(6))
                                    {
                                        tempWeekTasks.Add(task);
                                    }
                                }
                                else
                                {
                                    // no due
                                    tempNoDueTasks.Add(task);
                                }
                            }
                        }
                    }
                }

                tempOverdueTasks.Sort();
                tempTodayTasks.Sort();
                tempTomorrowTasks.Sort();
                tempWeekTasks.Sort();
                tempNoDueTasks.Sort();

                tempTags.Sort();

                SmartDispatcher.BeginInvoke(() =>
                {
                    TaskLists = tempTaskLists;

                    TodayTasks = tempTodayTasks;
                    TomorrowTasks = tempTomorrowTasks;
                    OverdueTasks = tempOverdueTasks;
                    WeekTasks = tempWeekTasks;
                    NoDueTasks = tempNoDueTasks;

                    Tags = tempTags;
                });
            }
        }
        public void SortSports()
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinute = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test1", SportDescriptor = "SPRT_BASKETBALL", SportView = new TestGroupVw()
                {
                    DisplayName = "b", LineObject = new GroupLn()
                    {
                        Sort = { Value = 3 }
                    }
                }, StartDate = new DateTime(2013, 1, 1), DefaultSorting = 3
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinute = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test2", SportDescriptor = "SPRT_SOCCER", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                }, StartDate = new DateTime(2013, 1, 1), DefaultSorting = 1
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinute = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test3", SportDescriptor = "SPRT_ICEH", SportView = new TestGroupVw()
                {
                    DisplayName = "h", LineObject = new GroupLn()
                    {
                        Sort = { Value = 4 }
                    }
                }, StartDate = new DateTime(2013, 1, 2), DefaultSorting = 4
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinute = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test4", SportDescriptor = "SPRT_TENNIS", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 1), DefaultSorting = 2
            });



            collection.Sort(LiveMonitorsService.Comparison);
            LiveMonitorsService.UpdateHeaders(collection);

            Assert.AreEqual("s", collection[0].SportView.DisplayName); //s
            Assert.AreEqual("t", collection[1].SportView.DisplayName); //s
            Assert.AreEqual("b", collection[2].SportView.DisplayName); //s
            Assert.AreEqual("h", collection[3].SportView.DisplayName); //s


            Assert.AreEqual(true, collection[0].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[1].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[2].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[3].IsHeaderForLiveMonitor);
        }
Exemple #28
0
        public async Task AddCatalogAsync(CatalogItem catalogItem)
        {
            await Task.Delay(10);

            MockCatalog.Add(catalogItem);
        }
        public void SameSport()
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection.Add(new TestMatchVw()
            {
                SportDescriptor = "SPRT_SOCCER", IsLiveBet = false, LiveBetStatus = eMatchStatus.Undefined, LiveMatchMinute = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test1", SportView = new TestGroupVw()
                {
                    DisplayName = "s"
                }, StartDate = new DateTime(2013, 1, 5)
            });

            collection.Add(new TestMatchVw()
            {
                SportDescriptor = "SPRT_SOCCER", IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinute = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test2", SportView = new TestGroupVw()
                {
                    DisplayName = "s"
                }, StartDate = new DateTime(2013, 1, 2)
            });

            collection.Add(new TestMatchVw()
            {
                SportDescriptor = "SPRT_SOCCER", IsLiveBet = false, LiveBetStatus = eMatchStatus.Undefined, LiveMatchMinute = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test3", SportView = new TestGroupVw()
                {
                    DisplayName = "s"
                }, StartDate = new DateTime(2013, 1, 3)
            });

            collection.Add(new TestMatchVw()
            {
                SportDescriptor = "SPRT_SOCCER", IsLiveBet = true, LiveBetStatus = eMatchStatus.Stopped, LiveMatchMinute = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test4", SportView = new TestGroupVw()
                {
                    DisplayName = "s"
                }, StartDate = new DateTime(2013, 1, 4)
            });


            collection.Sort(LiveMonitorsService.Comparison);
            LiveMonitorsService.UpdateHeaders(collection);

            Assert.AreEqual("test2", collection[0].Name); //s
            Assert.AreEqual("test4", collection[1].Name); //s
            Assert.AreEqual("test3", collection[2].Name); //s
            Assert.AreEqual("test1", collection[3].Name); //s


            Assert.AreEqual(true, collection[0].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[1].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[2].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[3].IsHeaderForLiveMonitor);


            collection = new SortableObservableCollection <IMatchVw>(collection.OrderByDescending(x => x.Name).ToList());

            collection.Sort(LiveMonitorsService.Comparison);
            LiveMonitorsService.UpdateHeaders(collection);

            Assert.AreEqual("test2", collection[0].Name); //s
            Assert.AreEqual("test4", collection[1].Name); //s
            Assert.AreEqual("test3", collection[2].Name); //s
            Assert.AreEqual("test1", collection[3].Name); //s

            Assert.AreEqual(true, collection[0].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[1].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[2].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[3].IsHeaderForLiveMonitor);
        }
Exemple #30
0
        public void SearchViewModelSortingTest()
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection.Add(new TestMatchVw()
            {
                IsLiveBet       = true,
                TournamentView  = TestGroupVw.CreateGroup(1, false),
                LiveBetStatus   = eMatchStatus.Started,
                LiveMatchMinute = 1,
                LivePeriodInfo  = eLivePeriodInfo.Basketball_1st_Quarter,
                Name            = "test1",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "b", LineObject = new GroupLn()
                    {
                        Sort = { Value = 3 }
                    }
                },
                StartDate = new DateTime(2013, 1, 1)
            });
            collection.Add(new TestMatchVw()
            {
                IsLiveBet       = true,
                TournamentView  = TestGroupVw.CreateGroup(1, false),
                LiveBetStatus   = eMatchStatus.Started,
                LiveMatchMinute = 1,
                LivePeriodInfo  = eLivePeriodInfo.Basketball_1st_Quarter,
                Name            = "test2",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                },
                StartDate = new DateTime(2013, 1, 2)
            });
            collection.Add(new TestMatchVw()
            {
                IsLiveBet       = true,
                TournamentView  = TestGroupVw.CreateGroup(1, false),
                LiveBetStatus   = eMatchStatus.Started,
                LiveMatchMinute = 1,
                LivePeriodInfo  = eLivePeriodInfo.Basketball_1st_Quarter,
                Name            = "test3",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "h", LineObject = new GroupLn()
                    {
                        Sort = { Value = 4 }
                    }
                },
                StartDate = new DateTime(2013, 1, 3)
            });
            collection.Add(new TestMatchVw()
            {
                IsLiveBet       = true,
                TournamentView  = TestGroupVw.CreateGroup(1, false),
                LiveBetStatus   = eMatchStatus.Started,
                LiveMatchMinute = 1,
                LivePeriodInfo  = eLivePeriodInfo.Basketball_1st_Quarter,
                Name            = "test4",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                },
                StartDate = new DateTime(2013, 1, 4)
            });


            collection.Sort(SearchViewModel.Comparison);

            Assert.AreEqual("test1", collection[0].Name);
            Assert.AreEqual("test2", collection[1].Name);
            Assert.AreEqual("test3", collection[2].Name);
            Assert.AreEqual("test4", collection[3].Name);
        }
Exemple #31
0
        public void FillTopTournamentsTest()
        {
            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());
            TranslationProvider.Setup(x => x.Translate(It.IsAny <MultistringTag>())).Returns("Outrights");

            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            //fill up collection
            collection.Add(new TestMatchVw()
            {
                SportDescriptor   = "SPRT_SOCCER",
                DefaultSorting    = 1,
                IsLiveBet         = false,
                LiveBetStatus     = eMatchStatus.NotStarted,
                LiveMatchMinuteEx = 1,
                LivePeriodInfo    = eLivePeriodInfo.Basketball_4th_Quarter,
                Name      = "test1",
                SportView = new TestGroupVw()
                {
                    DisplayName = "soccer", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                CategoryView = new TestGroupVw()
                {
                    DisplayName = "soccer category", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                StartDate      = new DateTime(2013, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName         = "tournament1",
                    TournamentSportView = new TestGroupVw()
                    {
                        DisplayName = "soccer", LineObject = new GroupLn()
                        {
                            GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = 1
                            }
                        }
                    },
                    LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1)
            });

            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);
            TopTournamentsViewModel model = new TopTournamentsViewModel();

            model.OnNavigationCompleted();

            //no outrights, no "all tournaments"
            Assert.AreEqual(1, model.Categories.Count);
            Assert.AreEqual("soccer category", model.Categories[0].SportName);
            Assert.AreEqual(1, model.Categories[0].Tournaments.Count);
            Assert.AreEqual("tournament1", model.Categories[0].Tournaments[0].Name);
            Assert.AreEqual(1, model.Categories[0].Tournaments[0].MatchesCount);
        }
Exemple #32
0
        public void FillSeveralCategories()
        {
            TestGroupVw soccerCategory = new TestGroupVw()
            {
                DisplayName = "soccer category", LineObject = new GroupLn()
                {
                    GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 1
                    }
                }
            };
            TestGroupVw hockeyCategory = new TestGroupVw()
            {
                DisplayName = "hockey category", LineObject = new GroupLn()
                {
                    GroupId = 3, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 3
                    }
                }
            };
            TestGroupVw someCategory = new TestGroupVw()
            {
                DisplayName = "some category", LineObject = new GroupLn()
                {
                    GroupId = 2, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 2
                    }
                }
            };

            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection = FillCategoryWithTournaments(soccerCategory, 8);

            SortableObservableCollection <IMatchVw> collection2 = FillCategoryWithTournaments(hockeyCategory, 15);
            SortableObservableCollection <IMatchVw> collection3 = FillCategoryWithTournaments(someCategory, 2);

            foreach (IMatchVw m in collection2)
            {
                collection.Add(m);
            }

            foreach (IMatchVw m in collection3)
            {
                collection.Add(m);
            }

            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());
            TranslationProvider.Setup(x => x.Translate(It.IsAny <MultistringTag>())).Returns("Outrights");
            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);

            TopTournamentsViewModel model = new TopTournamentsViewModel();

            model.OnNavigationCompleted();

            Assert.AreEqual(3, model.Categories.Count);
            Assert.AreEqual("soccer category", model.Categories[0].SportName);
            Assert.AreEqual("hockey category", model.Categories[2].SportName);
            Assert.AreEqual("some category", model.Categories[1].SportName);
            Assert.AreEqual(8, model.Categories[0].Tournaments.Count);
            Assert.AreEqual(8, model.Categories[2].Tournaments.Count);
            Assert.AreEqual(2, model.Categories[1].Tournaments.Count);
            Assert.AreEqual("tournament0", model.Categories[0].Tournaments[0].Name);
            Assert.AreEqual("tournament7", model.Categories[0].Tournaments[7].Name);
            Assert.AreEqual("All tournaments", model.Categories[2].Tournaments[7].Name);
            Assert.AreEqual("tournament0", model.Categories[0].Tournaments[0].Name);
            Assert.AreEqual("tournament1", model.Categories[0].Tournaments[1].Name);
        }
Exemple #33
0
        public void FillPlentyTournamentsWithOutrights()
        {
            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());
            TranslationProvider.Setup(x => x.Translate(It.IsAny <MultistringTag>())).Returns("Outrights");

            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            TestGroupVw soccerCategory = new TestGroupVw()
            {
                DisplayName = "soccer category", LineObject = new GroupLn()
                {
                    GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 1
                    }
                }
            };

            //get category with more tournaments that fits into it
            collection = FillCategoryWithTournaments(soccerCategory, 9);

            //add outright tournament to category
            collection.Add(new TestMatchVw()
            {
                SportDescriptor = "SPRT_SOCCER",
                DefaultSorting  = 1,
                IsLiveBet       = false,
                IsOutright      = true,
                LiveBetStatus   = eMatchStatus.NotStarted,
                Name            = "outright1",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "soccer", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                CategoryView   = soccerCategory,
                StartDate      = new DateTime(2015, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName         = "outright1",
                    TournamentSportView = new TestGroupVw()
                    {
                        DisplayName = "lasttournament", LineObject = new GroupLn()
                        {
                            GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = 1
                            }
                        }
                    },
                    LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1000)
            });

            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);
            TopTournamentsViewModel model = new TopTournamentsViewModel();

            model.OnNavigationCompleted();

            //no outrights, with "all tournaments"
            Assert.AreEqual(1, model.Categories.Count);
            Assert.AreEqual("soccer category", model.Categories[0].SportName);
            Assert.AreEqual(8, model.Categories[0].Tournaments.Count);
            Assert.AreEqual("tournament0", model.Categories[0].Tournaments[0].Name);
            Assert.AreEqual("tournament6", model.Categories[0].Tournaments[6].Name);
            Assert.AreEqual("All tournaments", model.Categories[0].Tournaments[7].Name);
        }
Exemple #34
0
        private void LoadDataInBackground()
        {
            SmartDispatcher.BeginInvoke(() =>
            {
                //GlobalLoading.Instance.IsLoadingText(Strings.SyncingTasks);

                if (App.RtmClient.TaskLists != null)
                {
                    var tempAllTasks = new SortableObservableCollection<Task>();
                    var tempTaskLists = new SortableObservableCollection<TaskList>();
                    var tempTaskTags = new SortableObservableCollection<TaskTag>();

                    foreach (TaskList l in App.RtmClient.TaskLists)
                    {
                        if (l.Tasks != null &&
                            l.IsNormal == true)
                        {
                            foreach (Task t in l.Tasks)
                            {
                                if (t.IsCompleted == true ||
                                    t.IsDeleted == true) continue;

                                if (t.DueDateTime.HasValue &&
                                    t.DueDateTime.Value.Date <= DateTime.Now.AddDays(1).Date)
                                {
                                    tempAllTasks.Add(t);
                                }
                            }
                        }

                        if (l.Name.ToLower() == "all tasks")
                            tempTaskLists.Insert(0, l);
                        else
                            tempTaskLists.Add(l);
                    }

                    //tempAllTasks.Sort(Task.CompareByDate);

                    // insert the nearby list placeholder
                    TaskList nearby = new TaskList("Nearby");
                    tempTaskLists.Insert(1, nearby);

                    foreach (var tag in App.RtmClient.GetTasksByTag().OrderBy(z => z.Key))
                    {
                        TaskTag data = new TaskTag();
                        data.Name = tag.Key;
                        data.Count = tag.Value.Count;

                        tempTaskTags.Add(data);
                    }

                    AllTasks = tempAllTasks;
                    TaskLists = tempTaskLists;
                    TaskTags = tempTaskTags;

                    ToggleLoadingText();
                    ToggleEmptyText();

                    //GlobalLoading.Instance.IsLoading = false;

                    ShowLastUpdatedStatus();
                }
            });
        }
        void DataCopy_DataSqlUpdateSucceeded(eUpdateType eut, string sProviderDescription)
        {
            SyncHashSet <ITipItemVw> shsToRemove = new SyncHashSet <ITipItemVw>();

            var tipitems = new SortableObservableCollection <ITipItemVw>();

            foreach (var ticket1 in TicketHandler.TicketsInBasket.ToSyncList())
            {
                foreach (var tipItemVw in ticket1.TipItems.ToSyncList())
                {
                    tipitems.Add(tipItemVw);
                }
            }

            LineSr.VerifySelectedOdds(tipitems, shsToRemove);

            // remove hidden odds (disabled in web admin) and not caught by LineSr.VerifySelectedOdds()
            foreach (var ticket1 in TicketHandler.TicketsInBasket.ToSyncList())
            {
                foreach (var tipItemVw in ticket1.TipItems.ToSyncList())
                {
                    if (tipItemVw.OddView.Visibility == Visibility.Hidden)
                    {
                        shsToRemove.Add(tipItemVw);
                    }
                }
            }

            if (shsToRemove.Count > 0)
            {
                foreach (ITipItemVw tipItemVw in shsToRemove)
                {
                    ShowError(TranslationProvider.Translate(MultistringTags.TERMINAL_REMOVE_FROM_BASKET_MATCH, tipItemVw.BetDomain.Match.MatchView.Name), null, false, 5);
                    PlaceBetMethod(tipItemVw, true);
                }
            }

            var TicketsInBasket = TicketHandler.TicketsInBasket.ToSyncList();

            foreach (var ticket1 in TicketsInBasket)
            {
                if (ticket1.TipItems.ToSyncList().Count == 0)
                {
                    var ticket = ticket1;
                    Dispatcher.Invoke(() =>
                    {
                        TicketHandler.TicketsInBasket.Remove(ticket);
                    });
                }
            }


            TicketsInBasket = TicketHandler.TicketsInBasket.ToSyncList();
            if (TicketsInBasket.Count() > 0)
            {
                TicketHandler.CopyValues();
            }
            TicketHandler.UpdateTicket();

            if (ChangeTracker.IsBasketOpen && TicketHandler.Count == 0 && !ChangeTracker.IsLandscapeMode)
            {
                Mediator.SendMessage("", MsgTag.ShowFirstViewAndResetFilters);
            }
        }
        public void FillTournamentsTest()
        {
            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());

            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            //fill up collection
            collection.Add(new TestMatchVw()
            {
                SportDescriptor   = "SPRT_SOCCER",
                DefaultSorting    = 1,
                IsLiveBet         = true,
                LiveBetStatus     = eMatchStatus.NotStarted,
                LiveMatchMinuteEx = 1,
                LivePeriodInfo    = eLivePeriodInfo.Basketball_4th_Quarter,
                Name      = "test1",
                SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                StartDate      = new DateTime(2013, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName = "tournament1", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1)
            });

            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);
            TournamentsViewModel model = new TournamentsViewModel(1);

            model.OnNavigationCompleted();

            Assert.AreEqual(1, model.Tournaments.Count);

            collection.Add(new TestMatchVw()
            {
                SportDescriptor   = "SPRT_SOCCER",
                DefaultSorting    = 1,
                IsLiveBet         = true,
                LiveBetStatus     = eMatchStatus.NotStarted,
                LiveMatchMinuteEx = 1,
                LivePeriodInfo    = eLivePeriodInfo.Basketball_4th_Quarter,
                Name      = "test1",
                SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                StartDate      = new DateTime(2013, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName = "tournament1", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1)
            });

            collection.Add(new TestMatchVw()
            {
                SportDescriptor   = "SPRT_SOCCER",
                DefaultSorting    = 1,
                IsLiveBet         = true,
                LiveBetStatus     = eMatchStatus.NotStarted,
                LiveMatchMinuteEx = 1,
                LivePeriodInfo    = eLivePeriodInfo.Basketball_4th_Quarter,
                Name      = "test1",
                SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                StartDate      = new DateTime(2013, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName = "tournament1", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1)
            });

            collection.Add(new TestMatchVw()
            {
                SportDescriptor   = "SPRT_SOCCER",
                DefaultSorting    = 1,
                IsLiveBet         = true,
                LiveBetStatus     = eMatchStatus.NotStarted,
                LiveMatchMinuteEx = 1,
                LivePeriodInfo    = eLivePeriodInfo.Basketball_4th_Quarter,
                Name      = "test1",
                SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                StartDate      = new DateTime(2013, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName = "tournament1", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1)
            });

            model.Refresh(true);
            Assert.AreEqual(1, model.Tournaments.Count);
            Assert.AreEqual(4, model.Tournaments[0].MatchesCount);

            collection.Add(new TestMatchVw()
            {
                SportDescriptor   = "SPRT_SOCCER",
                DefaultSorting    = 1,
                IsLiveBet         = true,
                LiveBetStatus     = eMatchStatus.NotStarted,
                LiveMatchMinuteEx = 1,
                LivePeriodInfo    = eLivePeriodInfo.Basketball_4th_Quarter,
                Name      = "test1",
                SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 0
                        }
                    }
                },
                StartDate      = new DateTime(2013, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName = "tournament2", LineObject = new GroupLn()
                    {
                        GroupId = 2, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 0
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1)
            });

            model.Refresh(true);
            Assert.AreEqual(2, model.Tournaments.Count);
            Assert.AreEqual(1, model.Tournaments[0].MatchesCount);
            Assert.AreEqual(4, model.Tournaments[1].MatchesCount);

            collection.Add(new TestMatchVw()
            {
                SportDescriptor   = "SPRT_SOCCER",
                DefaultSorting    = 1,
                IsLiveBet         = true,
                LiveBetStatus     = eMatchStatus.NotStarted,
                LiveMatchMinuteEx = 1,
                LivePeriodInfo    = eLivePeriodInfo.Basketball_4th_Quarter,
                Name      = "test1",
                SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 3
                        }
                    }
                },
                StartDate      = new DateTime(2013, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName = "tournament3", LineObject = new GroupLn()
                    {
                        GroupId = 3, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 3
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1)
            });

            collection.Add(new TestMatchVw()
            {
                SportDescriptor   = "SPRT_SOCCER",
                DefaultSorting    = 1,
                IsLiveBet         = true,
                LiveBetStatus     = eMatchStatus.NotStarted,
                LiveMatchMinuteEx = 1,
                LivePeriodInfo    = eLivePeriodInfo.Basketball_4th_Quarter,
                Name      = "test1",
                SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 3
                        }
                    }
                },
                StartDate      = new DateTime(2013, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName = "tournament3", LineObject = new GroupLn()
                    {
                        GroupId = 3, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 3
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1)
            });

            model.Refresh(true);
            Assert.AreEqual(3, model.Tournaments.Count);
            Assert.AreEqual(1, model.Tournaments[0].MatchesCount);
            Assert.AreEqual(4, model.Tournaments[1].MatchesCount);
            Assert.AreEqual(2, model.Tournaments[2].MatchesCount);
            Assert.AreEqual("tournament2", model.Tournaments[0].Name);
            Assert.AreEqual("tournament1", model.Tournaments[1].Name);
            Assert.AreEqual("tournament3", model.Tournaments[2].Name);
        }
        public void TournamentsViewMultyTournamentsTest()
        {
            AuthorizationService = MockRepository.GenerateStub <IAuthorizationService>();
            StationRepository    = MockRepository.GenerateStub <IStationRepository>();
            LanguageRepository   = MockRepository.GenerateStub <ILanguageRepository>();
            LineProvider         = MockRepository.GenerateStub <ILineProvider>();
            BusinessPropsHelper  = MockRepository.GenerateStub <IBusinessPropsHelper>();
            DataBinding          = MockRepository.GenerateStub <IDataBinding>();


            IoCContainer.Kernel.Bind <IDataBinding>().ToConstant <IDataBinding>(DataBinding).InSingletonScope();
            IoCContainer.Kernel.Bind <IAuthorizationService>().ToConstant <IAuthorizationService>(AuthorizationService).InSingletonScope();
            IoCContainer.Kernel.Bind <IStationRepository>().ToConstant <IStationRepository>(StationRepository).InSingletonScope();
            IoCContainer.Kernel.Bind <ILanguageRepository>().ToConstant <ILanguageRepository>(LanguageRepository).InSingletonScope();
            IoCContainer.Kernel.Bind <ILineProvider>().ToConstant <ILineProvider>(LineProvider).InSingletonScope();
            IoCContainer.Kernel.Bind <IBusinessPropsHelper>().ToConstant <IBusinessPropsHelper>(BusinessPropsHelper).InSingletonScope();


            DataBinding.Expect(x => x.TipListInfo).Return(new TipListInfo());



            StationRepository.TurnOffCashInInit = true;
            StationRepository.Expect(x => x.AllowAnonymousBetting).Return(true);
            StationRepository.Expect(x => x.IsReady).Return(true);
            StationRepository.Expect(x => x.StationNumber).Return("0024");
            StationRepository.Expect(x => x.HubSettings).Return(new Dictionary <string, string>());
            StationRepository.Currency = "EUR";

            ChangeTracker                           = IoCContainer.Kernel.Get <IChangeTracker>();
            ChangeTracker.CurrentUser               = new AnonymousUser("1", 1);
            ChangeTracker.CurrentUser.Cashpool      = 100000;
            ChangeTracker.CurrentUser.AvailableCash = 100000;



            SortableObservableCollection <IMatchVw> matches = new SortableObservableCollection <IMatchVw>();

            matches.Add(CreateMatch(1, true));
            matches.Add(CreateMatch(2));
            matches.Add(CreateMatch(2));
            matches.Add(CreateMatch(3, true));
            matches.Add(CreateMatch(4));
            matches.Add(CreateMatch(4));

            Repository.BackToRecord();

            Repository.Stub(x => x.FindMatches(matches, "", "", null, null)).IgnoreArguments().Return(matches);
            Repository.Stub(x => x.FindResults(null, null, null)).IgnoreArguments();

            Repository.Replay();

            Dispatcher.Invoke(() =>
            {
                Window = MyRegionManager.FindWindowByViewModel <MainViewModel>();
                Window.Show();
            });

            Thread.Sleep(1000);
            var firstModel = MyRegionManager.CurrentViewModelInRegion(RegionNames.ContentRegion);

            Assert.IsNotNull(firstModel);


            MyRegionManager.NavigateUsingViewModel <TournamentsViewModel>(RegionNames.ContentRegion);


            var model = MyRegionManager.CurrentViewModelInRegion(RegionNames.ContentRegion) as TournamentsViewModel;

            while (!model.IsReady)
            {
                Thread.Sleep(100);
            }


            Assert.AreEqual(3, model.Tournaments.Count);
            Assert.AreEqual(true, model.Tournaments[0].IsOutrightGroup);
            Assert.AreEqual(2, model.Tournaments[1].MatchesCount);
            Assert.AreEqual(2, model.Tournaments[0].MatchesCount);
            Assert.AreEqual(2, model.Tournaments[1].Id);



            model.CheckedBox.Execute(model.Tournaments[1]);
            model.CheckedBox.Execute(model.Tournaments[2]);


            var header = MyRegionManager.CurrentViewModelInRegion(RegionNames.HeaderRegion) as HeaderViewModel;

            header.NextView.Execute("");

            Thread.Sleep(1000);

            var matchesmodel = MyRegionManager.CurrentViewModelInRegion(RegionNames.ContentRegion) as MatchesViewModel;

            while (!matchesmodel.IsReady)
            {
                Thread.Sleep(100);
            }
            Assert.IsNotNull(matchesmodel);
            Assert.IsNotNull(matchesmodel.SelectedTournaments);
            Assert.IsFalse(matchesmodel.SelectedTournaments[2]);
            Assert.AreEqual(2, matchesmodel.SelectedTournaments.Count);

            Dispatcher.Invoke(() =>
                              { header.PrevView.Execute(""); });


            model = MyRegionManager.CurrentViewModelInRegion(RegionNames.ContentRegion) as TournamentsViewModel;

            while (!model.IsReady)
            {
                Thread.Sleep(100);
            }

            Assert.AreEqual(2, model.SelectedTournaments.Count);


            Dispatcher.Invoke(() =>
            {
                Window.Close();
            });
        }
		void UpdateGrid()
		{
			using (new WaitWrapper())
			{
				var employeeUID = Guid.Empty;

				if (SelectedTimeTrack != null)
				{
					employeeUID = SelectedTimeTrack.ShortEmployee.UID;
				}

				TotalDays = (int)(TimeTrackFilter.EndDate - TimeTrackFilter.StartDate).TotalDays + 1;
				FirstDay = TimeTrackFilter.StartDate;

				TimeTracks = new SortableObservableCollection<TimeTrackViewModel>();
				var stream = ClientManager.RubezhService.GetTimeTracksStream(TimeTrackFilter.EmployeeFilter, TimeTrackFilter.StartDate, TimeTrackFilter.EndDate);
				var folderName = AppDataFolderHelper.GetFolder("TempServer");
				var resultFileName = Path.Combine(folderName, "ClientTimeTrackResult.xml");
				var resultFileStream = File.Create(resultFileName);
				CopyStream(stream, resultFileStream);
				var timeTrackResult = Deserialize(resultFileName);

				if (timeTrackResult != null)
				{
					TimeTrackEmployeeResults = timeTrackResult.TimeTrackEmployeeResults;
					foreach (var timeTrackEmployeeResult in TimeTrackEmployeeResults)
					{
						var timeTrackViewModel = new TimeTrackViewModel(TimeTrackFilter, timeTrackEmployeeResult);
						TimeTracks.Add(timeTrackViewModel);
					}

					TimeTracks.Sort(x => x.ShortEmployee.LastName);
					RowHeight = 60 + 20 * TimeTrackFilter.TotalTimeTrackTypeFilters.Count;
				}

				SelectedTimeTrack = TimeTracks.FirstOrDefault(x => x.ShortEmployee.UID == employeeUID) ??
									TimeTracks.FirstOrDefault();
			}
		}
Exemple #39
0
        public void CetagoriesWithOnlyOutrights()
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();
            TestGroupVw soccerCategory = new TestGroupVw()
            {
                DisplayName = "soccer category", LineObject = new GroupLn()
                {
                    GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 1
                    }
                }
            };

            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());
            TranslationProvider.Setup(x => x.Translate(It.IsAny <MultistringTag>())).Returns("Outrights");
            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);

            //add outright tournament to category
            collection.Add(new TestMatchVw()
            {
                SportDescriptor = "SPRT_SOCCER",
                DefaultSorting  = 1,
                IsLiveBet       = false,
                IsOutright      = true,
                LiveBetStatus   = eMatchStatus.NotStarted,
                Name            = "outright1",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "soccer", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                CategoryView   = soccerCategory,
                StartDate      = new DateTime(2015, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName         = "outright1",
                    TournamentSportView = new TestGroupVw()
                    {
                        DisplayName = "lasttournament", LineObject = new GroupLn()
                        {
                            GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = 1
                            }
                        }
                    },
                    LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1000)
            });

            TopTournamentsViewModel model = new TopTournamentsViewModel();

            model.OnNavigationCompleted();

            //we do not show categories with outrights only
            Assert.AreEqual(0, model.Categories.Count);
        }
        public void DifferentSportsSort()
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.NotStarted, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test1", SportDescriptor = "SPRT_SOCCER", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                }, StartDate = new DateTime(2013, 1, 1), DefaultSorting = 1
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test2", SportDescriptor = "SPRT_TENNIS", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 1), DefaultSorting = 2
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test3", SportDescriptor = "SPRT_TENNIS", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 2), DefaultSorting = 2
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Stopped, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test4", SportDescriptor = "SPRT_TENNIS", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 1), DefaultSorting = 2
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Stopped, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test5", SportDescriptor = "SPRT_SOCCER", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                }, StartDate = new DateTime(2013, 1, 2), DefaultSorting = 1
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = false, LiveBetStatus = eMatchStatus.Undefined, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test6", SportDescriptor = "SPRT_SOCCER", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                }, StartDate = new DateTime(2013, 1, 2), DefaultSorting = 1
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.NotStarted, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test7", SportDescriptor = "SPRT_TENNIS", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 3), DefaultSorting = 2
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Stopped, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test8", SportDescriptor = "SPRT_SOCCER", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                }, StartDate = new DateTime(2013, 1, 1), DefaultSorting = 1
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = false, LiveBetStatus = eMatchStatus.Undefined, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test9", SportDescriptor = "SPRT_SOCCER", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                }, StartDate = new DateTime(2013, 1, 4), DefaultSorting = 1
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Stopped, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test10", SportDescriptor = "SPRT_TENNIS", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 2), DefaultSorting = 2
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = false, LiveBetStatus = eMatchStatus.Undefined, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test11", SportDescriptor = "SPRT_TENNIS", SportView = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                }, StartDate = new DateTime(2013, 1, 5), DefaultSorting = 2
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test12", SportDescriptor = "SPRT_SOCCER", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                }, StartDate = new DateTime(2013, 1, 1), DefaultSorting = 1
            });

            collection.Add(new TestMatchVw()
            {
                IsLiveBet = true, LiveBetStatus = eMatchStatus.Started, LiveMatchMinuteEx = 1, LivePeriodInfo = eLivePeriodInfo.Basketball_1st_Quarter, Name = "test13", SportDescriptor = "SPRT_SOCCER", SportView = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                }, StartDate = new DateTime(2013, 1, 2), DefaultSorting = 1
            });

            var groupln = new GroupLn {
                Sort = { Value = 1 }
            };

            collection.Sort(LiveMonitorsService.Comparison);
            LiveMonitorsService.UpdateHeaders(collection);

            Assert.AreEqual("test12", collection[0].Name);  //s
            Assert.AreEqual("test8", collection[1].Name);   //s
            Assert.AreEqual("test13", collection[2].Name);  //s
            Assert.AreEqual("test5", collection[3].Name);   //s
            Assert.AreEqual("test2", collection[4].Name);   //t
            Assert.AreEqual("test4", collection[5].Name);   //t
            Assert.AreEqual("test10", collection[6].Name);  //t
            Assert.AreEqual("test3", collection[7].Name);   //t
            Assert.AreEqual("test1", collection[8].Name);   //s
            Assert.AreEqual("test6", collection[9].Name);   //s
            Assert.AreEqual("test9", collection[10].Name);  //s
            Assert.AreEqual("test7", collection[11].Name);  //t
            Assert.AreEqual("test11", collection[12].Name); //t

            Assert.AreEqual(true, collection[0].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[1].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[2].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[3].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[4].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[5].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[6].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[7].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[8].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[9].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[10].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[11].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[12].IsHeaderForLiveMonitor);

            collection = new SortableObservableCollection <IMatchVw>(collection.OrderByDescending(x => x.Name).ToList());

            collection.Sort(LiveMonitorsService.Comparison);
            LiveMonitorsService.UpdateHeaders(collection);

            Assert.AreEqual("test12", collection[0].Name);  //s
            Assert.AreEqual("test8", collection[1].Name);   //s
            Assert.AreEqual("test13", collection[2].Name);  //s
            Assert.AreEqual("test5", collection[3].Name);   //s
            Assert.AreEqual("test2", collection[4].Name);   //t
            Assert.AreEqual("test4", collection[5].Name);   //t
            Assert.AreEqual("test10", collection[6].Name);  //t
            Assert.AreEqual("test3", collection[7].Name);   //t
            Assert.AreEqual("test1", collection[8].Name);   //s
            Assert.AreEqual("test6", collection[9].Name);   //s
            Assert.AreEqual("test9", collection[10].Name);  //s
            Assert.AreEqual("test7", collection[11].Name);  //t
            Assert.AreEqual("test11", collection[12].Name); //t

            Assert.AreEqual(true, collection[0].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[1].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[2].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[3].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[4].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[5].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[6].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[7].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[8].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[9].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[10].IsHeaderForLiveMonitor);
            Assert.AreEqual(true, collection[11].IsHeaderForLiveMonitor);
            Assert.AreEqual(false, collection[12].IsHeaderForLiveMonitor);
        }