예제 #1
0
        public void MainViewModel_shows_init_text_on_startup()
        {
            var mocks = new MainViewModelMocks();
            var model = new MainViewModel(mocks.SqlQueryExecutorMock, mocks.MainViewMock,
                                          mocks.WindowsIdentityProviderMock, mocks.DBInfoBuilderMock);

            Assert.AreEqual(model.HelpText, model.INIT_TEXT);
        }
예제 #2
0
        public void Connect_click_shows_error_when_connection_is_invalid()
        {
            var mocks = new MainViewModelMocks();
            var model = new MainViewModel(mocks.SqlQueryExecutorMock, mocks.MainViewMock,
                                          mocks.WindowsIdentityProviderMock, mocks.DBInfoBuilderMock);
            mocks.SqlQueryExecutorMock.Stub(x => x.ConnectionIsValid(string.Empty)).IgnoreArguments().Return(false);

            model.Connect.Execute(null);

            mocks.MainViewMock.Dialogs.AssertWasCalled(x => x.Error(string.Empty), options => options.IgnoreArguments());
        }
예제 #3
0
        public void Analyse_click_shows_message_when_no_database_selected()
        {
            var mocks = new MainViewModelMocks();
            var model = new MainViewModel(mocks.SqlQueryExecutorMock, mocks.MainViewMock,
                                          mocks.WindowsIdentityProviderMock, mocks.DBInfoBuilderMock);

            mocks.MainViewMock.Stub(x => x.SelectedItem).Return(null);
            model.Analyse.Execute(null);

            mocks.MainViewMock.Dialogs.AssertWasCalled(x => x.Info(string.Empty), options => options.IgnoreArguments());
            mocks.MainViewMock.AssertWasNotCalled(x => x.CreateDetailsWindow());
        }
예제 #4
0
        public void Analyse_click_shows_details_view()
        {
            var mocks = new MainViewModelMocks();
            var model = new MainViewModel(mocks.SqlQueryExecutorMock, mocks.MainViewMock,
                                          mocks.WindowsIdentityProviderMock, mocks.DBInfoBuilderMock);

            var dbInfo1 = MockRepository.GenerateStub<IDBInfo>();
            dbInfo1.Stub(x => x.Name).Return("testName");
            var dbInfoViewItem1 = new DBInfoListItem(dbInfo1, null);
            mocks.MainViewMock.Stub(x => x.SelectedItem).Return(dbInfoViewItem1);

            model.Analyse.Execute(null);

            mocks.MainViewMock.AssertWasCalled(x => x.CreateDetailsWindow());
            mocks.DatabaseDetailsWindowMock.AssertWasCalled(x => x.ShowDialog());
            Assert.IsInstanceOfType(mocks.DatabaseDetailsWindowMock.DataContext, typeof(DatabaseDetailsViewModel));
        }
예제 #5
0
        public void Only_checked_databases_shows_on_chart()
        {
            var mocks = new MainViewModelMocks();
            var model = new MainViewModel(mocks.SqlQueryExecutorMock, mocks.MainViewMock,
                                          mocks.WindowsIdentityProviderMock, mocks.DBInfoBuilderMock);

            var chart = MockRepository.GenerateStub<IRefreshChartBinding>();
            var dbInfo1 = MockRepository.GenerateStub<IDBInfo>();
            var dbInfoViewItem1 = new DBInfoListItem(dbInfo1, chart);
            dbInfoViewItem1.IsChecked = true;

            var dbInfo2 = MockRepository.GenerateStub<IDBInfo>();
            var dbInfoViewItem2 = new DBInfoListItem(dbInfo2, chart);
            dbInfoViewItem2.IsChecked = false;

            model.AllDataBases.Add(dbInfoViewItem1);
            model.AllDataBases.Add(dbInfoViewItem2);

            Assert.AreEqual(1, model.DataBasesForChart.Count);
            Assert.AreEqual(dbInfoViewItem1, model.DataBasesForChart[0]);
        }
예제 #6
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new MainViewModel(new SqlQueryExecutor(), (IMainView)this,
         new WindowsIdentityProvider(), new DBInfoBuilder());
 }