public void SetUpFixture() { MockTextEditorProperties textEditorProperties = new MockTextEditorProperties(); generator = new DerivedPythonDesignerGenerator(); mockViewContent = new MockTextEditorViewContent(); viewContent = new FormsDesignerViewContent(mockViewContent, new MockOpenedFile("Test.py")); viewContent.DesignerCodeFileContent = GetTextEditorCode(); generator.Attach(viewContent); viewContentAttached = generator.GetViewContent(); ParseInformation parseInfo = new ParseInformation(); PythonParser parser = new PythonParser(); ICompilationUnit parserCompilationUnit = parser.Parse(new DefaultProjectContent(), "Test.py", GetTextEditorCode()); parseInfo.SetCompilationUnit(parserCompilationUnit); generator.ParseInfoToReturnFromParseFileMethod = parseInfo; using (DesignSurface designSurface = new DesignSurface(typeof(Form))) { IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); Form form = (Form)host.RootComponent; form.ClientSize = new Size(499, 309); PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false); namePropertyDescriptor.SetValue(form, "MainForm"); DesignerSerializationManager serializationManager = new DesignerSerializationManager(host); using (serializationManager.CreateSession()) { generator.MergeRootComponentChanges(host, serializationManager); generator.Detach(); } } }
public void ViewContentSetToNullAfterDetach() { Assert.IsNull(generator.GetViewContent()); }