public void Given_a_specification_with_a_missing_table_then_the_missing_table_should_be_detected()
            {
                // Arrange
                TestingSchemaSpecification spec1 = new TestingSchemaSpecification();
                spec1.AddTable("t1");
                Table expected = spec1.AddTable("t2");

                TestingSchemaSpecification spec2 = new TestingSchemaSpecification();
                spec2.AddTable("t1");

                // Act
                CompareResult result = spec1.Compare(spec2);

                // Assert
                Assert.That(result.MissingList.Count, Is.EqualTo(1));
                Assert.That(result.MissingList[0], Is.SameAs(expected));
            }
 public void SetUp()
 {
     _testingSchemaSpec = new TestingSchemaSpecification();
 }
            public void Given_two_specifications_with_differences_in_one_table_then_conflict_should_be_detected()
            {
                // Arrange
                TestingSchemaSpecification spec1 = new TestingSchemaSpecification();
                spec1.AddTable("irrelevant");
                Table expectedFirst = spec1.AddTable("t2").WithColumn("c1").Done();

                TestingSchemaSpecification spec2 = new TestingSchemaSpecification();
                spec2.AddTable("irrelevant");
                Table expectedSecond = spec2.AddTable("t2");

                // Act
                CompareResult result = spec1.Compare(spec2);

                // Assert
                Assert.That(result.ConflictList.Count, Is.EqualTo(1));
                Assert.That(result.ConflictList[0].First, Is.SameAs(expectedFirst));
                Assert.That(result.ConflictList[0].Second, Is.SameAs(expectedSecond));
            }
            public void Then_should_return_table_conflicts_with_their_columns_conflicts()
            {
                // Arrange
                TestingSchemaSpecification spec1 = new TestingSchemaSpecification();
                TestingSchemaSpecification spec2 = new TestingSchemaSpecification();

                spec1.AddTable("t1").WithColumn("t1_c1").OfType("int", 4);
                spec1.AddTable("t2").WithColumn("T2_c1").Done();

                spec2.AddTable("t1").WithColumn("t1_c1").OfType("varchar", 4);
                spec2.AddTable("t2");

                // Act
                CompareResult result = spec1.Compare(spec2);

                // Assert
                Assert.That(result.ConflictList.Count, Is.EqualTo(2));
                var firstConflict = result.ConflictList[0];
                Assert.That(firstConflict.Detail, Is.Not.Null);

                var t1ColumnConflictList = firstConflict.Detail.ConflictList;
                Assert.That(t1ColumnConflictList.Count, Is.EqualTo(1));

                Assert.That(t1ColumnConflictList[0].First, Is.TypeOf<Column>());
                Assert.That(((Column)t1ColumnConflictList[0].First).ColumnType, Is.EqualTo("int"));
                Assert.That(((Column)t1ColumnConflictList[0].Second).ColumnType, Is.EqualTo("varchar"));

                // Asserting missing column
                var secondConflict = result.ConflictList[1];
                Assert.That(secondConflict.Detail, Is.Not.Null);
                var t2ColumnMissingList = secondConflict.Detail.MissingList;
                Assert.That(t2ColumnMissingList.Count, Is.EqualTo(1));
                Assert.That(t2ColumnMissingList[0], Is.TypeOf<Column>());
                Assert.That(t2ColumnMissingList[0].Name, Is.EqualTo("T2_c1"));
            }
            public void Given_a_specification_with_extra_tables_then_the_extra_tables_should_be_ignored()
            {
                // Arrange
                TestingSchemaSpecification spec1 = new TestingSchemaSpecification();
                spec1.AddTable("t1");

                TestingSchemaSpecification spec2 = new TestingSchemaSpecification();
                spec2.AddTable("t1");
                spec2.AddTable("t2");

                // Act
                CompareResult result = spec1.Compare(spec2);

                // Assert
                Assert.That(result.HaveValues, Is.False);
            }