public void ToString_should_return_string_representation_for_conflict_columns()
        {
            // Arrange
            Table t1 = new Table("t1").WithColumn("column1").OfType("int", 4).Done();
            Table t2 = new Table("t1").WithColumn("column1").OfType("varchar", 4).Done();

            CompareResult compareResult = t1.Compare(t2);

            string expected = "Conflict Column(s)\n" +
                              "----------------\n" +
                              "Expected: column1 : int(4)\n" +
                              "But was:  column1 : varchar(4)\n\n";

            // Act
            string result = compareResult.ToString();

            // Assert
            Assert.That(result, Is.EqualTo(expected));
        }
        public void ToString_should_return_string_representation_for_missing_columns()
        {
            // Arrange
            Table t1 = new Table("t1").WithColumn("Id").OfType("int", 4)
                                      .WithColumn("Desc").OfType("varchar", 100).Nullable()
                                      .Done();
            Table t2 = new Table("t1");

            CompareResult compareResult = t1.Compare(t2);

            string expected = "Missing Column(s)\n" +
                              "----------------\n" +
                              "Id : int(4)\n" +
                              "Desc : varchar(100) NULLABLE\n";

            // Act
            string result = compareResult.ToString();

            // Assert
            Assert.That(result, Is.EqualTo(expected));
        }
Example #3
0
            public void Given_a_table_with_a_missing_column_then_the_missing_column_should_be_detected()
            {
                // Arrange
                Table t1 = new Table("t1");
                t1.WithColumn("c1");

                Table t2 = new Table("t1");

                // Act
                CompareResult result = t1.Compare(t2);

                // Assert
                Assert.That(result.MissingList.Count, Is.EqualTo(1));
                Assert.That(result.MissingList[0].Name, Is.EqualTo("c1"));
            }
Example #4
0
            public void Then_table_names_should_be_case_insensitive()
            {
                // Arrange
                Table t1 = new Table("T1");
                Table t2 = new Table("t1");

                // Act
                CompareResult result = t1.Compare(t2);

                // Assert
                Assert.That(result, Is.Not.Null);
            }
Example #5
0
            public void Should_have_same_table_names_to_be_a_valid_operation()
            {
                // Arrange
                Table t1 = new Table("t1");
                Table t2 = new Table("t1");

                // Act
                CompareResult result = t1.Compare(t2);

                // Assert
                Assert.That(result, Is.Not.Null);
            }
Example #6
0
            public void Given_two_tables_with_different_names_then_should_throw_InvalidOperationException()
            {
                // Arrange
                Table t1 = new Table("t1");
                Table t2 = new Table("t2");

                // Act & Assert
                Assert.Throws<InvalidOperationException>(() => t1.Compare(t2));
            }
Example #7
0
            public void Given_two_tables_with_different_columnType_then_conflict_should_be_detected()
            {
                // Arrange
                Table t1 = new Table("t1");
                Column expectedFirst = t1.WithColumn("c1").OfType("int", 4);
                t1.WithColumn("irrelevant").OfType("varchar", 3);

                Table t2 = new Table("t1");
                Column expectedSecond = t2.WithColumn("c1").OfType("varchar", 4);
                t2.WithColumn("irrelevant").OfType("varchar", 3);

                // Act
                CompareResult result = t1.Compare(t2);

                // 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));
            }
Example #8
0
            public void Given_a_table_with_extra_columns_then_the_extra_columns_should_be_ignored()
            {
                // Arrange
                Table t1 = new Table("t1");
                t1.WithColumn("c1");

                Table t2 = new Table("t1");
                t2.WithColumn("c1");
                t2.WithColumn("c2");

                // Act
                CompareResult result = t1.Compare(t2);

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