Example #1
0
 public void CanAddScriptProperly()
 {
     var script = new DbScript();
     script.AddScript("HELLO");
     Assert.Equal(
         TestSqlHelper.Normalize("HELLO"),
         TestSqlHelper.Normalize(script.ToString()));
 }
Example #2
0
 public void InsertsGoBetweenScripts()
 {
     var script = new DbScript();
     script.AddScript("FIRST;");
     script.AddScript("SECOND;");
     Assert.Equal(
         TestSqlHelper.Normalize("FIRST;GO\nSECOND;"),
         TestSqlHelper.Normalize(script.ToString()));
 }
Example #3
0
        public void CanAddSqlUpdateProperly()
        {
            var script = new DbScript();
            script.Add(new TestRow
            {
                TestId = 1,
                Description = "Test"
            }.ToSqlUpdateById());

            Assert.Equal(TestSqlHelper.Normalize(
                "DECLARE @p1 NVARCHAR(4) = 'Test';" +
                "DECLARE @p2 BIGINT = 1;" +
                "UPDATE Tests SET Description = @p1 WHERE TestId = @p2"),
                TestSqlHelper.Normalize(script.ToString()));
        }
Example #4
0
        public void CanAddSqlInsertProperly()
        {
            var script = new DbScript();
            script.Add(new TestRow
            {
                TrackAssignments = true,
                TestId = 1,
                Description = "Test"
            }.ToSqlInsert());

            Assert.Equal(TestSqlHelper.Normalize(
                "DECLARE @p1 INT = 1;" +
                "DECLARE @p2 NVARCHAR(4) = 'Test';" +
                "INSERT INTO Tests (TestId, Description) VALUES (@p1, @p2)"),
                TestSqlHelper.Normalize(script.ToString()));
        }