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."); }
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'."); }
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"); }
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"); }
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"); }