public void GetInitializeComponentWhenNoClassesInCompilationUnit() { ParseInformation parseInfo = new ParseInformation(); parseInfo.SetCompilationUnit(new DefaultCompilationUnit(new MockProjectContent())); Assert.IsNull(PythonDesignerGenerator.GetInitializeComponents(parseInfo)); }
public void SetUpFixture() { PythonParser parser = new PythonParser(); MockProjectContent mockProjectContent = new MockProjectContent(); ICompilationUnit compilationUnit = parser.Parse(mockProjectContent, @"C:\Projects\Test\MainForm.py", GetFormCode()); // Create parse info to return from ParseFile method. parseInfo = new ParseInformation(); // Set the DirtyCompilationUnit to a non-null compilation unit // but with no items in the project content to ensure // that the BestCompilationUnit is used by the generator. parseInfo.SetCompilationUnit(compilationUnit); parseInfo.SetCompilationUnit(new DefaultCompilationUnit(new MockProjectContent()) { ErrorsDuringCompile = true }); // Get the InitializeComponent method from the // compilation unit. expectedInitializeComponentMethod = GetInitializeComponentMethod(compilationUnit); // Find the InitializeComponent method using the designer generator. initializeComponentMethod = PythonDesignerGenerator.GetInitializeComponents(parseInfo); }
public void InitializeComponentsUsedInsteadOfInitializeComponent() { PythonParser parser = new PythonParser(); MockProjectContent mockProjectContent = new MockProjectContent(); string code = GetFormCode().Replace("InitializeComponent", "InitializeComponents"); ICompilationUnit compilationUnit = parser.Parse(mockProjectContent, @"C:\Projects\Test\MainForm.py", code); ParseInformation parseInfo = new ParseInformation(compilationUnit); IMethod expectedMethod = GetInitializeComponentMethod(compilationUnit); IMethod method = PythonDesignerGenerator.GetInitializeComponents(parseInfo); Assert.IsNotNull(method); Assert.AreSame(expectedMethod, method); }
public void SetUpFixture() { PythonParser parser = new PythonParser(); MockProjectContent mockProjectContent = new MockProjectContent(); ICompilationUnit compilationUnit = parser.Parse(mockProjectContent, @"C:\Projects\Test\MainForm.py", GetFormCode()); // Create parse info to return from ParseFile method. parseInfo = new ParseInformation(compilationUnit); // Get the InitializeComponent method from the // compilation unit. expectedInitializeComponentMethod = GetInitializeComponentMethod(compilationUnit); // Find the InitializeComponent method using the designer generator. initializeComponentMethod = PythonDesignerGenerator.GetInitializeComponents(parseInfo); }