public void containerTest1() { var uvar = new UserVariable(); Script target = new Script(env, uvar); Assert.AreEqual("ne]", target.parse("#[var name = value\nli]ne]")); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("value\nli", uvar.get("name")); }
public void containerTest2() { var uvar = new UserVariable(); Script target = new Script(env, uvar); Assert.AreEqual(String.Empty, target.parse("#[var name = <#data>value\nli]ne</#data>]")); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("value\nli]ne", uvar.get("name")); }
public void catchTest1() { var uvar = new UserVariable(); var target = new Script(new StubEnv(), uvar); target.parse("#[try{ $(test = '123') }catch{ $(test2 = '456') }]"); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("123", uvar.get("test", null)); }
public void catchTest2() { var uvar = new UserVariable(); var target = new Script(new StubEnv(), uvar); Assert.AreEqual(0, uvar.Variables.Count()); target.parse("#[try{ #[notrealcomponentToError] $(test = '123') }catch{ $(test2 = '456') }]"); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("456", uvar.get("test2", null)); }
public void containerTest3() { var uvar = new UserVariable(); Script target = new Script(env, uvar); uvar.set("mx", null, "<#data>value\nli]ne</#data>"); uvar.evaluate("mx", null, new EvaluatorBlank(), true); Assert.AreEqual(String.Empty, target.parse("#[var name = #[var mx]]")); Assert.AreEqual(2, uvar.Variables.Count()); Assert.AreEqual("value\nli]ne", uvar.get("name")); }
public void iterateTest4() { var uvar = new UserVariable(); var target = new Script(new StubEnv(), uvar); Assert.AreEqual("ab!ab!ab!", noSpaces(@" #[Box iterate(i = 1; $(i) < 4; i = $([MSBuild]::Add($(i), 1))): ab! ]", target)); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("4", uvar.get("i", null)); }
public void catchTest3() { var uvar = new UserVariable(); var target = new Script(new StubEnv(), uvar); Assert.AreEqual(0, uvar.Variables.Count()); target.parse(@" #[( false ){ #[try { #[notrealcomponentToError] } catch(err, msg) { $(test1 = '123') }] } else{ #[try { #[notrealcomponentToError] } catch(err, msg) { $(test2 = '456') $(exErr = $(err)) $(exMsg = $(msg)) }] }] "); Assert.AreEqual(3, uvar.Variables.Count()); Assert.AreEqual(null, uvar.get("test1", null)); Assert.AreEqual("456", uvar.get("test2", null)); Assert.AreEqual(true, !string.IsNullOrWhiteSpace(uvar.get("exErr", null))); Assert.AreEqual(true, !string.IsNullOrWhiteSpace(uvar.get("exMsg", null))); Assert.AreEqual(null, uvar.get("err", null)); Assert.AreEqual(null, uvar.get("msg", null)); }
public void catchTest4() { var uvar = new UserVariable(); var target = new Script(new StubEnv(), uvar); Assert.AreEqual(0, uvar.Variables.Count()); target.parse(@" #[( false ){ #[try { #[notrealcomponentToError] } catch { $(test1 = '123') }] } else{ #[try { #[notrealcomponentToError] } catch { $(test2 = '456') }] }] "); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual(null, uvar.get("test1", null)); Assert.AreEqual("456", uvar.get("test2", null)); Assert.AreEqual(null, uvar.get("err", null)); Assert.AreEqual(null, uvar.get("msg", null)); }
public void containerTest9() { var uvar = new UserVariable(); Script target = new Script(env, uvar); Assert.AreEqual("test - cc", target.parse("#[var sres = <#data>Data1\n\nEnd</#data>]test - cc#[var sres2 = <#data>Data2\n\nEnd</#data>]")); Assert.AreEqual(2, uvar.Variables.Count()); Assert.AreEqual("Data1\n\nEnd", uvar.get("sres")); Assert.AreEqual("Data2\n\nEnd", uvar.get("sres2")); }
public void containerTest7() { var uvar = new UserVariable(); Script target = new Script(env, uvar); Assert.AreEqual("#[var name = left [box1 right]", target.parse("#[var name = left [box1 right]")); Assert.AreEqual(0, uvar.Variables.Count()); Assert.AreEqual(String.Empty, target.parse("#[var name = \"left [box1 right\"]")); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("\"left [box1 right\"", uvar.get("name")); }
public void evaluateTest4() { UserVariable target = new UserVariable(); string name = "name"; string project = "project"; target.set(name, project, "val"); target.evaluate(name, project, new Evaluator1(), true); Assert.AreEqual("[E1:val]", target.get(name, project)); }
public void getTest3() { UserVariable target = new UserVariable(); target.set("name", null, "val"); Assert.AreEqual(String.Empty, target.get("name")); }
public void getTest() { UserVariable target = new UserVariable(); Assert.AreEqual(null, target.get("name")); Assert.AreEqual(null, target.get("name", "project")); }
public void vtSignTest1() { var uvar = new UserVariable(); var target = new Parser(new StubEnv(), uvar); Assert.AreEqual(String.Empty, target.parse("$(+name = 'myvar')")); Assert.AreEqual("myvar", uvar.get("name")); Assert.AreEqual(String.Empty, target.parse("$(+name += '12')")); Assert.AreEqual("myvar12", uvar.get("name")); Assert.AreEqual(String.Empty, target.parse("$(name += '34')")); Assert.AreEqual("myvar1234", uvar.get("name")); }
public void repeatTest4() { var uvar = new UserVariable(); var target = new Script(new StubEnv(), uvar); Assert.AreEqual("ab!ab!ab!ab!", noSpaces(@" #[$(i = 0)]#[Box repeat($(i) < 4; false): $(i = $([MSBuild]::Add($(i), 1))) ab! ]", target)); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("4", uvar.get("i", null)); }
public void repeatTest3() { var uvar = new UserVariable(); var target = new Script(new StubEnv(), uvar); Assert.AreEqual(String.Empty, noSpaces(@" #[$(i = 2)]#[Box repeat($(i) < 8; true): $(i = $([MSBuild]::Add($(i), 1))) ab! ]", target)); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("8", uvar.get("i", null)); }
public void quotesTest7() { var uvar = new UserVariable(); var target = new Parser(new StubEnv(), uvar); uvar.set("lp", null, "s1\\dir"); uvar.evaluate("lp", null, new EvaluatorBlank(), true); Assert.AreEqual("s1\\dir", uvar.get("lp", null)); Assert.AreEqual("\"s1\\dir\\p1.exe\"", target.parse("\"$(lp)\\p1.exe\"")); Assert.AreEqual("'$(lp)\\p2.exe'", target.parse("'$(lp)\\p2.exe'")); Assert.AreEqual("s1\\dir\\p3.exe", target.parse("$(lp)\\p3.exe")); }
public void vtSignTest5() { var uvar = new UserVariable(); var target = new Parser(new StubEnv(), uvar); Assert.AreEqual(String.Empty, target.parse("$(i = 1)")); Assert.AreEqual(String.Empty, target.parse("$(i += $(i))")); Assert.AreEqual("2", uvar.get("i")); //TODO: currently std. exception: try { Assert.AreEqual(String.Empty, target.parse("$(i += 'test')")); Assert.Fail("1"); } catch(Exception ex) { Assert.IsTrue(true /*ex.GetType() == typeof(NotFoundException)*/, ex.GetType().ToString()); } }
public void vtSignTest4() { var uvar = new UserVariable(); var target = new Parser(new StubEnv(), uvar); Assert.AreEqual(String.Empty, target.parse("$(i = \"test\")")); Assert.AreEqual(String.Empty, target.parse("$(i += 1)")); Assert.AreEqual("test1", uvar.get("i")); target.parse("$(i -= 1)"); }
public void vtSignTest3() { var uvar = new UserVariable(); var target = new Parser(new StubEnv(), uvar); Assert.AreEqual(String.Empty, target.parse("$(i += 1)")); Assert.AreEqual("1", uvar.get("i")); Assert.AreEqual(String.Empty, target.parse("$(j -= 1)")); Assert.AreEqual("-1", uvar.get("j")); }
public void vtSignTest2() { var uvar = new UserVariable(); var target = new Parser(new StubEnv(), uvar); Assert.AreEqual(String.Empty, target.parse("$(i = 0)")); Assert.AreEqual(String.Empty, target.parse("$(i += 1)")); Assert.AreEqual(String.Empty, target.parse("$(i += 2)$(i += 1)")); Assert.AreEqual(String.Empty, target.parse("$(i -= 2)")); Assert.AreEqual("2", uvar.get("i")); }
public void repeatTest2() { var uvar = new UserVariable(); var target = new Script(new StubEnv(), uvar); Assert.AreEqual("ab!ab!ab!", noSpaces(@" #[$(i = 2)]#[Box repeat($(i) < 8): $(i = $([MSBuild]::Add($(i), 2))) ab! #[Box operators.sleep(50)] ]", target)); Assert.AreEqual(1, uvar.Variables.Count()); Assert.AreEqual("8", uvar.get("i", null)); }
public void quotesTest9() { var uvar = new UserVariable(); var target = new Parser(new StubEnv(), uvar); uvar.set("lp", null, "\"s3\\dir\""); uvar.evaluate("lp", null, new EvaluatorBlank(), true); Assert.AreEqual("\"s3\\dir\"", uvar.get("lp", null)); //Assert.AreEqual("\"\"s3\\dir\"\\p1.exe\"", target.parse("\"$(lp)\\p1.exe\"")); // ? TODO: unspecified for current time Assert.AreEqual("'$(lp)\\p2.exe'", target.parse("'$(lp)\\p2.exe'")); Assert.AreEqual("\"s3\\dir\"\\p3.exe", target.parse("$(lp)\\p3.exe")); }