public void All_Of_The_Operations_Are_Put_Into_The_Result()
        {
            var columnOp = MockRepository.GenerateMock<MergeOperation<IColumn>>();
            var tableOp = MockRepository.GenerateMock<MergeOperation<ITable>>();
            var keyOp = MockRepository.GenerateMock<MergeOperation<IKey>>();
            var indexOp = MockRepository.GenerateMock<MergeOperation<IIndex>>();

            DatabaseMergeResult result1 = new DatabaseMergeResult();
            result1.AddColumnOperation(columnOp);
            result1.AddTableOperation(tableOp);
            result1.AddKeyOperation(keyOp);
            result1.AddIndexOperation(indexOp);

            DatabaseMergeResult result2 = new DatabaseMergeResult();
            result2.CopyFrom(result1);

            Assert.That(result1.ColumnOperations, Has.Count(1));
            Assert.That(result1.TableOperations, Has.Count(1));
            Assert.That(result1.KeyOperations, Has.Count(1));
            Assert.That(result1.IndexOperations, Has.Count(1));

            Assert.That(result1.ColumnOperations.ElementAt(0), Is.SameAs(columnOp));
            Assert.That(result1.TableOperations.ElementAt(0), Is.SameAs(tableOp));
            Assert.That(result1.KeyOperations.ElementAt(0), Is.SameAs(keyOp));
            Assert.That(result1.IndexOperations.ElementAt(0), Is.SameAs(indexOp));
        }
        public void All_Of_The_Operations_Are_Put_Into_The_Result()
        {
            var columnOp = MockRepository.GenerateMock <MergeOperation <IColumn> >();
            var tableOp  = MockRepository.GenerateMock <MergeOperation <ITable> >();
            var keyOp    = MockRepository.GenerateMock <MergeOperation <IKey> >();
            var indexOp  = MockRepository.GenerateMock <MergeOperation <IIndex> >();

            DatabaseMergeResult result1 = new DatabaseMergeResult();

            result1.AddColumnOperation(columnOp);
            result1.AddTableOperation(tableOp);
            result1.AddKeyOperation(keyOp);
            result1.AddIndexOperation(indexOp);

            DatabaseMergeResult result2 = new DatabaseMergeResult();

            result2.CopyFrom(result1);

            Assert.That(result1.ColumnOperations, Has.Count(1));
            Assert.That(result1.TableOperations, Has.Count(1));
            Assert.That(result1.KeyOperations, Has.Count(1));
            Assert.That(result1.IndexOperations, Has.Count(1));

            Assert.That(result1.ColumnOperations.ElementAt(0), Is.SameAs(columnOp));
            Assert.That(result1.TableOperations.ElementAt(0), Is.SameAs(tableOp));
            Assert.That(result1.KeyOperations.ElementAt(0), Is.SameAs(keyOp));
            Assert.That(result1.IndexOperations.ElementAt(0), Is.SameAs(indexOp));
        }
Exemple #3
0
        public void It_Should_Call_Back_To_The_Main_Panel()
        {
            var form    = MockRepository.GenerateMock <ISimpleDBMergeResultForm>();
            var results = new DatabaseMergeResult();
            var panel   = MockRepository.GenerateMock <IMainPanel>();

            var tableOp  = MockRepository.GenerateMock <IMergeOperation <ITable> >();
            var columnOp = MockRepository.GenerateMock <IMergeOperation <IColumn> >();
            var keyOp    = MockRepository.GenerateMock <IMergeOperation <IKey> >();
            var indexOp  = MockRepository.GenerateMock <IMergeOperation <IIndex> >();

            results.AddTableOperation(tableOp);
            results.AddColumnOperation(columnOp);
            results.AddKeyOperation(keyOp);
            results.AddIndexOperation(indexOp);

            new SimpleDBMergeResultPresenter(form, panel, results);
            form.GetEventRaiser(f => f.ChangesCancelled += null).Raise(form, null);

            panel.AssertWasCalled(f => f.CloseDatabaseRefreshResultsForm(Changes.WereRejected));
            tableOp.AssertWasNotCalled(o => o.RunOperation());
            columnOp.AssertWasNotCalled(o => o.RunOperation());
            keyOp.AssertWasNotCalled(o => o.RunOperation());
            indexOp.AssertWasNotCalled(o => o.RunOperation());
        }
        public void The_Operations_Come_Back_In_A_Good_Order()
        {
            DatabaseMergeResult result = new DatabaseMergeResult();
            result.AddIndexOperation(new IndexAdditionOperation(new Table(), new Index()));
            result.AddKeyOperation(new KeyAdditionOperation(new Table(), new Key()));
            // Not a ITwoStepMergeOperation
            result.AddTableOperation(new TableAdditionOperation(new Database(""), new Table()));

            IEnumerable<ITwoStepMergeOperation> list = result.TwoStepOperations;

            Assert.That(list, Has.Count(2));
            Assert.That(list.ElementAt(0) is KeyAdditionOperation);
            Assert.That(list.ElementAt(1) is IndexAdditionOperation);
        }
Exemple #5
0
        public void The_Operations_Come_Back_In_A_Good_Order()
        {
            DatabaseMergeResult result = new DatabaseMergeResult();

            result.AddIndexOperation(new IndexAdditionOperation(new Table(), new Index()));
            result.AddKeyOperation(new KeyAdditionOperation(new Table(), new Key()));
            // Not a ITwoStepMergeOperation
            result.AddTableOperation(new TableAdditionOperation(new Database(""), new Table()));

            IEnumerable <ITwoStepMergeOperation> list = result.TwoStepOperations;

            Assert.That(list, Has.Count(2));
            Assert.That(list.ElementAt(0) is KeyAdditionOperation);
            Assert.That(list.ElementAt(1) is IndexAdditionOperation);
        }
Exemple #6
0
        public void It_Should_Apply_Changes_And_Call_Back_To_The_Main_Panel()
        {
            var form    = MockRepository.GenerateStub <ISimpleDBMergeResultForm>();
            var results = new DatabaseMergeResult();
            var panel   = MockRepository.GenerateMock <IMainPanel>();

            // These are all two step processes
            var tableOp  = new MockMergeOperation <ITable, Table>();
            var columnOp = new MockMergeOperation <IColumn, Column>();
            var keyOp    = new MockMergeOperation <IKey, Key>();
            var indexOp  = new MockMergeOperation <IIndex, Index>();

            results.AddTableOperation(tableOp);
            results.AddColumnOperation(columnOp);
            results.AddKeyOperation(keyOp);
            results.AddIndexOperation(indexOp);

            form.Stub(f => { var v = f.SelectedAddedTableOperations; }).Return(new List <IMergeOperation <ITable> > {
                tableOp
            });
            form.Stub(f => { var v = f.SelectedRemovedTableOperations; }).Return(new List <IMergeOperation <ITable> >());

            new SimpleDBMergeResultPresenter(form, panel, results);
            form.GetEventRaiser(f => f.ChangesAccepted += null).Raise(form, null);

            panel.AssertWasCalled(f => f.CloseDatabaseRefreshResultsForm(Changes.WereAccepted));

            Assert.That(tableOp.OperationRun, Is.True);
            Assert.That(indexOp.OperationRun, Is.True);
            Assert.That(columnOp.OperationRun, Is.True);
            Assert.That(keyOp.OperationRun, Is.True);

            Assert.That(tableOp.SecondStepRun, Is.True);
            Assert.That(indexOp.SecondStepRun, Is.True);
            Assert.That(columnOp.SecondStepRun, Is.True);
            Assert.That(keyOp.SecondStepRun, Is.True);
        }