public void SetUpFixture() { resourceWriter = new MockResourceWriter(); resourceService = new MockResourceService(); resourceService.SetResourceWriter(resourceWriter); AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor(); document = textEditor.Document; textEditor.Text = GetTextEditorCode(); PythonParser parser = new PythonParser(); ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.Text); 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()) { AvalonEditDocumentAdapter adapter = new AvalonEditDocumentAdapter(document, null); MockTextEditorOptions options = new MockTextEditorOptions(); PythonDesignerGenerator generator = new PythonDesignerGenerator(options); generator.Merge(host, adapter, compilationUnit, serializationManager); } } }
void CreateResourceService() { fakeReader = new MockResourceReader(); fakeWriter = new MockResourceWriter(); resourceService = new MockResourceService(); resourceService.SetResourceReader(fakeReader); resourceService.SetResourceWriter(fakeWriter); }