コード例 #1
0
        public void Setup()
        {
            _settingsViewModelBuilder = new ParameterSettingsViewModelBuilder(new ConnectionProviderStub());
            _builder = new ParameterViewModelBuilder(_settingsViewModelBuilder);

            _expectedViewModels = new List <ParameterViewModel>
            {
                new ParameterViewModel("@Start", _settingsViewModelBuilder),
                new ParameterViewModel("@End", _settingsViewModelBuilder)
            };

            _viewModels = new List <ParameterViewModel>();

            _query = @"
			    SELECT
				    ProductID,
				    DATEFROMPARTS(YEAR(soh.OrderDate), MONTH(soh.OrderDate), 01) [Date],
				    SUM(UnitPrice * OrderQty) [TotalSales]
			    FROM
				    [Sales].[SalesOrderDetail] sod
				    JOIN [Sales].[SalesOrderHeader] soh ON soh.SalesOrderID = sod.SalesOrderID
                WHERE
				    soh.OrderDate BETWEEN @Start AND @End
			    GROUP BY
				    ProductID,
				    DATEFROMPARTS(YEAR(soh.OrderDate), MONTH(soh.OrderDate), 01)
			    ORDER BY
				    [Date] DESC,
				    TotalSales DESC"                ;
        }
コード例 #2
0
        public TestEnvironmentViewModel(
            IViewFactory viewFactory,
            IConnectionProvider connectionProvider,
            DbCommandProvider dbCommandProvider,
            ParameterViewModelBuilder parameterViewModelBuilder)
        {
            _viewFactory                            = viewFactory;
            _connectionProvider                     = connectionProvider;
            _dbCommandProvider                      = dbCommandProvider;
            _parameterViewModelBuilder              = parameterViewModelBuilder;
            _connectionProvider.ConnectionsChanged += (sender, args) =>
            {
                Connections = BuildConnectionList(args.Connections);
                ActiveTest.SelectedConnection = Connections.First();
                ExecuteCommandHandler?.RaiseCanExecuteChanged();
            };

            Connections = BuildConnectionList(_connectionProvider.GetConnections());
            Tests       = new ObservableCollection <QueryStressTestViewModel>();

            AddNewQueryStressTest();
            OnConnectionChanged();

            ExecuteCommandHandler            = new CommandHandler((_) => Execute());
            StopCommandHandler               = new CommandHandler((_) => Stop());
            NewQueryStressTestCommandHandler = new CommandHandler((_) => AddNewQueryStressTest());
            ConnectionDropdownClosedCommand  = new CommandHandler((_) => OnConnectionDropdownClosed());
            ConnectionChangedCommand         = new CommandHandler((_) => OnConnectionChanged());
            DbCommandSelected            = new CommandHandler((dbCommand) => InvokeDbCommand((DbCommand)dbCommand));
            OpenParameterSettingsCommand = new CommandHandler((_) => OpenParameterSettings());
            RemoveTestCommand            = new CommandHandler((test) => RemoveTest((QueryStressTestViewModel)test));
        }