public void UseNamespaceTest() { CodeGeneratorWrapper testCodeGeneratorWrapper = new CodeGeneratorWrapper(); Assert.AreNotEqual("OK", testCodeGeneratorWrapper.CheckCode("MessageBox.Show(\"Test!\");")); testCodeGeneratorWrapper.UseNamespace("System.Windows.Forms", "System.Windows.Forms.dll"); Assert.AreEqual("OK", testCodeGeneratorWrapper.CheckCode("MessageBox.Show(\"Test!\");")); }
public void PrepareCodeForCancelationAbilityWhileTest() { CodeGeneratorWrapper testCodeGeneratorWrapper = new CodeGeneratorWrapper(); string codeSource = "int x = 0;while\t \t(x<100)\r\n{x++;Thread.Sleep(500);}\twhile\r\n(x<100)\r\n{x++;Thread.Sleep(500);}"; string codeExpected = " int x = 0;while\t \t((!__codeGeneratorWrapper_CancellationToken.IsCancellationRequested)&&x<100)\r\n{x++;Thread.Sleep(500);}\twhile\r\n((!__codeGeneratorWrapper_CancellationToken.IsCancellationRequested)&&x<100)\r\n{x++;Thread.Sleep(500);}"; string codeModified = testCodeGeneratorWrapper.PrepareCodeForCancelationAbility(codeSource); Assert.AreEqual(codeExpected, codeModified); Assert.AreEqual("OK", testCodeGeneratorWrapper.CheckCode(codeModified)); }
public void PrepareCodeForCancelationAbilityEmptyForTest() { CodeGeneratorWrapper testCodeGeneratorWrapper = new CodeGeneratorWrapper(); string codeSource = "for(;;){Thread.Sleep(500);}"; string codeExpected = " for(;(!__codeGeneratorWrapper_CancellationToken.IsCancellationRequested);){Thread.Sleep(500);}"; string codeModified = testCodeGeneratorWrapper.PrepareCodeForCancelationAbility(codeSource); Assert.AreEqual(codeExpected, codeModified); Assert.AreEqual("OK", testCodeGeneratorWrapper.CheckCode(codeModified)); }