public async Task ProgramInterpreterInvokeExternMethod3() { var parser = new BaZicParser(); var inputCode = @"EXTERN FUNCTION Main(args[]) AWAIT MethodAsync(345, 5.0) END FUNCTION EXTERN FUNCTION Method1(arg) RETURN arg END FUNCTION ASYNC FUNCTION MethodAsync(value, timeToWait) VARIABLE var1 = AWAIT System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(timeToWait)) RETURN value END FUNCTION"; using (var interpreter = new BaZicInterpreter(parser.Parse(inputCode, false).Program)) { var t = interpreter.StartDebugAsync(true); var result = await interpreter.InvokeMethod(true, "Method1", true, 123); Assert.AreEqual(123, result); // Idle is expected because InvokeMethod waits that the main // thread (used by Main()) is free before running. So the async // function is complete before reaching this assert. Assert.AreEqual(BaZicInterpreterState.Idle, interpreter.State); await interpreter.Stop(); Assert.AreEqual(BaZicInterpreterState.Stopped, interpreter.State); } }
public async Task ProgramInterpreterInvokeExternMethod7() { var parser = new BaZicParser(); var inputCode = @"EXTERN FUNCTION Main(args[]) END FUNCTION EXTERN ASYNC FUNCTION Method1(arg) VARIABLE var1 = AWAIT System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(3.0)) RETURN arg END FUNCTION"; using (var interpreter = new BaZicInterpreter(parser.Parse(inputCode, false).Program)) { var errors = await interpreter.Build(); Assert.IsNull(errors); var t = interpreter.StartReleaseAsync(true); var result = (Task)interpreter.InvokeMethod(true, "Method1", true, 123); Assert.AreEqual(TaskStatus.WaitingForActivation, result.Status); await Task.Delay(5000); Assert.AreEqual(TaskStatus.RanToCompletion, result.Status); Assert.AreEqual(123, ((dynamic)result).Result); Assert.AreEqual(BaZicInterpreterState.Idle, interpreter.State); await interpreter.Stop(); Assert.AreEqual(BaZicInterpreterState.Stopped, interpreter.State); } }
public async Task ProgramInterpreterInvokeExternMethodUI12() { var parser = new BaZicParser(); var inputCode = @" VARIABLE globVar = 1 EXTERN FUNCTION Main(args[]) END FUNCTION EXTERN FUNCTION Method1() DO WHILE TRUE LOOP END FUNCTION"; var xamlCode = @" <Window xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Name=""Window1""> <StackPanel> <Button Name=""Button1"" Content=""Hello""/> </StackPanel> </Window>"; using (var interpreter = new BaZicInterpreter(inputCode, xamlCode)) { var t = interpreter.StartDebugAsync(true); t = interpreter.InvokeMethod(true, "Method1", true); await Task.Delay(3000); Assert.AreEqual(BaZicInterpreterState.Running, interpreter.State); await interpreter.Stop(); Assert.AreEqual(BaZicInterpreterState.Stopped, interpreter.State); } using (var interpreter = new BaZicInterpreter(inputCode, xamlCode)) { var errors = await interpreter.Build(); Assert.IsNull(errors); var t = interpreter.StartReleaseAsync(true); t = interpreter.InvokeMethod(true, "Method1", true); await Task.Delay(10000); Assert.AreEqual(BaZicInterpreterState.Running, interpreter.State); await interpreter.Stop(); Assert.AreEqual(BaZicInterpreterState.Stopped, interpreter.State); } }
public async Task ProgramInterpreterInvokeExternMethod11() { var parser = new BaZicParser(); var inputCode = @" VARIABLE globVar = 1 EXTERN FUNCTION Main(args[]) DO WHILE TRUE LOOP END FUNCTION EXTERN FUNCTION Method1() RETURN TRUE END FUNCTION"; using (var interpreter = new BaZicInterpreter(parser.Parse(inputCode, false).Program)) { var t = interpreter.StartDebugAsync(true); t = interpreter.InvokeMethod(true, "Method1", true); await Task.Delay(3000); Assert.AreEqual(BaZicInterpreterState.Running, interpreter.State); await interpreter.Stop(); Assert.AreEqual(BaZicInterpreterState.Stopped, interpreter.State); } using (var interpreter = new BaZicInterpreter(parser.Parse(inputCode, false).Program)) { var t = interpreter.StartReleaseAsync(true); t = interpreter.InvokeMethod(true, "Method1", true); await Task.Delay(10000); Assert.AreEqual(BaZicInterpreterState.Running, interpreter.State); await interpreter.Stop(); Assert.AreEqual(BaZicInterpreterState.Stopped, interpreter.State); } }
public async Task IterationInterpreterInfiniteLoop() { var parser = new BaZicParser(); var inputCode = @"EXTERN FUNCTION Main(args[]) VARIABLE file = NEW System.IO.FileStream(""LocalWebPage.html"", System.IO.FileMode.OpenOrCreate) DO LOOP WHILE True RETURN 1 END FUNCTION"; var interpreter = new BaZicInterpreter(parser.Parse(inputCode, false).Program); var t = interpreter.StartDebugAsync(true); await Task.Delay(3000); try { File.ReadAllText("LocalWebPage.html"); // Must crash. Assert.Fail(); } catch (IOException) { } catch { Assert.Fail(); } await interpreter.Stop(); var fileContent = File.ReadAllText("LocalWebPage.html"); Assert.IsTrue(interpreter.GetStateChangedHistoryString().Contains("[Log] The user requests to stop the interpreter as soon as possible.")); Assert.IsTrue(interpreter.State == BaZicInterpreterState.Stopped); Assert.IsFalse(string.IsNullOrWhiteSpace(fileContent)); }
public async Task IterationInterpreterInfiniteLoopReleaseMode() { var parser = new BaZicParser(); var inputCode = @"EXTERN FUNCTION Main(args[]) VARIABLE file = NEW System.IO.FileStream(""LocalWebPage.html"", System.IO.FileMode.OpenOrCreate) DO # The file LocalWebPage.html must be protected in write as it's a busy resource. LOOP WHILE True RETURN 1 END FUNCTION"; var interpreter = new BaZicInterpreter(parser.Parse(inputCode, false).Program); var t = interpreter.StartReleaseAsync(true); await Task.Delay(10000); try { File.ReadAllText("LocalWebPage.html"); // Must crash. Assert.Fail(); } catch (IOException) { } catch { Assert.Fail(); } await interpreter.Stop(); var fileContent = File.ReadAllText("LocalWebPage.html"); Assert.IsTrue(interpreter.State == BaZicInterpreterState.Stopped); Assert.IsFalse(string.IsNullOrWhiteSpace(fileContent)); }
private async void StopButton_Click(object sender, RoutedEventArgs e) { await _interpreter.Stop(); }
public async Task BaZicInterpreterStepInto() { var parser = new BaZicParser(); var inputCode = @"EXTERN FUNCTION Main(args[]) VARIABLE var1 = 0 BREAKPOINT var1 = 1 var1 = 2 var1 = 3 RETURN var1 END FUNCTION"; var interpreter = new BaZicInterpreter(parser.Parse(inputCode, false).Program); var t = interpreter.StartDebugAsync(true); await Task.Delay(3000); var expectedLogs = @"[State] Ready [State] Preparing [Log] Reference assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Declaring global variables. [Log] Program's entry point detected. [State] Running [Log] Preparing to invoke the method 'Main'. [Log] Executing the argument values of the method. [Log] Executing an expression of type 'ArrayCreationExpression'. [Log] The expression returned the value 'BaZicProgramReleaseMode.ObservableDictionary' (BaZicProgramReleaseMode.ObservableDictionary (length: 0)). [Log] Invoking the synchronous method 'Main'. [Log] Variable 'args' declared. Default value : {Null} [Log] Variable 'args' value set to : BaZicProgramReleaseMode.ObservableDictionary (BaZicProgramReleaseMode.ObservableDictionary (length: 0)) [Log] Registering labels. [Log] Executing a statement of type 'VariableDeclaration'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '0' (System.Int32). [Log] Variable 'var1' declared. Default value : 0 (System.Int32) [Log] Executing a statement of type 'BreakpointStatement'. [Log] A Breakpoint has been intercepted. [State] Pause "; Assert.AreEqual(expectedLogs, interpreter.GetStateChangedHistoryString()); Assert.AreEqual(BaZicInterpreterState.Pause, interpreter.State); interpreter.NextStep(); await Task.Delay(1000); Assert.AreEqual(BaZicInterpreterState.Pause, interpreter.State); interpreter.NextStep(); await Task.Delay(1000); expectedLogs = @"[State] Ready [State] Preparing [Log] Reference assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Declaring global variables. [Log] Program's entry point detected. [State] Running [Log] Preparing to invoke the method 'Main'. [Log] Executing the argument values of the method. [Log] Executing an expression of type 'ArrayCreationExpression'. [Log] The expression returned the value 'BaZicProgramReleaseMode.ObservableDictionary' (BaZicProgramReleaseMode.ObservableDictionary (length: 0)). [Log] Invoking the synchronous method 'Main'. [Log] Variable 'args' declared. Default value : {Null} [Log] Variable 'args' value set to : BaZicProgramReleaseMode.ObservableDictionary (BaZicProgramReleaseMode.ObservableDictionary (length: 0)) [Log] Registering labels. [Log] Executing a statement of type 'VariableDeclaration'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '0' (System.Int32). [Log] Variable 'var1' declared. Default value : 0 (System.Int32) [Log] Executing a statement of type 'BreakpointStatement'. [Log] A Breakpoint has been intercepted. [State] Pause [State] Running [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to ''1' (type:System.Int32)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '1' (System.Int32). [Log] Variable 'var1' value set to : 1 (System.Int32) [Log] 'var1' is now equal to '1'(type:System.Int32) [State] Pause [State] Running [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to ''2' (type:System.Int32)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '2' (System.Int32). [Log] Variable 'var1' value set to : 2 (System.Int32) [Log] 'var1' is now equal to '2'(type:System.Int32) [State] Pause "; Assert.AreEqual(expectedLogs, interpreter.GetStateChangedHistoryString()); Assert.AreEqual(BaZicInterpreterState.Pause, interpreter.State); await interpreter.Stop(); await Task.Delay(1000); expectedLogs = @"[State] Ready [State] Preparing [Log] Reference assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Declaring global variables. [Log] Program's entry point detected. [State] Running [Log] Preparing to invoke the method 'Main'. [Log] Executing the argument values of the method. [Log] Executing an expression of type 'ArrayCreationExpression'. [Log] The expression returned the value 'BaZicProgramReleaseMode.ObservableDictionary' (BaZicProgramReleaseMode.ObservableDictionary (length: 0)). [Log] Invoking the synchronous method 'Main'. [Log] Variable 'args' declared. Default value : {Null} [Log] Variable 'args' value set to : BaZicProgramReleaseMode.ObservableDictionary (BaZicProgramReleaseMode.ObservableDictionary (length: 0)) [Log] Registering labels. [Log] Executing a statement of type 'VariableDeclaration'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '0' (System.Int32). [Log] Variable 'var1' declared. Default value : 0 (System.Int32) [Log] Executing a statement of type 'BreakpointStatement'. [Log] A Breakpoint has been intercepted. [State] Pause [State] Running [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to ''1' (type:System.Int32)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '1' (System.Int32). [Log] Variable 'var1' value set to : 1 (System.Int32) [Log] 'var1' is now equal to '1'(type:System.Int32) [State] Pause [State] Running [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to ''2' (type:System.Int32)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '2' (System.Int32). [Log] Variable 'var1' value set to : 2 (System.Int32) [Log] 'var1' is now equal to '2'(type:System.Int32) [State] Pause [Log] The user requests to stop the interpreter as soon as possible. [State] Stopped "; Assert.AreEqual(expectedLogs, interpreter.GetStateChangedHistoryString()); Assert.AreEqual(BaZicInterpreterState.Stopped, interpreter.State); }
public async Task BaZicInterpreterWithUiProgram() { var parser = new BaZicParser(); var inputCode = @" EXTERN FUNCTION Main(args[]) END FUNCTION EVENT FUNCTION Window1_Closed() RETURN ""Result of Window.Close"" END FUNCTION EVENT FUNCTION Window1_Loaded() VARIABLE var1 = Button1.Content IF var1 = ""Hello"" THEN Button1.Content = ""Hello World"" var1 = Button1.Content IF var1 = ""Hello World"" THEN RETURN TRUE END IF END IF END FUNCTION # The XAML will be provided separatly"; var xamlCode = @" <Window xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Name=""Window1"" Opacity=""0""> <StackPanel> <Button Name=""Button1"" Content=""Hello""/> </StackPanel> </Window>"; var bazicProgram = (BaZicUiProgram)parser.Parse(inputCode, xamlCode, optimize: true).Program; var interpreter = new BaZicInterpreter(bazicProgram); var t = interpreter.StartDebugAsync(true); await Task.Delay(5000); await interpreter.Stop(); var expect = @"[State] Ready [State] Preparing [Log] Reference assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Declaring global variables. [Log] Program's entry point detected. [State] Running [Log] Preparing to invoke the method 'Main'. [Log] Executing the argument values of the method. [Log] Executing an expression of type 'ArrayCreationExpression'. [Log] The expression returned the value 'BaZicProgramReleaseMode.ObservableDictionary' (BaZicProgramReleaseMode.ObservableDictionary (length: 0)). [Log] Invoking the synchronous method 'Main'. [Log] Variable 'args' declared. Default value : {Null} [Log] Variable 'args' value set to : BaZicProgramReleaseMode.ObservableDictionary (BaZicProgramReleaseMode.ObservableDictionary (length: 0)) [Log] Registering labels. [Log] End of the execution of the method 'Main'. Returned value : ({Null}) [Log] Loading user interface. [Log] Registering events. [Log] Declaring control accessors. [Log] Variable 'Window1' declared. Default value : System.Windows.Window (Window1 : System.Windows.Window) [Log] Variable 'Button1' declared. Default value : System.Windows.Controls.Button: Hello (Button1 : System.Windows.Controls.Button) [Log] Showing user interface. [State] Idle [Log] An event has been raised from an interaction with the user interface. [State] Running [Log] Preparing to invoke the method 'Window1_Loaded'. [Log] Executing the argument values of the method. [Log] Invoking the synchronous method 'Window1_Loaded'. [Log] Registering labels. [Log] Executing a statement of type 'VariableDeclaration'. [Log] Executing an expression of type 'PropertyReferenceExpression'. [Log] Getting the property 'Button1.Content'. [Log] Executing an expression of type 'VariableReferenceExpression'. [Log] The expression returned the value 'System.Windows.Controls.Button: Hello' (System.Windows.Controls.Button). [Log] The expression returned the value 'Hello' (System.String). [Log] Variable 'var1' declared. Default value : Hello (System.String) [Log] Executing a statement of type 'LabelConditionStatement'. [Log] Executing an expression of type 'NotOperatorExpression'. [Log] Executing an expression of type 'BinaryOperatorExpression'. [Log] Executing an expression of type 'VariableReferenceExpression'. [Log] The expression returned the value 'Hello' (System.String). [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value 'Hello' (System.String). [Log] Doing an operation 'Equality'. [Log] The expression returned the value 'True' (System.Boolean). [Log] The expression returned the value 'False' (System.Boolean). [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'Button1.Content' to ''Hello World' (type:System.String)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value 'Hello World' (System.String). [Log] Executing an expression of type 'VariableReferenceExpression'. [Log] The expression returned the value 'System.Windows.Controls.Button: Hello' (System.Windows.Controls.Button). [Log] 'Button1.Content' is now equal to 'Hello World'(type:System.String) [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to 'Button1.Content'. [Log] Executing an expression of type 'PropertyReferenceExpression'. [Log] Getting the property 'Button1.Content'. [Log] Executing an expression of type 'VariableReferenceExpression'. [Log] The expression returned the value 'System.Windows.Controls.Button: Hello World' (System.Windows.Controls.Button). [Log] The expression returned the value 'Hello World' (System.String). [Log] Variable 'var1' value set to : Hello World (System.String) [Log] 'var1' is now equal to 'Hello World'(type:System.String) [Log] Executing a statement of type 'LabelConditionStatement'. [Log] Executing an expression of type 'NotOperatorExpression'. [Log] Executing an expression of type 'BinaryOperatorExpression'. [Log] Executing an expression of type 'VariableReferenceExpression'. [Log] The expression returned the value 'Hello World' (System.String). [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value 'Hello World' (System.String). [Log] Doing an operation 'Equality'. [Log] The expression returned the value 'True' (System.Boolean). [Log] The expression returned the value 'False' (System.Boolean). [Log] Executing a statement of type 'ReturnStatement'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value 'True' (System.Boolean). [Log] Return : True (System.Boolean) [Log] A Return statement or Break statement or Exception has been detected or thrown. Exiting the current block of statements. [Log] End of the execution of the method 'Window1_Loaded'. Returned value : True (System.Boolean) [State] Idle [Log] The user requests to stop the interpreter as soon as possible. [Log] An event has been raised from an interaction with the user interface. [State] Running [Log] Preparing to invoke the method 'Window1_Closed'. [Log] Executing the argument values of the method. [Log] Invoking the synchronous method 'Window1_Closed'. [Log] Registering labels. [Log] Executing a statement of type 'ReturnStatement'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value 'Result of Window.Close' (System.String). [Log] Return : Result of Window.Close (System.String) [Log] A Return statement or Break statement or Exception has been detected or thrown. Exiting the current block of statements. [Log] End of the execution of the method 'Window1_Closed'. Returned value : Result of Window.Close (System.String) [State] Idle [Log] Hidding/closing user interface. [State] Stopped "; Assert.AreEqual(expect, interpreter.GetStateChangedHistoryString()); Assert.AreEqual(null, interpreter.ProgramResult); // Null because the program has been forced to stop. }
public async Task BaZicInterpreterWithUiProgramResource() { var parser = new BaZicParser(); var imageFile = Path.Combine(Directory.GetParent(Assembly.GetAssembly(this.GetType()).Location).FullName, "Image.png"); var inputCode = @" EXTERN FUNCTION Main(args[]) END FUNCTION # The XAML will be provided separatly"; var xamlCode = @" <Window Title=""Window"" BorderBrush=""#FFFFFFFF"" Background=""#FFFFFFFF"" Foreground=""#FFFFFFFF"" Name=""Window1"" Width=""154"" Height=""183"" Margin=""0,0,0,0"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:b=""clr-namespace:ANamespace;assembly=AnAssembly""> <Grid Name=""Grid1""> <Grid.Background> <ImageBrush ImageSource=""{imageFile}"" Stretch=""Uniform"" /> </Grid.Background> </Grid> </Window>" .Replace("{imageFile}", $"file:///{imageFile.Replace("\\", "/")}"); var bazicProgram = (BaZicUiProgram)parser.Parse(inputCode, xamlCode, new List <string> { imageFile }, optimize: true).Program; Assert.AreEqual(1, bazicProgram.ResourceFilePaths.Count); var interpreter = new BaZicInterpreter(bazicProgram); var t = interpreter.StartDebugAsync(true); await Task.Delay(5000); await interpreter.Stop(); Assert.AreEqual(null, interpreter.ProgramResult); using (interpreter = new BaZicInterpreter(inputCode, xamlCode, new List <string> { imageFile }, optimize: false)) { var tempFile = Path.Combine(Path.GetTempPath(), "BaZic_Bin", Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + ".exe"); var errors = await interpreter.Build(Core.Enums.BaZicCompilerOutputType.WindowsApp, tempFile); Assert.IsNull(errors); Assert.IsTrue(File.Exists(tempFile)); Assert.IsTrue(File.Exists(tempFile.Replace(".exe", ".pdb"))); File.Delete(tempFile); File.Delete(tempFile.Replace(".exe", ".pdb")); Directory.Delete(Path.Combine(Path.GetTempPath(), @"BaZic_Bin"), true); } }