public void Modified()
        {
            IIndex index = GetIndex();
            IMergeOperation<IIndex> op = new IndexChangeOperation(index, new Index("Index1"));

            Assert.That(op.ToString(), Is.EqualTo("DB1.Table2.Index1 Changed"));
        }
Example #2
0
        public void Modified()
        {
            IIndex index = GetIndex();
            IMergeOperation <IIndex> op = new IndexChangeOperation(index, new Index("Index1"));

            Assert.That(op.ToString(), Is.EqualTo("DB1.Table2.Index1 Changed"));
        }
Example #3
0
            public void The_Original_Index_Should_Be_Modified()
            {
                var db1 = TestDatabaseLoader.TestDatabase();

                IIndex originalIndex = db1.Tables[0].Indexes[0];

                originalIndex.Description = "old description";

                IIndex newIndex = new Index(originalIndex.Name);

                newIndex.Parent = new Table("Table1");
                newIndex.Parent.AddColumn(new Column("Column2"));
                newIndex.Description = "new description";
                newIndex.AddColumn("Column2");

                IndexChangeOperation op = new IndexChangeOperation(db1.Tables[0].Indexes[0], newIndex);

                op.RunOperation();
                op.RunSecondStep();

                IIndex index = db1.Tables[0].Indexes[0];

                Assert.That(db1.Tables[0].Indexes, Has.Count(1), "No new indexes should have been added");
                Assert.That(index, Is.SameAs(originalIndex), "Index object should still be the same");
                Assert.That(index.Description, Is.EqualTo("old description"));
                Assert.That(index.Columns, Has.Count(1));
                Assert.That(index.Columns[0].Name, Is.EqualTo("Column2"));
                Assert.That(index.Columns[0], Is.Not.SameAs(newIndex.Columns[0]));
                Assert.That(index.Columns[0], Is.SameAs(db1.Tables[0].Columns[1]), "The new Index should reference existing columns");
                Assert.That(index.Parent, Is.SameAs(db1.Tables[0]), "The new Index's parent should be Table1 in the existing database");
            }
            public void The_Original_Index_Should_Be_Modified()
            {
                var db1 = TestDatabaseLoader.TestDatabase();

                IIndex originalIndex = db1.Tables[0].Indexes[0];
                originalIndex.Description = "old description";

                IIndex newIndex = new Index(originalIndex.Name);
                newIndex.Parent = new Table("Table1");
                newIndex.Parent.AddColumn(new Column("Column2"));
                newIndex.Description = "new description";
                newIndex.AddColumn("Column2");

                IndexChangeOperation op = new IndexChangeOperation(db1.Tables[0].Indexes[0], newIndex);
                op.RunOperation();
                op.RunSecondStep();

                IIndex index = db1.Tables[0].Indexes[0];

                Assert.That(db1.Tables[0].Indexes, Has.Count(1), "No new indexes should have been added");
                Assert.That(index, Is.SameAs(originalIndex), "Index object should still be the same");
                Assert.That(index.Description, Is.EqualTo("old description"));
                Assert.That(index.Columns, Has.Count(1));
                Assert.That(index.Columns[0].Name, Is.EqualTo("Column2"));
                Assert.That(index.Columns[0], Is.Not.SameAs(newIndex.Columns[0]));
                Assert.That(index.Columns[0], Is.SameAs(db1.Tables[0].Columns[1]), "The new Index should reference existing columns");
                Assert.That(index.Parent, Is.SameAs(db1.Tables[0]), "The new Index's parent should be Table1 in the existing database");
            }