Beispiel #1
0
        public void WhenViewChanged()
        {
            //arrange
            var sb     = new List <CompareResult>();
            var writer = new ComparisonWriter(SqlType.SqlServer);
            var target = new CompareViews(sb, writer);

            var baseViews = new List <DatabaseView> {
                CreateView()
            };
            var          view        = CreateView();
            const string orderByName = " ORDER BY NAME";

            view.Sql += orderByName;
            var compareViews = new List <DatabaseView> {
                view
            };

            //act
            target.Execute(baseViews, compareViews);
            var result = string.Join(Environment.NewLine, sb.Select(x => x.Script).ToArray());

            //assert
            Assert.IsTrue(result.Contains("DROP VIEW"));
            Assert.IsTrue(result.Contains("CREATE VIEW"));
            Assert.IsTrue(result.Contains(orderByName));
        }
Beispiel #2
0
        public void WhenViewsIdenticalWithDifferentFormatSql()
        {
            //arrange
            var sb     = new List <CompareResult>();
            var writer = new ComparisonWriter(SqlType.SqlServer);
            var target = new CompareViews(sb, writer);

            var databaseView = CreateView();

            databaseView.Sql = @"
create view ""Alphabetical list of products"" AS
SELECT Products.*, Categories.CategoryName
FROM Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID
WHERE (((Products.Discontinued)=0))
";
            var baseViews = new List <DatabaseView> {
                databaseView
            };
            var databaseView2 = CreateView();

            databaseView2.Sql = @"create view [dbo].[Alphabetical list of products] AS
SELECT Products.*, Categories.CategoryName
FROM Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID
WHERE (((Products.Discontinued)=0))";
            var compareViews = new List <DatabaseView> {
                databaseView2
            };

            //act
            target.Execute(baseViews, compareViews);
            var result = string.Join(Environment.NewLine, sb.Select(x => x.Script).ToArray());

            //assert
            Assert.IsTrue(string.IsNullOrEmpty(result));
        }
        public void WhenViewChanged()
        {
            //arrange
            var sb     = new StringBuilder();
            var writer = new ComparisonWriter(SqlType.SqlServer);
            var target = new CompareViews(sb, writer);

            var baseViews = new List <DatabaseView> {
                CreateView()
            };
            var          view        = CreateView();
            const string orderByName = " ORDER BY NAME";

            view.Sql += orderByName;
            var compareViews = new List <DatabaseView> {
                view
            };

            //act
            target.Execute(baseViews, compareViews);
            var result = sb.ToString();

            //assert
            Assert.IsTrue(result.Contains("DROP VIEW"));
            Assert.IsTrue(result.Contains("CREATE VIEW"));
            Assert.IsTrue(result.Contains(orderByName));
        }
Beispiel #4
0
        public void WhenViewAdded()
        {
            //arrange
            var sb     = new List <CompareResult>();
            var writer = new ComparisonWriter(SqlType.SqlServer);
            var target = new CompareViews(sb, writer);

            var baseViews    = new List <DatabaseView>();
            var compareViews = new List <DatabaseView> {
                CreateView()
            };

            //act
            target.Execute(baseViews, compareViews);
            var result = string.Join(Environment.NewLine, sb.Select(x => x.Script).ToArray());

            //assert
            Assert.IsTrue(result.Contains("CREATE VIEW"));
        }
        public void WhenViewAdded()
        {
            //arrange
            var sb     = new StringBuilder();
            var writer = new ComparisonWriter(SqlType.SqlServer);
            var target = new CompareViews(sb, writer);

            var baseViews    = new List <DatabaseView>();
            var compareViews = new List <DatabaseView> {
                CreateView()
            };

            //act
            target.Execute(baseViews, compareViews);
            var result = sb.ToString();

            //assert
            Assert.IsTrue(result.Contains("CREATE VIEW"));
        }
        public void WhenViewsIdentical()
        {
            //arrange
            var sb     = new StringBuilder();
            var writer = new ComparisonWriter(SqlType.SqlServer);
            var target = new CompareViews(sb, writer);

            var baseViews = new List <DatabaseView> {
                CreateView()
            };
            var compareViews = new List <DatabaseView> {
                CreateView()
            };

            //act
            target.Execute(baseViews, compareViews);
            var result = sb.ToString();

            //assert
            Assert.IsTrue(string.IsNullOrEmpty(result));
        }