29 changed files with 907 additions and 1313 deletions
@ -1,83 +0,0 @@
@@ -1,83 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the GetComponent method of the PythonDesignerLoader.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetComponentFromDesignerLoaderTestFixture |
||||
{ |
||||
PythonDesignerLoader loader; |
||||
TextBox textBox; |
||||
MockDesignerLoaderHost host; |
||||
Label label; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
host = new MockDesignerLoaderHost(); |
||||
loader = new PythonDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(host); |
||||
|
||||
textBox = (TextBox)loader.CreateComponent(typeof(TextBox), "textBox1"); |
||||
label = (Label)loader.CreateComponent(typeof(Label), "label1"); |
||||
loader.Add(label, "label1"); |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
if (textBox != null) { |
||||
textBox.Dispose(); |
||||
} |
||||
if (label != null) { |
||||
label.Dispose(); |
||||
} |
||||
if (loader != null) { |
||||
loader.Dispose(); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void LabelAddedToContainer() |
||||
{ |
||||
Assert.AreEqual(label, host.Container.Components["label1"]); |
||||
} |
||||
|
||||
[Test] |
||||
public void TextBoxIsNotAddedToContainer() |
||||
{ |
||||
Assert.IsNull(host.Container.Components["textBox1"]); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetUnknownCreatedComponent() |
||||
{ |
||||
Assert.IsNull(loader.GetComponent("unknown")); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTextBoxComponent() |
||||
{ |
||||
Assert.IsNull(loader.GetComponent("textBox1")); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetLabelComponent() |
||||
{ |
||||
Assert.AreEqual(label, loader.GetComponent("label1")); |
||||
} |
||||
} |
||||
} |
@ -1,64 +0,0 @@
@@ -1,64 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the GetInstance method of the PythonDesignerLoader.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetInstanceFromDesignerLoaderTestFixture |
||||
{ |
||||
PythonDesignerLoader loader; |
||||
MockDesignerLoaderHost host; |
||||
ListViewItem listViewItem1; |
||||
object instance; |
||||
Type type; |
||||
string typeName; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
host = new MockDesignerLoaderHost(); |
||||
loader = new PythonDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(host); |
||||
|
||||
DesignerSerializationManager designerSerializationManager = (DesignerSerializationManager)host.GetService(typeof(IDesignerSerializationManager)); |
||||
using (designerSerializationManager.CreateSession()) { |
||||
listViewItem1 = (ListViewItem)loader.CreateInstance(typeof(ListViewItem), new object[0], "listViewItem1", false); |
||||
instance = loader.GetInstance("listViewItem1"); |
||||
typeName = typeof(Int32).FullName; |
||||
type = loader.GetType(typeName); |
||||
} |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void GetListViewInstance() |
||||
{ |
||||
Assert.AreEqual(listViewItem1, instance); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTypeFromLoader() |
||||
{ |
||||
Assert.AreEqual(typeof(Int32), type); |
||||
} |
||||
|
||||
[Test] |
||||
public void TypeNameUsed() |
||||
{ |
||||
Assert.AreEqual(typeName, host.TypeResolutionService.LastTypeNameResolved); |
||||
} |
||||
} |
||||
} |
@ -1,90 +0,0 @@
@@ -1,90 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Globalization; |
||||
using System.Resources; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the GetResourceReader method of the PythonDesignerLoader.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetResourcesFromDesignerLoaderTestFixture |
||||
{ |
||||
PythonDesignerLoader loader; |
||||
MockDesignerLoaderHost host; |
||||
MockResourceReader reader; |
||||
MockResourceService resourceService; |
||||
MockResourceReader dummyReader; |
||||
MockResourceWriter dummyWriter; |
||||
MockResourceWriter writer; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
dummyReader = new MockResourceReader(); |
||||
dummyWriter = new MockResourceWriter(); |
||||
resourceService = new MockResourceService(); |
||||
resourceService.SetResourceReader(dummyReader); |
||||
resourceService.SetResourceWriter(dummyWriter); |
||||
host = new MockDesignerLoaderHost(); |
||||
host.AddService(typeof(IResourceService), resourceService); |
||||
loader = new PythonDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(host); |
||||
|
||||
reader = loader.GetResourceReader(CultureInfo.InvariantCulture) as MockResourceReader; |
||||
writer = loader.GetResourceWriter(CultureInfo.InvariantCulture) as MockResourceWriter; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResourceReaderInstance() |
||||
{ |
||||
Assert.IsTrue(Object.ReferenceEquals(dummyReader, reader)); |
||||
} |
||||
|
||||
[Test] |
||||
public void CultureInfoPassedToResourceServiceForReader() |
||||
{ |
||||
Assert.AreEqual(CultureInfo.InvariantCulture, resourceService.ResourceReaderCultureInfo); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetReaderWhenNoResourceService() |
||||
{ |
||||
PythonDesignerLoader loader = new PythonDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(new MockDesignerLoaderHost()); |
||||
Assert.IsNull(loader.GetResourceReader(CultureInfo.InvariantCulture)); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetWriterWhenNoResourceService() |
||||
{ |
||||
PythonDesignerLoader loader = new PythonDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(new MockDesignerLoaderHost()); |
||||
Assert.IsNull(loader.GetResourceWriter(CultureInfo.InvariantCulture)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResourceWriterInstance() |
||||
{ |
||||
Assert.IsTrue(Object.ReferenceEquals(dummyWriter, writer)); |
||||
} |
||||
|
||||
[Test] |
||||
public void CultureInfoPassedToResourceServiceForWriter() |
||||
{ |
||||
Assert.AreEqual(CultureInfo.InvariantCulture, resourceService.ResourceWriterCultureInfo); |
||||
} |
||||
} |
||||
} |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the PythonDesignerLoader throws an exception
|
||||
/// when created with a null IDesignerGenerator.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class NullGeneratorPassedToLoader |
||||
{ |
||||
[Test] |
||||
public void ThrowsException() |
||||
{ |
||||
try { |
||||
PythonDesignerLoader loader = new PythonDesignerLoader(null); |
||||
Assert.Fail("Expected an argument exception before this line."); |
||||
} catch (ArgumentException ex) { |
||||
Assert.AreEqual("generator", ex.ParamName); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,177 +0,0 @@
@@ -1,177 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.FormsDesigner.Services; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests basic operation of the PythonDesignerLoader.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class PythonDesignerLoaderTestFixture |
||||
{ |
||||
FormsDesignerViewContent view; |
||||
DerivedPythonDesignerLoader loader; |
||||
MockDesignerGenerator generator; |
||||
MockTypeResolutionService mockTypeResolutionService; |
||||
MockDesignerLoaderHost mockDesignerLoaderHost; |
||||
MockExtenderProviderService mockExtenderProviderService; |
||||
IComponent rootComponent; |
||||
Form designedForm; |
||||
MockEventBindingService mockEventBindingService; |
||||
MockResourceService mockResourceService; |
||||
DesignerSerializationManager serializationManager; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
generator = new MockDesignerGenerator(); |
||||
view = new FormsDesignerViewContent(new MockViewContent(), new MockOpenedFile("Test.py")); |
||||
generator.Attach(view); |
||||
|
||||
view.DesignerCodeFileContent = GetFormCode(); |
||||
loader = new DerivedPythonDesignerLoader(generator); |
||||
|
||||
// Begin load.
|
||||
mockDesignerLoaderHost = new MockDesignerLoaderHost(); |
||||
mockResourceService = new MockResourceService(); |
||||
mockDesignerLoaderHost.AddService(typeof(IResourceService), mockResourceService); |
||||
|
||||
mockTypeResolutionService = mockDesignerLoaderHost.TypeResolutionService; |
||||
|
||||
mockExtenderProviderService = new MockExtenderProviderService(); |
||||
mockDesignerLoaderHost.AddService(typeof(IExtenderProviderService), mockExtenderProviderService); |
||||
mockDesignerLoaderHost.AddService(typeof(ProjectResourceService), new ProjectResourceService(new MockProjectContent())); |
||||
|
||||
mockEventBindingService = new MockEventBindingService(); |
||||
mockDesignerLoaderHost.AddService(typeof(IEventBindingService), mockEventBindingService); |
||||
|
||||
serializationManager = new DesignerSerializationManager(mockDesignerLoaderHost); |
||||
|
||||
loader.BeginLoad(mockDesignerLoaderHost); |
||||
rootComponent = mockDesignerLoaderHost.RootComponent; |
||||
|
||||
designedForm = new Form(); |
||||
designedForm.Name = "NewMainForm"; |
||||
mockDesignerLoaderHost.RootComponent = designedForm; |
||||
loader.CallPerformFlush(serializationManager); |
||||
} |
||||
|
||||
[TestFixtureTearDown] |
||||
public void TearDownFixture() |
||||
{ |
||||
loader.Dispose(); |
||||
designedForm.Dispose(); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsDerivedFromBasicDesignerLoader() |
||||
{ |
||||
BasicDesignerLoader basicLoader = loader as BasicDesignerLoader; |
||||
Assert.IsNotNull(basicLoader); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateComponent() |
||||
{ |
||||
List<CreatedComponent> expectedCreatedComponents = new List<CreatedComponent>(); |
||||
expectedCreatedComponents.Add(new CreatedComponent(typeof(Form).FullName, "MainForm", null)); |
||||
|
||||
Assert.AreEqual(expectedCreatedComponents, mockDesignerLoaderHost.CreatedComponents); |
||||
} |
||||
|
||||
[Test] |
||||
public void ComponentSerializationServiceCreated() |
||||
{ |
||||
CodeDomComponentSerializationService service = mockDesignerLoaderHost.GetService(typeof(ComponentSerializationService)) as CodeDomComponentSerializationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
[Test] |
||||
public void NameCreationServiceCreated() |
||||
{ |
||||
ScriptingNameCreationService service = mockDesignerLoaderHost.GetService(typeof(INameCreationService)) as ScriptingNameCreationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
[Test] |
||||
public void DesignerSerializationServiceCreated() |
||||
{ |
||||
DesignerSerializationService service = mockDesignerLoaderHost.GetService(typeof(IDesignerSerializationService)) as DesignerSerializationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProjectResourceServiceDesignerDoesNotSupportProjectResources() |
||||
{ |
||||
ProjectResourceService service = mockDesignerLoaderHost.GetService(typeof(ProjectResourceService)) as ProjectResourceService; |
||||
Assert.IsFalse(service.DesignerSupportsProjectResources); |
||||
} |
||||
|
||||
[Test] |
||||
public void RootDesignerComponentNameIsMainForm() |
||||
{ |
||||
Form form = rootComponent as Form; |
||||
Assert.AreEqual("MainForm", form.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void PerformFlushUsesDesignerHost() |
||||
{ |
||||
Assert.AreEqual(mockDesignerLoaderHost, generator.MergeChangesHost); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetEventPropertyUsesEventBindingService() |
||||
{ |
||||
IEventBindingService eventBindingService = (IEventBindingService)mockEventBindingService; |
||||
EventDescriptor e = TypeDescriptor.GetEvents(typeof(Form)).Find("Load", true); |
||||
PropertyDescriptor expectedProperty = eventBindingService.GetEventProperty(e); |
||||
Assert.AreEqual(expectedProperty, loader.GetEventProperty(e)); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetRootComponentFromLoader() |
||||
{ |
||||
Assert.AreEqual(designedForm, loader.RootComponent); |
||||
} |
||||
|
||||
[Test] |
||||
public void SerializationManagerPassedToMergeRootComponentMethod() |
||||
{ |
||||
Assert.IsTrue(Object.ReferenceEquals(serializationManager, generator.MergeChangesSerializationManager)); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The code that the designer loader will parse.
|
||||
/// </summary>
|
||||
string GetFormCode() |
||||
{ |
||||
return "from System.Windows.Forms import Form\r\n" + |
||||
"\r\n" + |
||||
"class MainForm(Form):\r\n" + |
||||
"\tdef __init__(self):\r\n" + |
||||
"\t\tself.InitializeComponents()\r\n" + |
||||
"\t\r\n" + |
||||
"\tdef InitializeComponents(self):\r\n" + |
||||
"\t\tself.Name = 'MainForm'\r\n"; |
||||
} |
||||
} |
||||
} |
@ -1,61 +0,0 @@
@@ -1,61 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
using System.Collections; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.IO; |
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.Scripting; |
||||
|
||||
namespace PythonBinding.Tests.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// PythonDesignerLoader derived class that provides access to
|
||||
/// various protected methods so we can use them when testing.
|
||||
/// </summary>
|
||||
public class DerivedPythonDesignerLoader : PythonDesignerLoader |
||||
{ |
||||
public DerivedPythonDesignerLoader(IScriptingDesignerGenerator generator) : base(generator) |
||||
{ |
||||
} |
||||
|
||||
public void CallPerformFlush(IDesignerSerializationManager serializationManager) |
||||
{ |
||||
base.PerformFlush(serializationManager); |
||||
} |
||||
|
||||
protected override void OnEndLoad(bool successful, ICollection errors) |
||||
{ |
||||
if (errors != null) { |
||||
foreach (object o in errors) { |
||||
Exception ex = o as Exception; |
||||
if (ex != null) { |
||||
System.Console.WriteLine("DesignerLoader.OnEndLoad: Exception: " + ex.ToString()); |
||||
} |
||||
} |
||||
} |
||||
base.OnEndLoad(successful, errors); |
||||
} |
||||
|
||||
protected override void OnBeginLoad() |
||||
{ |
||||
base.OnBeginLoad(); |
||||
} |
||||
|
||||
protected override void Initialize() |
||||
{ |
||||
base.Initialize(); |
||||
} |
||||
|
||||
protected override void PerformLoad(IDesignerSerializationManager manager) |
||||
{ |
||||
base.PerformLoad(manager); |
||||
} |
||||
} |
||||
} |
@ -1,83 +0,0 @@
@@ -1,83 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the GetComponent method of the RubyDesignerLoader.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetComponentFromDesignerLoaderTestFixture |
||||
{ |
||||
RubyDesignerLoader loader; |
||||
TextBox textBox; |
||||
MockDesignerLoaderHost host; |
||||
Label label; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
host = new MockDesignerLoaderHost(); |
||||
loader = new RubyDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(host); |
||||
|
||||
textBox = (TextBox)loader.CreateComponent(typeof(TextBox), "textBox1"); |
||||
label = (Label)loader.CreateComponent(typeof(Label), "label1"); |
||||
loader.Add(label, "label1"); |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
if (textBox != null) { |
||||
textBox.Dispose(); |
||||
} |
||||
if (label != null) { |
||||
label.Dispose(); |
||||
} |
||||
if (loader != null) { |
||||
loader.Dispose(); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void LabelAddedToContainer() |
||||
{ |
||||
Assert.AreEqual(label, host.Container.Components["label1"]); |
||||
} |
||||
|
||||
[Test] |
||||
public void TextBoxIsNotAddedToContainer() |
||||
{ |
||||
Assert.IsNull(host.Container.Components["textBox1"]); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetUnknownCreatedComponent() |
||||
{ |
||||
Assert.IsNull(loader.GetComponent("unknown")); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTextBoxComponent() |
||||
{ |
||||
Assert.IsNull(loader.GetComponent("textBox1")); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetLabelComponent() |
||||
{ |
||||
Assert.AreEqual(label, loader.GetComponent("label1")); |
||||
} |
||||
} |
||||
} |
@ -1,63 +0,0 @@
@@ -1,63 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the GetInstance method of the RubyDesignerLoader.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetInstanceFromDesignerLoaderTestFixture |
||||
{ |
||||
RubyDesignerLoader loader; |
||||
MockDesignerLoaderHost host; |
||||
ListViewItem listViewItem1; |
||||
object instance; |
||||
Type type; |
||||
string typeName; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
host = new MockDesignerLoaderHost(); |
||||
loader = new RubyDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(host); |
||||
|
||||
DesignerSerializationManager designerSerializationManager = (DesignerSerializationManager)host.GetService(typeof(IDesignerSerializationManager)); |
||||
using (designerSerializationManager.CreateSession()) { |
||||
listViewItem1 = (ListViewItem)loader.CreateInstance(typeof(ListViewItem), new object[0], "listViewItem1", false); |
||||
instance = loader.GetInstance("listViewItem1"); |
||||
typeName = typeof(Int32).FullName; |
||||
type = loader.GetType(typeName); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void GetListViewInstance() |
||||
{ |
||||
Assert.AreEqual(listViewItem1, instance); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTypeFromLoader() |
||||
{ |
||||
Assert.AreEqual(typeof(Int32), type); |
||||
} |
||||
|
||||
[Test] |
||||
public void TypeNameUsed() |
||||
{ |
||||
Assert.AreEqual(typeName, host.TypeResolutionService.LastTypeNameResolved); |
||||
} |
||||
} |
||||
} |
@ -1,90 +0,0 @@
@@ -1,90 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Globalization; |
||||
using System.Resources; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the GetResourceReader method of the RubyDesignerLoader.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetResourcesFromDesignerLoaderTestFixture |
||||
{ |
||||
RubyDesignerLoader loader; |
||||
MockDesignerLoaderHost host; |
||||
MockResourceReader reader; |
||||
MockResourceService resourceService; |
||||
MockResourceReader dummyReader; |
||||
MockResourceWriter dummyWriter; |
||||
MockResourceWriter writer; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
dummyReader = new MockResourceReader(); |
||||
dummyWriter = new MockResourceWriter(); |
||||
resourceService = new MockResourceService(); |
||||
resourceService.SetResourceReader(dummyReader); |
||||
resourceService.SetResourceWriter(dummyWriter); |
||||
host = new MockDesignerLoaderHost(); |
||||
host.AddService(typeof(IResourceService), resourceService); |
||||
loader = new RubyDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(host); |
||||
|
||||
reader = loader.GetResourceReader(CultureInfo.InvariantCulture) as MockResourceReader; |
||||
writer = loader.GetResourceWriter(CultureInfo.InvariantCulture) as MockResourceWriter; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResourceReaderInstance() |
||||
{ |
||||
Assert.IsTrue(Object.ReferenceEquals(dummyReader, reader)); |
||||
} |
||||
|
||||
[Test] |
||||
public void CultureInfoPassedToResourceServiceForReader() |
||||
{ |
||||
Assert.AreEqual(CultureInfo.InvariantCulture, resourceService.ResourceReaderCultureInfo); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetReaderWhenNoResourceService() |
||||
{ |
||||
RubyDesignerLoader loader = new RubyDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(new MockDesignerLoaderHost()); |
||||
Assert.IsNull(loader.GetResourceReader(CultureInfo.InvariantCulture)); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetWriterWhenNoResourceService() |
||||
{ |
||||
RubyDesignerLoader loader = new RubyDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(new MockDesignerLoaderHost()); |
||||
Assert.IsNull(loader.GetResourceWriter(CultureInfo.InvariantCulture)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResourceWriterInstance() |
||||
{ |
||||
Assert.IsTrue(Object.ReferenceEquals(dummyWriter, writer)); |
||||
} |
||||
|
||||
[Test] |
||||
public void CultureInfoPassedToResourceServiceForWriter() |
||||
{ |
||||
Assert.AreEqual(CultureInfo.InvariantCulture, resourceService.ResourceWriterCultureInfo); |
||||
} |
||||
} |
||||
} |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.RubyBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace RubyBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the RubyDesignerLoader throws an exception
|
||||
/// when created with a null IDesignerGenerator.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class NullGeneratorPassedToLoader |
||||
{ |
||||
[Test] |
||||
public void ThrowsException() |
||||
{ |
||||
try { |
||||
RubyDesignerLoader loader = new RubyDesignerLoader(null); |
||||
Assert.Fail("Expected an argument exception before this line."); |
||||
} catch (ArgumentException ex) { |
||||
Assert.AreEqual("generator", ex.ParamName); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,184 +0,0 @@
@@ -1,184 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.FormsDesigner.Services; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests basic operation of the RubyDesignerLoader.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class RubyDesignerLoaderTestFixture |
||||
{ |
||||
FormsDesignerViewContent view; |
||||
DerivedRubyDesignerLoader loader; |
||||
MockDesignerGenerator generator; |
||||
MockTypeResolutionService mockTypeResolutionService; |
||||
MockDesignerLoaderHost mockDesignerLoaderHost; |
||||
MockExtenderProviderService mockExtenderProviderService; |
||||
IComponent rootComponent; |
||||
Form designedForm; |
||||
MockEventBindingService mockEventBindingService; |
||||
MockResourceService mockResourceService; |
||||
DesignerSerializationManager serializationManager; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
generator = new MockDesignerGenerator(); |
||||
view = new FormsDesignerViewContent(new MockViewContent(), new MockOpenedFile("Test.rb")); |
||||
generator.Attach(view); |
||||
|
||||
view.DesignerCodeFileContent = GetFormCode(); |
||||
loader = new DerivedRubyDesignerLoader(generator); |
||||
|
||||
// Begin load.
|
||||
mockDesignerLoaderHost = new MockDesignerLoaderHost(); |
||||
mockResourceService = new MockResourceService(); |
||||
mockDesignerLoaderHost.AddService(typeof(IResourceService), mockResourceService); |
||||
|
||||
mockTypeResolutionService = mockDesignerLoaderHost.TypeResolutionService; |
||||
|
||||
mockExtenderProviderService = new MockExtenderProviderService(); |
||||
mockDesignerLoaderHost.AddService(typeof(IExtenderProviderService), mockExtenderProviderService); |
||||
mockDesignerLoaderHost.AddService(typeof(ProjectResourceService), new ProjectResourceService(new MockProjectContent())); |
||||
|
||||
mockEventBindingService = new MockEventBindingService(); |
||||
mockDesignerLoaderHost.AddService(typeof(IEventBindingService), mockEventBindingService); |
||||
|
||||
serializationManager = new DesignerSerializationManager(mockDesignerLoaderHost); |
||||
|
||||
System.Console.WriteLine("Before BeginLoad"); |
||||
loader.BeginLoad(mockDesignerLoaderHost); |
||||
System.Console.WriteLine("After BeginLoad"); |
||||
rootComponent = mockDesignerLoaderHost.RootComponent; |
||||
|
||||
designedForm = new Form(); |
||||
designedForm.Name = "NewMainForm"; |
||||
mockDesignerLoaderHost.RootComponent = designedForm; |
||||
loader.CallPerformFlush(serializationManager); |
||||
} |
||||
|
||||
[TestFixtureTearDown] |
||||
public void TearDownFixture() |
||||
{ |
||||
loader.Dispose(); |
||||
designedForm.Dispose(); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsDerivedFromBasicDesignerLoader() |
||||
{ |
||||
BasicDesignerLoader basicLoader = loader as BasicDesignerLoader; |
||||
Assert.IsNotNull(basicLoader); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateComponent() |
||||
{ |
||||
List<CreatedComponent> expectedCreatedComponents = new List<CreatedComponent>(); |
||||
expectedCreatedComponents.Add(new CreatedComponent(typeof(Form).FullName, "MainForm", null)); |
||||
|
||||
Assert.AreEqual(expectedCreatedComponents, mockDesignerLoaderHost.CreatedComponents); |
||||
} |
||||
|
||||
[Test] |
||||
public void ComponentSerializationServiceCreated() |
||||
{ |
||||
CodeDomComponentSerializationService service = mockDesignerLoaderHost.GetService(typeof(ComponentSerializationService)) as CodeDomComponentSerializationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
[Test] |
||||
public void NameCreationServiceCreated() |
||||
{ |
||||
ScriptingNameCreationService service = mockDesignerLoaderHost.GetService(typeof(INameCreationService)) as ScriptingNameCreationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
[Test] |
||||
public void DesignerSerializationServiceCreated() |
||||
{ |
||||
DesignerSerializationService service = mockDesignerLoaderHost.GetService(typeof(IDesignerSerializationService)) as DesignerSerializationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProjectResourceServiceDesignerDoesNotSupportProjectResources() |
||||
{ |
||||
ProjectResourceService service = mockDesignerLoaderHost.GetService(typeof(ProjectResourceService)) as ProjectResourceService; |
||||
Assert.IsFalse(service.DesignerSupportsProjectResources); |
||||
} |
||||
|
||||
[Test] |
||||
public void RootDesignerComponentNameIsMainForm() |
||||
{ |
||||
Form form = rootComponent as Form; |
||||
Assert.AreEqual("MainForm", form.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void PerformFlushUsesDesignerHost() |
||||
{ |
||||
Assert.AreEqual(mockDesignerLoaderHost, generator.MergeChangesHost); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetEventPropertyUsesEventBindingService() |
||||
{ |
||||
IEventBindingService eventBindingService = (IEventBindingService)mockEventBindingService; |
||||
EventDescriptor e = TypeDescriptor.GetEvents(typeof(Form)).Find("Load", true); |
||||
PropertyDescriptor expectedProperty = eventBindingService.GetEventProperty(e); |
||||
Assert.AreEqual(expectedProperty, loader.GetEventProperty(e)); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetRootComponentFromLoader() |
||||
{ |
||||
Assert.AreEqual(designedForm, loader.RootComponent); |
||||
} |
||||
|
||||
[Test] |
||||
public void SerializationManagerPassedToMergeRootComponentMethod() |
||||
{ |
||||
Assert.IsTrue(Object.ReferenceEquals(serializationManager, generator.MergeChangesSerializationManager)); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The code that the designer loader will parse.
|
||||
/// </summary>
|
||||
string GetFormCode() |
||||
{ |
||||
return "require \"mscorlib\"\r\n" + |
||||
"require \"System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\n" + |
||||
"require \"System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"\r\n" + |
||||
"\r\n" + |
||||
"class MainForm < System::Windows::Forms::Form\r\n" + |
||||
"\tdef initialize()\r\n" + |
||||
"\t\tself.InitializeComponents()\r\n" + |
||||
"\tend\r\n" + |
||||
"\t\r\n" + |
||||
"\tdef InitializeComponents()\r\n" + |
||||
"\t\tself.Name = 'MainForm'\r\n" + |
||||
"\tend\r\n" + |
||||
"end"; |
||||
} |
||||
} |
||||
} |
@ -1,66 +0,0 @@
@@ -1,66 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
using System.Collections; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.IO; |
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.Scripting; |
||||
|
||||
namespace RubyBinding.Tests.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// RubyDesignerLoader derived class that provides access to
|
||||
/// various protected methods so we can use them when testing.
|
||||
/// </summary>
|
||||
public class DerivedRubyDesignerLoader : RubyDesignerLoader |
||||
{ |
||||
public DerivedRubyDesignerLoader(IScriptingDesignerGenerator generator) : base(generator) |
||||
{ |
||||
} |
||||
|
||||
public void CallPerformFlush(IDesignerSerializationManager serializationManager) |
||||
{ |
||||
base.PerformFlush(serializationManager); |
||||
} |
||||
|
||||
protected override void OnEndLoad(bool successful, ICollection errors) |
||||
{ |
||||
System.Console.WriteLine("DesignerLoader.OnEndLoad: successful: " + successful); |
||||
if (errors != null) { |
||||
foreach (object o in errors) { |
||||
Exception ex = o as Exception; |
||||
if (ex != null) { |
||||
System.Console.WriteLine("DesignerLoader.OnEndLoad: Exception: " + ex.ToString()); |
||||
} |
||||
} |
||||
} |
||||
base.OnEndLoad(successful, errors); |
||||
} |
||||
|
||||
protected override void OnBeginLoad() |
||||
{ |
||||
System.Console.WriteLine("DesignerLoader.OnBeginLoad"); |
||||
base.OnBeginLoad(); |
||||
} |
||||
|
||||
protected override void Initialize() |
||||
{ |
||||
System.Console.WriteLine("DesignerLoader.Initialize"); |
||||
base.Initialize(); |
||||
} |
||||
|
||||
protected override void PerformLoad(IDesignerSerializationManager manager) |
||||
{ |
||||
System.Console.WriteLine("DesignerLoader.PerformLoad Before"); |
||||
base.PerformLoad(manager); |
||||
System.Console.WriteLine("DesignerLoader.PerformLoad After"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
|
||||
namespace ICSharpCode.Scripting |
||||
{ |
||||
public interface IComponentWalker |
||||
{ |
||||
IComponent CreateComponent(string code); |
||||
} |
||||
} |
@ -0,0 +1,156 @@
@@ -0,0 +1,156 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Globalization; |
||||
using System.Resources; |
||||
using System.Security.Permissions; |
||||
|
||||
using ICSharpCode.FormsDesigner.Services; |
||||
|
||||
namespace ICSharpCode.Scripting |
||||
{ |
||||
/// <summary>
|
||||
/// Loads the form or control's code so the forms designer can
|
||||
/// display it.
|
||||
/// </summary>
|
||||
[PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")] |
||||
[PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")] |
||||
public class ScriptingDesignerLoader : BasicDesignerLoader, IComponentCreator |
||||
{ |
||||
IScriptingDesignerGenerator generator; |
||||
IDesignerSerializationManager serializationManager; |
||||
IResourceService resourceService; |
||||
Dictionary<string, IComponent> addedObjects = new Dictionary<string, IComponent>(); |
||||
|
||||
public ScriptingDesignerLoader(IScriptingDesignerGenerator generator) |
||||
{ |
||||
if (generator == null) { |
||||
throw new ArgumentException("Generator cannot be null.", "generator"); |
||||
} |
||||
this.generator = generator; |
||||
} |
||||
|
||||
public override void BeginLoad(IDesignerLoaderHost host) |
||||
{ |
||||
AddServices(host); |
||||
SetDesignerSupportsProjectResourcesToFalse(host); |
||||
base.BeginLoad(host); |
||||
} |
||||
|
||||
void AddServices(IDesignerLoaderHost host) |
||||
{ |
||||
host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host)); |
||||
host.AddService(typeof(INameCreationService), new ScriptingNameCreationService(host)); |
||||
host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host)); |
||||
} |
||||
|
||||
void SetDesignerSupportsProjectResourcesToFalse(IDesignerLoaderHost host) |
||||
{ |
||||
ProjectResourceService projectResourceService = host.GetService(typeof(ProjectResourceService)) as ProjectResourceService; |
||||
if (projectResourceService != null) { |
||||
projectResourceService.DesignerSupportsProjectResources = false; |
||||
} |
||||
} |
||||
|
||||
public IComponent CreateComponent(Type componentClass, string name) |
||||
{ |
||||
return base.LoaderHost.CreateComponent(componentClass, name); |
||||
} |
||||
|
||||
public void Add(IComponent component, string name) |
||||
{ |
||||
base.LoaderHost.Container.Add(component, name); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets a component that has been added to the loader.
|
||||
/// </summary>
|
||||
/// <returns>Null if the component cannot be found.</returns>
|
||||
public IComponent GetComponent(string name) |
||||
{ |
||||
return LoaderHost.Container.Components[name]; |
||||
} |
||||
|
||||
public IComponent RootComponent { |
||||
get { return base.LoaderHost.RootComponent; } |
||||
} |
||||
|
||||
public object CreateInstance(Type type, ICollection arguments, string name, bool addToContainer) |
||||
{ |
||||
return serializationManager.CreateInstance(type, arguments, name, addToContainer); |
||||
} |
||||
|
||||
public object GetInstance(string name) |
||||
{ |
||||
return serializationManager.GetInstance(name); |
||||
} |
||||
|
||||
public Type GetType(string typeName) |
||||
{ |
||||
return serializationManager.GetType(typeName); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the property descriptor associated with the event.
|
||||
/// </summary>
|
||||
public PropertyDescriptor GetEventProperty(EventDescriptor e) |
||||
{ |
||||
IEventBindingService eventBindingService = GetService(typeof(IEventBindingService)) as IEventBindingService; |
||||
return eventBindingService.GetEventProperty(e); |
||||
} |
||||
|
||||
public IResourceReader GetResourceReader(CultureInfo info) |
||||
{ |
||||
if (GetResourceService()) { |
||||
return resourceService.GetResourceReader(info); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
bool GetResourceService() |
||||
{ |
||||
resourceService = (IResourceService)LoaderHost.GetService(typeof(IResourceService)); |
||||
return resourceService != null; |
||||
} |
||||
|
||||
public IResourceWriter GetResourceWriter(CultureInfo info) |
||||
{ |
||||
if (GetResourceService()) { |
||||
return resourceService.GetResourceWriter(info); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Passes the designer host's root component to the generator so it can update the
|
||||
/// source code with changes made at design time.
|
||||
/// </summary>
|
||||
protected override void PerformFlush(IDesignerSerializationManager serializationManager) |
||||
{ |
||||
generator.MergeRootComponentChanges(LoaderHost, serializationManager); |
||||
} |
||||
|
||||
protected override void PerformLoad(IDesignerSerializationManager serializationManager) |
||||
{ |
||||
this.serializationManager = serializationManager; |
||||
CreateComponents(); |
||||
} |
||||
|
||||
void CreateComponents() |
||||
{ |
||||
IComponentWalker walker = CreateComponentWalker(this); |
||||
walker.CreateComponent(generator.ViewContent.DesignerCodeFileContent); |
||||
} |
||||
|
||||
protected virtual IComponentWalker CreateComponentWalker(IComponentCreator componentCreator) |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,127 @@
@@ -0,0 +1,127 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Globalization; |
||||
using System.Resources; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
[TestFixture] |
||||
public class ScriptingDesignerLoaderGetResourcesTests |
||||
{ |
||||
ScriptingDesignerLoader loader; |
||||
MockDesignerLoaderHost host; |
||||
MockResourceService resourceService; |
||||
MockResourceReader fakeReader; |
||||
MockResourceWriter fakeWriter; |
||||
MockResourceWriter writer; |
||||
MockResourceReader reader; |
||||
|
||||
[Test] |
||||
public void GetResourceReader_PassedInvariantCulture_ReturnsReaderFromResourceService() |
||||
{ |
||||
BeginLoad(); |
||||
GetResourceReader(); |
||||
Assert.AreEqual(fakeReader, reader); |
||||
} |
||||
|
||||
void BeginLoad() |
||||
{ |
||||
CreateResourceService(); |
||||
CreateDesignerLoaderHost(); |
||||
|
||||
host.AddService(typeof(IResourceService), resourceService); |
||||
|
||||
BeginLoad(host); |
||||
} |
||||
|
||||
void CreateResourceService() |
||||
{ |
||||
fakeReader = new MockResourceReader(); |
||||
fakeWriter = new MockResourceWriter(); |
||||
resourceService = new MockResourceService(); |
||||
resourceService.SetResourceReader(fakeReader); |
||||
resourceService.SetResourceWriter(fakeWriter); |
||||
} |
||||
|
||||
void CreateDesignerLoaderHost() |
||||
{ |
||||
host = new MockDesignerLoaderHost(); |
||||
} |
||||
|
||||
void BeginLoad(IDesignerLoaderHost host) |
||||
{ |
||||
loader = new ScriptingDesignerLoader(new MockDesignerGenerator()); |
||||
loader.BeginLoad(host); |
||||
} |
||||
|
||||
void BeginLoadWithoutResourceService() |
||||
{ |
||||
CreateDesignerLoaderHost(); |
||||
BeginLoad(host); |
||||
} |
||||
|
||||
void GetResourceReader() |
||||
{ |
||||
reader = loader.GetResourceReader(CultureInfo.InvariantCulture) as MockResourceReader; |
||||
} |
||||
|
||||
void GetResourceWriter() |
||||
{ |
||||
writer = loader.GetResourceWriter(CultureInfo.InvariantCulture) as MockResourceWriter; |
||||
} |
||||
|
||||
[Test] |
||||
public void GetResourceReader_PassedInvariantCulture_CultureInfoPassedToResourceServiceForReader() |
||||
{ |
||||
BeginLoad(); |
||||
GetResourceReader(); |
||||
CultureInfo culture = resourceService.CultureInfoPassedToGetResourceReader; |
||||
CultureInfo expectedCulture = CultureInfo.InvariantCulture; |
||||
Assert.AreEqual(expectedCulture, culture); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetResourceReader_NoResourceService_ReturnsNull() |
||||
{ |
||||
BeginLoadWithoutResourceService(); |
||||
GetResourceReader(); |
||||
Assert.IsNull(reader); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetResourceWriter_PassedInvariantCulture_ReturnsWriterFromResourceService() |
||||
{ |
||||
BeginLoad(); |
||||
GetResourceWriter(); |
||||
Assert.AreEqual(fakeWriter, writer); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetResourceWriter_PassedInvariantCulture_CultureInfoPassedToResourceServiceForWriter() |
||||
{ |
||||
BeginLoad(); |
||||
GetResourceWriter(); |
||||
CultureInfo culture = resourceService.CultureInfoPassedToGetResourceWriter; |
||||
CultureInfo expectedCulture = CultureInfo.InvariantCulture; |
||||
Assert.AreEqual(expectedCulture, culture); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetResourceWriter_NoResourceService_ReturnsNull() |
||||
{ |
||||
BeginLoadWithoutResourceService(); |
||||
GetResourceWriter(); |
||||
Assert.IsNull(writer); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,404 @@
@@ -0,0 +1,404 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.FormsDesigner.Services; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
[TestFixture] |
||||
[RequiresSTA] |
||||
public class ScriptingDesignerLoaderTests |
||||
{ |
||||
MockDesignerGenerator fakeGenerator; |
||||
TestableScriptingDesignerLoader loader; |
||||
MockDesignerLoaderHost fakeDesignerLoaderHost; |
||||
MockEventBindingService fakeEventBindingService; |
||||
FormsDesignerViewContent formsDesignerView; |
||||
FakeDesignerSerializationManager fakeSerializationManager; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
CreateScriptingDesignerLoader(); |
||||
} |
||||
|
||||
void CreateScriptingDesignerLoader() |
||||
{ |
||||
fakeGenerator = new MockDesignerGenerator(); |
||||
loader = new TestableScriptingDesignerLoader(fakeGenerator); |
||||
|
||||
formsDesignerView = new FormsDesignerViewContent(new MockViewContent(), new MockOpenedFile("Test.py")); |
||||
fakeGenerator.Attach(formsDesignerView); |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
loader.Dispose(); |
||||
} |
||||
|
||||
[Test] |
||||
public void ScriptingDesignerLoaderClass_NewInstance_IsBasicDesignerLoader() |
||||
{ |
||||
BasicDesignerLoader basicLoader = loader as BasicDesignerLoader; |
||||
Assert.IsNotNull(basicLoader); |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginLoad_PassedFakeDesignerLoaderHost_ComponentSerializationServiceAddedToDesignerLoaderHost() |
||||
{ |
||||
BeginLoad(); |
||||
CodeDomComponentSerializationService service = fakeDesignerLoaderHost.GetService(typeof(ComponentSerializationService)) as CodeDomComponentSerializationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
void BeginLoad() |
||||
{ |
||||
CreateDesignerLoaderHostWithoutProjectResourceService(); |
||||
fakeDesignerLoaderHost.AddService(typeof(ProjectResourceService), new ProjectResourceService(new MockProjectContent())); |
||||
loader.BeginLoad(fakeDesignerLoaderHost); |
||||
} |
||||
|
||||
void CreateDesignerLoaderHostWithoutProjectResourceService() |
||||
{ |
||||
fakeDesignerLoaderHost = new MockDesignerLoaderHost(); |
||||
fakeEventBindingService = new MockEventBindingService(); |
||||
fakeDesignerLoaderHost.AddService(typeof(IEventBindingService), fakeEventBindingService); |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginLoad_PassedFakeDesignerLoaderHost_NameCreationServiceAddedToDesignerLoaderHost() |
||||
{ |
||||
BeginLoad(); |
||||
ScriptingNameCreationService service = fakeDesignerLoaderHost.GetService(typeof(INameCreationService)) as ScriptingNameCreationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginLoad_PassedFakeDesignerLoaderHost_DesignerSerializationServiceAddedToDesignerLoaderHost() |
||||
{ |
||||
BeginLoad(); |
||||
DesignerSerializationService service = fakeDesignerLoaderHost.GetService(typeof(IDesignerSerializationService)) as DesignerSerializationService; |
||||
Assert.IsNotNull(service); |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginLoad_PassedFakeDesignerLoaderHost_ProjectResourceServiceDesignerAddedToDesignerLoaderHostDoesNotSupportProjectResources() |
||||
{ |
||||
BeginLoad(); |
||||
ProjectResourceService service = fakeDesignerLoaderHost.GetService(typeof(ProjectResourceService)) as ProjectResourceService; |
||||
Assert.IsFalse(service.DesignerSupportsProjectResources); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetEventProperty_PassedFormLoadEventDescriptor_ReturnsPropertyDescriptorFromEventBindingService() |
||||
{ |
||||
BeginLoad(); |
||||
IEventBindingService eventBindingService = (IEventBindingService)fakeEventBindingService; |
||||
EventDescriptor e = TypeDescriptor.GetEvents(typeof(Form)).Find("Load", true); |
||||
|
||||
PropertyDescriptor propertyDescriptor = loader.GetEventProperty(e); |
||||
PropertyDescriptor expectedPropertyDescriptor = eventBindingService.GetEventProperty(e); |
||||
|
||||
Assert.AreEqual(expectedPropertyDescriptor, propertyDescriptor); |
||||
} |
||||
|
||||
[Test] |
||||
public void ScriptingDesignerLoaderConstructor_PassedNullGenerator_ThrowsArgumentException() |
||||
{ |
||||
ArgumentException ex = Assert.Throws<ArgumentException>(delegate { |
||||
loader = new TestableScriptingDesignerLoader(null); |
||||
}); |
||||
string paramName = ex.ParamName; |
||||
string expectedParamName = "generator"; |
||||
Assert.AreEqual(expectedParamName, paramName); |
||||
} |
||||
|
||||
[Test] |
||||
public void PerformFlush_PassedDesignerSerializationManager_DesignerLoaderHostPassedToMergeRootComponentChangesMethod() |
||||
{ |
||||
BeginLoad(); |
||||
DesignerSerializationManager serializationManager = new DesignerSerializationManager(); |
||||
loader.CallPerformFlush(serializationManager); |
||||
|
||||
IDesignerHost host = fakeGenerator.MergeChangesHost; |
||||
Assert.AreEqual(fakeDesignerLoaderHost, host); |
||||
} |
||||
|
||||
[Test] |
||||
public void PerformFlush_PassedDesignerSerializationManager_SerializationManagerPassedToMergeRootComponentMethod() |
||||
{ |
||||
BeginLoad(); |
||||
DesignerSerializationManager expectedSerializationManager = new DesignerSerializationManager(); |
||||
loader.CallPerformFlush(expectedSerializationManager); |
||||
|
||||
IDesignerSerializationManager serializationManager = fakeGenerator.MergeChangesSerializationManager; |
||||
Assert.AreEqual(expectedSerializationManager, serializationManager); |
||||
} |
||||
|
||||
[Test] |
||||
public void RootComponent_DesignerLoaderHostRootComponentIsForm_ReturnsDesignerLoaderHostRootComponent() |
||||
{ |
||||
BeginLoad(); |
||||
using (Form form = new Form()) { |
||||
fakeDesignerLoaderHost.RootComponent = form; |
||||
IComponent rootComponent = loader.RootComponent; |
||||
Assert.AreEqual(form, rootComponent); |
||||
} |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void BeginLoad_PassedFakeDesignerLoaderHost_CallsCreatesComponentWalkerPassingNonNullComponentCreator() |
||||
{ |
||||
BeginLoad(); |
||||
IComponentCreator componentCreator = loader.ComponentCreatorPassedToCreateComponentWalker; |
||||
Assert.IsNotNull(componentCreator); |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginLoad_PassedFakeDesignerLoaderHost_CallsComponentWalkerCreateComponentMethodPassingFormCode() |
||||
{ |
||||
string expectedCode = |
||||
"MyForm(Form):\r\n" + |
||||
" pass"; |
||||
|
||||
formsDesignerView.DesignerCodeFileContent = expectedCode; |
||||
|
||||
BeginLoad(); |
||||
string code = loader.FakeComponentWalker.CodePassedToCreateComponent; |
||||
Assert.AreEqual(expectedCode, code); |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginLoad_NoProjectResourceService_NullReferenceExceptionIsNotThrown() |
||||
{ |
||||
CreateDesignerLoaderHostWithoutProjectResourceService(); |
||||
|
||||
Assert.DoesNotThrow(delegate { loader.BeginLoad(fakeDesignerLoaderHost); }); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateComponent_CreateTextBox_TextBoxTypePassedToDesignerLoaderHostCreateComponentMethod() |
||||
{ |
||||
BeginLoad(); |
||||
loader.CreateComponent(typeof(TextBox), "MyTextBox"); |
||||
CreatedComponent createdComponent = fakeDesignerLoaderHost.CreatedComponents[0]; |
||||
CreatedComponent expectedCreatedComponent = new CreatedComponent("System.Windows.Forms.TextBox", "MyTextBox"); |
||||
|
||||
Assert.AreEqual(expectedCreatedComponent, createdComponent); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateComponent_CreateTextBox_TextBoxInstanceReturned() |
||||
{ |
||||
BeginLoad(); |
||||
IComponent component = loader.CreateComponent(typeof(TextBox), "MyTextBox"); |
||||
bool result = component is TextBox; |
||||
|
||||
Assert.IsTrue(result); |
||||
} |
||||
|
||||
[Test] |
||||
public void Add_AddTextBox_AddsTextBoxToDesignerLoaderHostContainer() |
||||
{ |
||||
BeginLoad(); |
||||
using (TextBox textBox = new TextBox()) { |
||||
loader.Add(textBox, "MyTextBox"); |
||||
IComponent component = fakeDesignerLoaderHost.Container.Components["MyTextBox"]; |
||||
Assert.AreEqual(textBox, component); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void GetComponent_TextBoxAddedToLoader_ReturnsTextBox() |
||||
{ |
||||
BeginLoad(); |
||||
using (TextBox textBox = new TextBox()) { |
||||
loader.Add(textBox, "MyTextBox"); |
||||
IComponent component = loader.GetComponent("MyTextBox"); |
||||
Assert.AreEqual(textBox, component); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void GetComponent_NoComponentsAddedToLoader_ReturnsNull() |
||||
{ |
||||
BeginLoad(); |
||||
IComponent component = loader.GetComponent("MyTextBox"); |
||||
Assert.IsNull(component); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetType_PassedTypeName_ReturnsTypeFromDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
Type expectedType = typeof(string); |
||||
fakeSerializationManager.TypeToReturnFromGetType = expectedType; |
||||
Type type = loader.GetType("string"); |
||||
|
||||
Assert.AreEqual(expectedType, type); |
||||
} |
||||
|
||||
void CreateDesignerSerializationManager() |
||||
{ |
||||
fakeSerializationManager = new FakeDesignerSerializationManager(); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetType_PassedTypeName_TypeNamePassedToDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
string expectedTypeName = "test"; |
||||
loader.GetType(expectedTypeName); |
||||
|
||||
string typeName = fakeSerializationManager.TypeNamePassedToGetType; |
||||
Assert.AreEqual(expectedTypeName, typeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetInstance_PassedName_ReturnsInstanceFromDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
object expectedInstance = new object(); |
||||
fakeSerializationManager.InstanceToReturnFromGetInstance = expectedInstance; |
||||
object instance = loader.GetInstance("test"); |
||||
|
||||
Assert.AreEqual(expectedInstance, instance); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetInstance_PassedName_InstanceNamePassedToDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
string expectedName = "test"; |
||||
loader.GetInstance(expectedName); |
||||
|
||||
string name = fakeSerializationManager.NamePassedToGetInstance; |
||||
Assert.AreEqual(expectedName, name); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateInstance_PassedType_ReturnsInstanceFromDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
object expectedInstance = new object(); |
||||
fakeSerializationManager.InstanceToReturnFromCreateInstance = expectedInstance; |
||||
object instance = LoaderCreateInstance(typeof(string)); |
||||
|
||||
Assert.AreEqual(expectedInstance, instance); |
||||
} |
||||
|
||||
object LoaderCreateInstance(Type type) |
||||
{ |
||||
return LoaderCreateInstance(type, null, null, false); |
||||
} |
||||
|
||||
object LoaderCreateInstance(string name) |
||||
{ |
||||
return LoaderCreateInstance(null, null, name, false); |
||||
} |
||||
|
||||
object LoaderCreateInstance(ICollection arguments) |
||||
{ |
||||
return LoaderCreateInstance(null, arguments, null, false); |
||||
} |
||||
|
||||
object LoaderCreateInstance(bool addToContainer) |
||||
{ |
||||
return LoaderCreateInstance(null, null, null, addToContainer); |
||||
} |
||||
|
||||
object LoaderCreateInstance(Type type, ICollection arguments, string name, bool addToContainer) |
||||
{ |
||||
return loader.CreateInstance(type, arguments, name, addToContainer); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateInstance_PassedType_TypePassedToDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
Type expectedType = typeof(string); |
||||
LoaderCreateInstance(expectedType); |
||||
Type type = fakeSerializationManager.TypePassedToCreateInstance; |
||||
|
||||
Assert.AreEqual(expectedType, type); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateInstance_PassedName_NamePassedToDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
string expectedName = "test"; |
||||
LoaderCreateInstance(expectedName); |
||||
string name = fakeSerializationManager.NamePassedToCreateInstance; |
||||
|
||||
Assert.AreEqual(expectedName, name); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateInstance_PassedTrueAddToContainer_AddToContainerPassedToDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
LoaderCreateInstance(true); |
||||
bool addToContainer = fakeSerializationManager.AddToContainerPassedToCreateInstance; |
||||
|
||||
Assert.IsTrue(addToContainer); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateInstance_PassedFalseAddToContainer_AddToContainerPassedToDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
LoaderCreateInstance(false); |
||||
bool addToContainer = fakeSerializationManager.AddToContainerPassedToCreateInstance; |
||||
|
||||
Assert.IsFalse(addToContainer); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateInstance_PassedArguments_ArgumentsPassedToDesignerSerializationManager() |
||||
{ |
||||
CreateDesignerSerializationManager(); |
||||
loader.CallPerformLoad(fakeSerializationManager); |
||||
|
||||
string[] expectedArguments = new string[] { "a", "b" }; |
||||
LoaderCreateInstance(expectedArguments); |
||||
ICollection arguments = fakeSerializationManager.ArgumentsPassedToCreateInstance; |
||||
|
||||
Assert.AreEqual(expectedArguments, arguments); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using ICSharpCode.Scripting; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
public class FakeComponentWalker : IComponentWalker |
||||
{ |
||||
public string CodePassedToCreateComponent; |
||||
|
||||
public IComponent CreateComponent(string code) |
||||
{ |
||||
CodePassedToCreateComponent = code; |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,113 @@
@@ -0,0 +1,113 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
public class FakeDesignerSerializationManager : IDesignerSerializationManager |
||||
{ |
||||
public Type TypeToReturnFromGetType; |
||||
public string TypeNamePassedToGetType; |
||||
public object InstanceToReturnFromGetInstance; |
||||
public string NamePassedToGetInstance; |
||||
public object InstanceToReturnFromCreateInstance; |
||||
public Type TypePassedToCreateInstance; |
||||
public ICollection ArgumentsPassedToCreateInstance; |
||||
public string NamePassedToCreateInstance; |
||||
public bool AddToContainerPassedToCreateInstance; |
||||
|
||||
public event ResolveNameEventHandler ResolveName; |
||||
|
||||
protected virtual void OnResolveName(ResolveNameEventArgs e) |
||||
{ |
||||
if (ResolveName != null) { |
||||
ResolveName(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler SerializationComplete; |
||||
|
||||
protected virtual void OnSerializationComplete(EventArgs e) |
||||
{ |
||||
if (SerializationComplete != null) { |
||||
SerializationComplete(this, e); |
||||
} |
||||
} |
||||
|
||||
public ContextStack Context { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public PropertyDescriptorCollection Properties { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public void AddSerializationProvider(IDesignerSerializationProvider provider) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public object CreateInstance(Type type, ICollection arguments, string name, bool addToContainer) |
||||
{ |
||||
TypePassedToCreateInstance = type; |
||||
ArgumentsPassedToCreateInstance = arguments; |
||||
NamePassedToCreateInstance = name; |
||||
AddToContainerPassedToCreateInstance = addToContainer; |
||||
return InstanceToReturnFromCreateInstance; |
||||
} |
||||
|
||||
public object GetInstance(string name) |
||||
{ |
||||
NamePassedToGetInstance = name; |
||||
return InstanceToReturnFromGetInstance; |
||||
} |
||||
|
||||
public string GetName(object value) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public object GetSerializer(Type objectType, Type serializerType) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public Type GetType(string typeName) |
||||
{ |
||||
TypeNamePassedToGetType = typeName; |
||||
return TypeToReturnFromGetType; |
||||
} |
||||
|
||||
public void RemoveSerializationProvider(IDesignerSerializationProvider provider) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void ReportError(object errorInformation) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void SetName(object instance, string name) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public object GetService(Type serviceType) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using ICSharpCode.Scripting; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
public class TestableScriptingDesignerLoader : ScriptingDesignerLoader |
||||
{ |
||||
public IComponentCreator ComponentCreatorPassedToCreateComponentWalker; |
||||
public FakeComponentWalker FakeComponentWalker = new FakeComponentWalker(); |
||||
|
||||
public TestableScriptingDesignerLoader(IScriptingDesignerGenerator generator) |
||||
: base(generator) |
||||
{ |
||||
} |
||||
|
||||
public void CallPerformFlush(IDesignerSerializationManager serializationManager) |
||||
{ |
||||
base.PerformFlush(serializationManager); |
||||
} |
||||
|
||||
public void CallPerformLoad(IDesignerSerializationManager serializationManager) |
||||
{ |
||||
base.PerformLoad(serializationManager); |
||||
} |
||||
|
||||
protected override IComponentWalker CreateComponentWalker(IComponentCreator componentCreator) |
||||
{ |
||||
ComponentCreatorPassedToCreateComponentWalker = componentCreator; |
||||
return FakeComponentWalker; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue