예제 #1
0
        public void Process_VariableReplacement_Undefined()
        {
            var preprocessor = new SqlCmdPreprocessor {
            };

            preprocessor
            .Invoking(p => p.Process("$(foo)").Count())
            .Should().Throw <SqlCmdException>()
            .WithMessage("SqlCmd variable 'foo' is not defined.");
        }
예제 #2
0
        public void Process_VariableReplacement_Unterminated()
        {
            var preprocessor = new SqlCmdPreprocessor
            {
                Variables = { ["foo"] = "bar" }
            };

            preprocessor
            .Invoking(p => p.Process("$(foo").Count())
            .Should().Throw <SqlCmdException>()
            .WithMessage("Unterminated reference to SqlCmd variable 'foo'.");
        }
예제 #3
0
        public void Process_SetVariable_DoubleQuoted_Unterminated(string eol, string eof)
        {
            var preprocessor = new SqlCmdPreprocessor {
            };

            var text = Lines(eol, eof, @":setvar foo ""bar");

            preprocessor
            .Invoking(p => p.Process(text).Count())
            .Should().Throw <SqlCmdException>()
            .WithMessage("Unterminated double-quoted string.");

            preprocessor.Variables.Should().NotContainKey("foo");
        }
예제 #4
0
        public void Process_SetVariable_Unquoted_Invalid(string eol, string eof)
        {
            var preprocessor = new SqlCmdPreprocessor {
            };

            var text = Lines(eol, eof, ":setvar foo bar baz");

            preprocessor
            .Invoking(p => p.Process(text).Count())
            .Should().Throw <SqlCmdException>()
            .WithMessage("Invalid syntax in :setvar directive.");

            preprocessor.Variables.Should().NotContainKey("foo");
        }
예제 #5
0
        public void Process_SetVariable_Unset(string eol, string eof)
        {
            var preprocessor = new SqlCmdPreprocessor
            {
                Variables = { ["foo"] = "bar" }
            };

            var text = Lines(eol, eof, ":setvar foo", "$(foo)");

            preprocessor
            .Invoking(p => p.Process(text).Count())
            .Should().Throw <SqlCmdException>()
            .WithMessage("SqlCmd variable 'foo' is not defined.");

            preprocessor.Variables.Should().NotContainKey("foo");
        }