/// <summary>
 /// Initializes a new instance of the <see cref="TestCasesInitialViewModel"/> class.
 /// </summary>
 public SharedStepsInitialViewModel()
 {
     this.InitialViewFiltersSharedSteps = new InitialViewFilters();
     this.InitialViewFiltersTestCases = new InitialViewFilters();
     this.ObservableSharedSteps = new ObservableCollection<SharedStep>();
     this.InitialSharedStepsCollection = new ObservableCollection<SharedStep>();
     this.ObservableTestCases = new ObservableCollection<TestCase>();
     this.RefreshSharedSteps();
     this.InitializeInitialTestCaseCollection(this.ObservableSharedSteps);
     this.SharedStepsCount = this.ObservableSharedSteps.Count.ToString();
     this.TestCasesCount = this.ObservableTestCases.Count.ToString();
     this.IsAfterInitialize = true;
     var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting<SharedStep>();
     compiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler<SharedStep>(setting);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCasesInitialViewModel"/> class.
        /// </summary>
        public SharedStepsInitialViewModel()
        {
            this.InitialViewFiltersSharedSteps = new InitialViewFilters();
            this.InitialViewFiltersTestCases   = new InitialViewFilters();
            this.ObservableSharedSteps         = new ObservableCollection <SharedStep>();
            this.InitialSharedStepsCollection  = new ObservableCollection <SharedStep>();
            this.ObservableTestCases           = new ObservableCollection <TestCase>();
            this.RefreshSharedSteps();
            this.InitializeInitialTestCaseCollection(this.ObservableSharedSteps);
            this.SharedStepsCount  = this.ObservableSharedSteps.Count.ToString();
            this.TestCasesCount    = this.ObservableTestCases.Count.ToString();
            this.IsAfterInitialize = true;
            var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <SharedStep>();

            compiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <SharedStep>(setting);
        }
Пример #3
0
        public MainViewModel()
        {
            var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting<ProductViewModel>();
            compiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler<ProductViewModel>(setting);
            Preferences = new PreferencesViewModel(((App)Application.Current).Preferences);

            Products = new ObservableCollection<ProductViewModel>();
            SearchResult = new ObservableCollection<ProductViewModel>();
            AutoCompleteItems = new ObservableCollection<IAutoCompleteItem>(setting.ExtractAutoCompleteItems());

            SearchCommand = new RelayCommand(o => Search(o.ToString()));
            LogCommand = new RelayCommand(o => OpenDiagnosticsView());
            PreferencesCommand = new RelayCommand(o => OpenPreferencesView());
            AboutCommand = new RelayCommand(o => OpenAboutView());
            CloseCommand = new RelayCommand(o => Close());
        }
        public FeedReaderViewModel()
        {
            Feeds         = new ObservableCollection <FeedViewModel>();
            SearchCommand = new RelayCommand(o => Search(o.ToString()));
            FocusCommand  = new RelayCommand(o => OnFocusRequired(EventArgs.Empty));
            SelectAutocompleteItemCommand = new RelayCommand(o => OnSelectAutocompleteItemRequired(EventArgs.Empty));
            CancelAutocompleteCommand     = new RelayCommand(o => OnCancelAutocompleteRequired(EventArgs.Empty));

            feedsCollectionView = CollectionViewSource.GetDefaultView(Feeds);
            feedsCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("Group"));

            CompilerSetting = new CompilerSetting();
            CompilerSetting.Operators.Add(new PartialMatch <EntryViewModel>(":", true));
            CompilerSetting.Evaluators.Add(new PropertyEvaluator <EntryViewModel>());
            compiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <EntryViewModel>(CompilerSetting);
        }
        public FeedReaderViewModel()
        {
            Feeds = new ObservableCollection<FeedViewModel>();
            SearchCommand = new RelayCommand(o => Search(o.ToString()));
            FocusCommand = new RelayCommand(o => OnFocusRequired(EventArgs.Empty));
            SelectAutocompleteItemCommand = new RelayCommand(o => OnSelectAutocompleteItemRequired(EventArgs.Empty));
            CancelAutocompleteCommand = new RelayCommand(o => OnCancelAutocompleteRequired(EventArgs.Empty));

            feedsCollectionView = CollectionViewSource.GetDefaultView(Feeds);
            feedsCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("Group"));

            CompilerSetting = new CompilerSetting();
            CompilerSetting.Operators.Add(new PartialMatch<EntryViewModel>(":", true));
            CompilerSetting.Evaluators.Add(new PropertyEvaluator<EntryViewModel>());
            compiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler<EntryViewModel>(CompilerSetting);
        }
Пример #6
0
        public MainViewModel()
        {
            var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <ProductViewModel>();

            compiler    = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <ProductViewModel>(setting);
            Preferences = new PreferencesViewModel(((App)Application.Current).Preferences);

            Products          = new ObservableCollection <ProductViewModel>();
            SearchResult      = new ObservableCollection <ProductViewModel>();
            AutoCompleteItems = new ObservableCollection <IAutoCompleteItem>(setting.ExtractAutoCompleteItems());

            SearchCommand      = new RelayCommand(o => Search(o.ToString()));
            LogCommand         = new RelayCommand(o => OpenDiagnosticsView());
            PreferencesCommand = new RelayCommand(o => OpenPreferencesView());
            AboutCommand       = new RelayCommand(o => OpenAboutView());
            CloseCommand       = new RelayCommand(o => Close());
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCasesBatchDuplicateViewModel"/> class.
        /// </summary>
        public TestCasesBatchDuplicateViewModel(bool loadTestCases, bool loadSpecificTestCases)
        {
            this.InitializeInnerCollections();
            this.loadTestCases = loadTestCases;
            this.ShowTestCaseSpecificFields = loadTestCases;
            this.InitializeTeamFoundationIdentityNames();
            this.ReplaceContext = new ReplaceContext();

            if (loadTestCases)
            {
                if (!loadSpecificTestCases)
                {
                    this.InitializeTestCases();
                }
                else
                {
                    this.InitializeTestCasesFromSpecificSelectedTestCases();
                }
                this.InitializeInitialTestCaseCollection();
                this.EntitiesCount = this.ObservableTestCases.Count.ToString();
                this.InitializeTestSuiteList();
                this.ReplaceContext.SelectedSuite = this.ObservableTestSuites[0];
            }
            else
            {
                this.ObservableSharedSteps = new ObservableCollection <SharedStep>();
                List <SharedStep> allSharedSteps = SharedStepManager.GetAllSharedStepsInTestPlan(ExecutionContext.TestManagementTeamProject);
                allSharedSteps.ForEach(s => this.ObservableSharedSteps.Add(s));
                this.InitialSharedStepsCollection = new ObservableCollection <SharedStep>();
                allSharedSteps.ForEach(s => this.InitialSharedStepsCollection.Add(s));
                this.EntitiesCount = this.ObservableSharedSteps.Count.ToString();
            }

            if (this.ObservableTeamFoundationIdentityNames.Count > 0)
            {
                this.ReplaceContext.SelectedTeamFoundationIdentityName = this.ObservableTeamFoundationIdentityNames[0];
            }
            this.SelectedEntitiesCount = "0";
            var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <TestCase>();

            testCasesCompiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <TestCase>(setting);
            var sharedSteposSetting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <SharedStep>();

            sharedStepsCompiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <SharedStep>(sharedSteposSetting);
        }
Пример #8
0
        public static void Main(string[] args)
        {
            Greet();

            SearchQueryCompiler <Product> compiler = SearchQueryCompilerBuilder.Instance.BuildUpDefaultCompilerForObject <Product>();
            IEnumerable <Product>         products = GetProducts();

            while (true)
            {
                Console.Write("$ ");
                string query = Console.ReadLine();
                if (query.ToLower() == "exit")
                {
                    break;
                }

                Expression <Func <Product, bool> > filter = compiler.Compile(query);
                IEnumerable <Product> result = products.AsQueryable().Where(filter);
                PrintProducts(result);
            }
        }
        public void SetUp()
        {
            var setting = new CompilerSetting();
            setting.Operators.Add(new PartialMatch<ItemEntity>(":", false, OperatorIndependency.Strong, "contains"));
            setting.Operators.Add(new LessThan<ItemEntity>("<", OperatorIndependency.Strong, "less than"));
            setting.Operators.Add(new LessThanOrEqual<ItemEntity>("<=", OperatorIndependency.Strong, "less than or equal"));
            setting.Operators.Add(new Equal<ItemEntity>("=", false, OperatorIndependency.Strong, "equal"));
            setting.Operators.Add(new Equal<ItemEntity>("==", false, OperatorIndependency.Strong, "equal"));
            setting.Operators.Add(new NotEqual<ItemEntity>("!=", false, OperatorIndependency.Strong, "not equal"));
            setting.Operators.Add(new Add("+", 1));
            setting.Operators.Add(new Subtract("-", 1));
            setting.Operators.Add(new Multiply("*", 0));
            setting.Operators.Add(new Divide("/", 0));
            setting.Operators.Add(new LessThan<ItemEntity>("lt", OperatorIndependency.Weak, description: "less than"));
            setting.Operators.Add(new LessThanOrEqual<ItemEntity>("le", OperatorIndependency.Weak, description: "less than or equal"));
            setting.Operators.Add(new Add("add", 1, OperatorIndependency.Weak, null));
            setting.Operators.Add(new Multiply("multiply", 0, OperatorIndependency.Weak, null));

            setting.Evaluators.Add(new PropertyEvaluator<ItemEntity>());
            setting.Evaluators.Add(new TypeConversionEvaluator());

            testee = SearchQueryCompilerBuilder.Instance.BuildUpCompiler<ItemEntity>(setting);
        }
Пример #10
0
        public void SetUp()
        {
            var setting = new CompilerSetting();

            setting.Operators.Add(new PartialMatch <ItemEntity>(":", false, OperatorIndependency.Strong, "contains"));
            setting.Operators.Add(new LessThan <ItemEntity>("<", OperatorIndependency.Strong, "less than"));
            setting.Operators.Add(new LessThanOrEqual <ItemEntity>("<=", OperatorIndependency.Strong, "less than or equal"));
            setting.Operators.Add(new Equal <ItemEntity>("=", false, OperatorIndependency.Strong, "equal"));
            setting.Operators.Add(new Equal <ItemEntity>("==", false, OperatorIndependency.Strong, "equal"));
            setting.Operators.Add(new NotEqual <ItemEntity>("!=", false, OperatorIndependency.Strong, "not equal"));
            setting.Operators.Add(new Add("+", 1));
            setting.Operators.Add(new Subtract("-", 1));
            setting.Operators.Add(new Multiply("*", 0));
            setting.Operators.Add(new Divide("/", 0));
            setting.Operators.Add(new LessThan <ItemEntity>("lt", OperatorIndependency.Weak, description: "less than"));
            setting.Operators.Add(new LessThanOrEqual <ItemEntity>("le", OperatorIndependency.Weak, description: "less than or equal"));
            setting.Operators.Add(new Add("add", 1, OperatorIndependency.Weak, null));
            setting.Operators.Add(new Multiply("multiply", 0, OperatorIndependency.Weak, null));

            setting.Evaluators.Add(new PropertyEvaluator <ItemEntity>());
            setting.Evaluators.Add(new TypeConversionEvaluator());

            testee = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <ItemEntity>(setting);
        }
Пример #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCasesInitialViewModel"/> class.
        /// </summary>
        public TestCasesInitialViewModel()
        {
            this.InitialViewFilters = new InitialViewFilters();
            List <Suite> subSuites = TestSuiteManager.GetAllSuites(ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites).ToList();

            subSuites.Sort();
            // Load last selected suite in the treeview in order to selected it again
            this.selectedSuiteId = RegistryManager.Instance.GetSelectedSuiteId();
            List <TestCase> suiteTestCaseCollection = new List <TestCase>();

            this.ShowSubSuitesTestCases = RegistryManager.Instance.ReadShowSubsuiteTestCases();

            if (this.selectedSuiteId != -1)
            {
                try
                {
                    suiteTestCaseCollection = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, this.selectedSuiteId);
                    this.AddTestCasesSubsuites(suiteTestCaseCollection);
                }
                catch (NullReferenceException ex)
                {
                    log.Error(ex);
                    if (subSuites.Count > 0)
                    {
                        suiteTestCaseCollection = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, subSuites[0].Id);
                        this.selectedSuiteId    = subSuites[0].Id;
                    }
                    else
                    {
                        suiteTestCaseCollection = TestCaseManager.GetAllTestCasesInTestPlan(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan);
                    }
                }
            }
            else if (ExecutionContext.Preferences.TestPlan.RootSuite != null && ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites != null && ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.Count > 0)
            {
                suiteTestCaseCollection     = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.First().Id);
                this.selectedSuiteId        = ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.First().Id;
                this.ShowSubSuitesTestCases = false;
                RegistryManager.Instance.WriteShowSubsuiteTestCases(false);
            }
            else
            {
                this.ShowSubSuitesTestCases = false;
                RegistryManager.Instance.WriteShowSubsuiteTestCases(false);
                suiteTestCaseCollection = TestCaseManager.GetAllTestCasesInTestPlan(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan);
            }

            this.ObservableTestCases       = new ObservableCollection <TestCase>();
            this.InitialTestCaseCollection = new ObservableCollection <TestCase>();
            suiteTestCaseCollection.ForEach(t => this.ObservableTestCases.Add(t));
            this.InitializeInitialTestCaseCollection(this.ObservableTestCases);
            this.TestCasesCount = this.ObservableTestCases.Count.ToString();

            this.Suites = new ObservableCollection <Suite>();
            ObservableCollection <Suite> currentSubSuites = new ObservableCollection <Suite>();
            var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <TestCase>();

            compiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <TestCase>(setting);
            subSuites.ForEach(s => currentSubSuites.Add(s));
            // Add a master node which will represnt all test cases in the plan. If selected all test cases will be displayed.
            Suite masterSuite = new Suite("ALL", -1, currentSubSuites);

            masterSuite.IsNodeExpanded  = true;
            masterSuite.IsSelected      = false;
            masterSuite.IsCopyEnabled   = false;
            masterSuite.IsRenameEnabled = false;
            masterSuite.IsCutEnabled    = false;
            masterSuite.IsRemoveEnabled = false;
            this.Suites.Add(masterSuite);
            TestSuiteManager.SetParentToAllChildrenSuites(masterSuite.SubSuites, masterSuite);
            this.SelectPreviouslySelectedSuite(this.Suites, this.selectedSuiteId);
            this.IsAfterInitialize            = true;
            this.SelectedTestCasesCount       = "0";
            this.CurrentExecutionStatusOption = TestCaseExecutionType.All;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCasesBatchDuplicateViewModel"/> class.
        /// </summary>
        public TestCasesBatchDuplicateViewModel(bool loadTestCases, bool loadSpecificTestCases)
        {
            this.InitializeInnerCollections();
            this.loadTestCases = loadTestCases;
            this.ShowTestCaseSpecificFields = loadTestCases;
            this.InitializeTeamFoundationIdentityNames();
            this.ReplaceContext = new ReplaceContext();

            if (loadTestCases)
            {
                if (!loadSpecificTestCases)
                {
                    this.InitializeTestCases();
                }
                else
                {
                    this.InitializeTestCasesFromSpecificSelectedTestCases();
                }
                this.InitializeInitialTestCaseCollection();
                this.EntitiesCount = this.ObservableTestCases.Count.ToString();
                this.InitializeTestSuiteList();
                this.ReplaceContext.SelectedSuite = this.ObservableTestSuites[0];
            }
            else
            {
                this.ObservableSharedSteps = new ObservableCollection<SharedStep>();
                List<SharedStep> allSharedSteps = SharedStepManager.GetAllSharedStepsInTestPlan(ExecutionContext.TestManagementTeamProject);
                allSharedSteps.ForEach(s => this.ObservableSharedSteps.Add(s));
                this.InitialSharedStepsCollection = new ObservableCollection<SharedStep>();
                allSharedSteps.ForEach(s => this.InitialSharedStepsCollection.Add(s));
                this.EntitiesCount = this.ObservableSharedSteps.Count.ToString();
            }
      
            if (this.ObservableTeamFoundationIdentityNames.Count > 0)
            {
                this.ReplaceContext.SelectedTeamFoundationIdentityName = this.ObservableTeamFoundationIdentityNames[0];
            }
            this.SelectedEntitiesCount = "0";
            var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting<TestCase>();
            testCasesCompiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler<TestCase>(setting);
            var sharedSteposSetting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting<SharedStep>();
            sharedStepsCompiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler<SharedStep>(sharedSteposSetting);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCasesInitialViewModel"/> class.
        /// </summary>
        public TestCasesInitialViewModel()
        {
            this.InitialViewFilters = new InitialViewFilters();
            List<Suite> subSuites = TestSuiteManager.GetAllSuites(ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites).ToList();
            subSuites.Sort();
            // Load last selected suite in the treeview in order to selected it again
            this.selectedSuiteId = RegistryManager.Instance.GetSelectedSuiteId();
            List<TestCase> suiteTestCaseCollection = new List<TestCase>();
            this.ShowSubSuitesTestCases = RegistryManager.Instance.ReadShowSubsuiteTestCases();

            if (this.selectedSuiteId != -1)
            {
                try
                {
                    suiteTestCaseCollection = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, this.selectedSuiteId);
                    this.AddTestCasesSubsuites(suiteTestCaseCollection);
                }
                catch (NullReferenceException ex)
                {
                    log.Error(ex);
                    if (subSuites.Count > 0)
                    {
                        suiteTestCaseCollection = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, subSuites[0].Id);
                        this.selectedSuiteId = subSuites[0].Id;
                    }
                    else
                    {
                        suiteTestCaseCollection = TestCaseManager.GetAllTestCasesInTestPlan(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan);
                    }
                }
            }
            else if (ExecutionContext.Preferences.TestPlan.RootSuite != null && ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites != null && ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.Count > 0)
            {
                suiteTestCaseCollection = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.First().Id);
                this.selectedSuiteId = ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.First().Id;
                this.ShowSubSuitesTestCases = false;
                RegistryManager.Instance.WriteShowSubsuiteTestCases(false);
            }
            else
            {
                this.ShowSubSuitesTestCases = false;
                RegistryManager.Instance.WriteShowSubsuiteTestCases(false);
                suiteTestCaseCollection = TestCaseManager.GetAllTestCasesInTestPlan(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan);
            }
            
            this.ObservableTestCases = new ObservableCollection<TestCase>();
            this.InitialTestCaseCollection = new ObservableCollection<TestCase>();
            suiteTestCaseCollection.ForEach(t => this.ObservableTestCases.Add(t));
            this.InitializeInitialTestCaseCollection(this.ObservableTestCases);
            this.TestCasesCount = this.ObservableTestCases.Count.ToString();
         
            this.Suites = new ObservableCollection<Suite>();
            ObservableCollection<Suite> currentSubSuites = new ObservableCollection<Suite>();
            var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting<TestCase>();
            compiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler<TestCase>(setting);
            subSuites.ForEach(s => currentSubSuites.Add(s));
            // Add a master node which will represnt all test cases in the plan. If selected all test cases will be displayed.
            Suite masterSuite = new Suite("ALL", -1, currentSubSuites);
            masterSuite.IsNodeExpanded = true;
            masterSuite.IsSelected = false;
            masterSuite.IsCopyEnabled = false;
            masterSuite.IsRenameEnabled = false;
            masterSuite.IsCutEnabled = false;
            masterSuite.IsRemoveEnabled = false;
            this.Suites.Add(masterSuite);
            TestSuiteManager.SetParentToAllChildrenSuites(masterSuite.SubSuites, masterSuite);
            this.SelectPreviouslySelectedSuite(this.Suites, this.selectedSuiteId);
            this.IsAfterInitialize = true;
            this.SelectedTestCasesCount = "0";
            this.CurrentExecutionStatusOption = TestCaseExecutionType.All;
        }