public void SetUp()
        {
            this.session = new Mock <ISession>();

            this.category1 = new Category(Guid.NewGuid(), null, null)
            {
                Name = CategoryName1
            };

            this.category2 = new Category(Guid.NewGuid(), null, null)
            {
                Name = CategoryName2
            };

            this.parentRow = new CategoryTestRowViewModel(this.category1, this.session.Object, null);
            this.childRow  = new CategoryTestRowViewModel(this.category2, this.session.Object, this.parentRow);

            this.parentRow.ContainedRows.Add(this.childRow);

            this.filterEditorQueryOperatorsEventArgs =
                this.CreateInstance <FilterEditorQueryOperatorsEventArgs>(CriteriaOperator.And(), nameof(CategoryTestRowViewModel.Category));

            var filterEditorOperatorItem = new List <FilterEditorOperatorItem>
            {
                new FilterEditorOperatorItem(FilterEditorOperatorType.AboveAverage),
                new FilterEditorOperatorItem(FilterEditorOperatorType.Equal),
                new FilterEditorOperatorItem(FilterEditorOperatorType.Greater),
                new FilterEditorOperatorItem(FilterEditorOperatorType.AnyOf)
            };

            this.filterEditorOperatorItemList = this.CreateInstance <FilterEditorOperatorItemList>(filterEditorOperatorItem);
            this.filterEditorQueryOperatorsEventArgs.Operators = this.filterEditorOperatorItemList;
        }
Exemple #2
0
 private void RemoveIrrelevantFilters(FilterEditorOperatorItemList filterEditors)
 {
     filterEditors.RemoveAll(x => x.OperatorType == FilterEditorOperatorType.AnyOf ||
                             x.OperatorType == FilterEditorOperatorType.NoneOf ||
                             x.OperatorType == FilterEditorOperatorType.Less ||
                             x.OperatorType == FilterEditorOperatorType.LessOrEqual ||
                             x.OperatorType == FilterEditorOperatorType.Greater ||
                             x.OperatorType == FilterEditorOperatorType.GreaterOrEqual ||
                             x.OperatorType == FilterEditorOperatorType.Between ||
                             x.OperatorType == FilterEditorOperatorType.NotBetween);
 }
        public void SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.serviceLocator       = new Mock <IServiceLocator>();

            var treeList = new TreeListControl {
                View = new TreeListView()
            };

            this.dataViewBase      = treeList.View;
            this.dataViewBase.Name = "DataViewBase";

            this.dialogNavigationService = new Mock <IDialogNavigationService>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IDialogNavigationService>()).Returns(this.dialogNavigationService.Object);

            this.savedUserPreferenceService = new Mock <ISavedUserPreferenceService>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <ISavedUserPreferenceService>()).Returns(this.savedUserPreferenceService.Object);

            this.session = new Mock <ISession>();

            this.category1 = new Category(Guid.NewGuid(), null, null)
            {
                Name = CategoryName1
            };

            this.category2 = new Category(Guid.NewGuid(), null, null)
            {
                Name = CategoryName2
            };

            this.parentRow = new CategoryTestRowViewModel(this.category1, this.session.Object, null);
            this.childRow  = new CategoryTestRowViewModel(this.category2, this.session.Object, this.parentRow);

            this.parentRow.ContainedRows.Add(this.childRow);

            this.filterEditorQueryOperatorsEventArgs =
                this.CreateInstance <FilterEditorQueryOperatorsEventArgs>(CriteriaOperator.And(), nameof(CategoryTestRowViewModel.Category));

            var filterEditorOperatorItem = new List <FilterEditorOperatorItem>
            {
                new FilterEditorOperatorItem(FilterEditorOperatorType.AboveAverage),
                new FilterEditorOperatorItem(FilterEditorOperatorType.Equal),
                new FilterEditorOperatorItem(FilterEditorOperatorType.Greater),
                new FilterEditorOperatorItem(FilterEditorOperatorType.AnyOf)
            };

            this.filterEditorOperatorItemList = this.CreateInstance <FilterEditorOperatorItemList>(filterEditorOperatorItem);
            this.filterEditorQueryOperatorsEventArgs.Operators = this.filterEditorOperatorItemList;

            this.customFilterOperatorsViewModel = new Mock <IHaveCustomFilterOperators>();

            var customFilterOperators = new Dictionary <DataViewBase, Dictionary <string, (CustomFilterOperatorType, IEnumerable <IRowViewModelBase <Thing> >)> >();
            var browserDictionary     = new Dictionary <string, (CustomFilterOperatorType, IEnumerable <IRowViewModelBase <Thing> >)>();

            browserDictionary.Add(nameof(CategoryTestRowViewModel.Category), (CustomFilterOperatorType.Category, new [] { this.parentRow }));

            customFilterOperators.Add(this.dataViewBase, browserDictionary);

            this.customFilterOperatorsViewModel.Setup(x => x.CustomFilterOperators).Returns(customFilterOperators);

            this.dataViewBase.DataContext = this.customFilterOperatorsViewModel.Object;
        }