コード例 #1
0
        public void The_Presenter_Refreshes_The_Database_And_Attempts_To_Show_The_Results()
        {
            IDatabaseForm form = MockRepository.GenerateMock<IDatabaseForm>();
            IMainPanel panel = MockRepository.GenerateMock<IMainPanel>();
            IDatabase db = MockRepository.GenerateStub<IDatabase>();

            db.Stub(d => d.Tables).Return(new ReadOnlyCollection<ITable>(new List<ITable>()));

            var presenter = new DatabasePresenter(panel, form);
            presenter.AttachToModel(db);

            AutoResetEvent arEvent = new AutoResetEvent(false);
            presenter.SchemaRefreshed += (sender, e) => arEvent.Set();

            form.Stub(t => t.SelectedDatabaseType).Return(DatabaseTypes.SQLCE);
            form.Stub(t => t.SelectedDatabase).Return("1Table3Columns.sdf");

            var raiser = form.GetEventRaiser(t => t.RefreshSchema += null);
            raiser.Raise(form, null);

            Assert.That(arEvent.WaitOne(10000, true), "The test timed out waiting for the SchemaRefreshed event to be triggered");

            panel.AssertWasCalled(p => p.ShowDatabaseRefreshResults(
                Arg<DatabaseMergeResult>.Matches(t => t.TableOperations.Count() == 1)));
        }
コード例 #2
0
        public void The_DatabaseName_Is_Wired_Up_Correctly()
        {
            IDatabaseForm form = MockRepository.GenerateMock<IDatabaseForm>();
            Database obj = new Database("Database1");
            obj.Loader = DatabaseLoaderFacade.GetSQLCELoader("asdfsdf.sdf");
            IMainPanel panel = MockRepository.GenerateMock<IMainPanel>();

            var presenter = new DatabasePresenter(panel, form);
            presenter.AttachToModel(obj);

            form.AssertWasCalled(a => a.SelectedDatabaseType = DatabaseTypes.SQLCE);
            form.AssertWasCalled(a => a.SetDatabaseFilename("asdfsdf.sdf"));
            form.AssertWasCalled(a => a.DatabaseHelper = Arg<IServerAndDatabaseHelper>.Is.NotNull);
        }
コード例 #3
0
        public void The_DatabaseName_Is_Wired_Up_Correctly_With_DatabaseName()
        {
            IDatabaseForm form = MockRepository.GenerateMock<IDatabaseForm>();
            Database obj = new Database("Database1");

            ISQLServer2005DatabaseConnector connector = MockRepository.GenerateStub<ISQLServer2005DatabaseConnector>();

            connector.ConnectionInformation = new ConnectionStringHelper
                                              	{
                                              		UserName = "******",
                                              		Password = "******",
                                              		ServerName = "Server",
                                              		UseFileName = true
                                              	};
            connector.DatabaseName = "DatabaseName";
            obj.Loader = new SQLServer2005DatabaseLoader(connector);

            IMainPanel panel = MockRepository.GenerateMock<IMainPanel>();

            var presenter = new DatabasePresenter(panel, form);
            presenter.AttachToModel(obj);

            form.AssertWasCalled(a => a.SelectedDatabaseType = DatabaseTypes.SQLServer2005);
            form.AssertWasCalled(a => a.SetDatabaseFilename("DatabaseName"));
            form.AssertWasCalled(a => a.Username = "******");
            form.AssertWasCalled(a => a.Password = "******");
            form.AssertWasCalled(a => a.SelectedServerName = "Server");
            form.AssertWasCalled(a => a.DatabaseHelper = Arg<IServerAndDatabaseHelper>.Is.NotNull);
        }