562 changed files with 28462 additions and 26904 deletions
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// 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.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageResultsReader |
||||
{ |
||||
List<string> fileNames = new List<string>(); |
||||
IFileSystem fileSystem = new FileSystem(); |
||||
List<string> missingFileNames = new List<string>(); |
||||
|
||||
public CodeCoverageResultsReader() |
||||
{ |
||||
} |
||||
|
||||
public void AddResultsFile(string fileName) |
||||
{ |
||||
fileNames.Add(fileName); |
||||
} |
||||
|
||||
public IEnumerable<CodeCoverageResults> GetResults() |
||||
{ |
||||
foreach (string fileName in fileNames) { |
||||
if (fileSystem.FileExists(fileName)) { |
||||
yield return ReadCodeCoverageResults(fileName); |
||||
} else { |
||||
missingFileNames.Add(fileName); |
||||
} |
||||
} |
||||
} |
||||
|
||||
CodeCoverageResults ReadCodeCoverageResults(string fileName) |
||||
{ |
||||
TextReader reader = fileSystem.CreateTextReader(fileName); |
||||
return new CodeCoverageResults(reader); |
||||
} |
||||
|
||||
public IEnumerable<string> GetMissingResultsFiles() |
||||
{ |
||||
return missingFileNames; |
||||
} |
||||
} |
||||
} |
@ -1,110 +1,110 @@
@@ -1,110 +1,110 @@
|
||||
// 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.Diagnostics; |
||||
using System.IO; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageTestRunner : TestProcessRunnerBase |
||||
{ |
||||
UnitTestingOptions options; |
||||
IFileSystem fileSystem; |
||||
OpenCoverApplication partCoverApplication; |
||||
OpenCoverSettingsFactory settingsFactory; |
||||
|
||||
public CodeCoverageTestRunner() |
||||
: this(new CodeCoverageTestRunnerContext()) |
||||
{ |
||||
} |
||||
|
||||
public CodeCoverageTestRunner(CodeCoverageTestRunnerContext context) |
||||
: base(context) |
||||
{ |
||||
this.options = context.Options; |
||||
this.fileSystem = context.CodeCoverageFileSystem; |
||||
settingsFactory = new OpenCoverSettingsFactory(fileSystem); |
||||
} |
||||
|
||||
public bool HasCodeCoverageResults() |
||||
{ |
||||
return fileSystem.FileExists(CodeCoverageResultsFileName); |
||||
} |
||||
|
||||
public CodeCoverageResults ReadCodeCoverageResults() |
||||
{ |
||||
TextReader reader = fileSystem.CreateTextReader(CodeCoverageResultsFileName); |
||||
return new CodeCoverageResults(reader); |
||||
} |
||||
|
||||
public string CodeCoverageResultsFileName { |
||||
get { return partCoverApplication.CodeCoverageResultsFileName; } |
||||
} |
||||
|
||||
public override void Start(SelectedTests selectedTests) |
||||
{ |
||||
AddProfilerEnvironmentVariableToProcessRunner(); |
||||
CreatePartCoverApplication(selectedTests); |
||||
RemoveExistingCodeCoverageResultsFile(); |
||||
CreateDirectoryForCodeCoverageResultsFile(); |
||||
AppendRunningCodeCoverageMessage(); |
||||
|
||||
base.Start(selectedTests); |
||||
} |
||||
|
||||
void AddProfilerEnvironmentVariableToProcessRunner() |
||||
{ |
||||
ProcessRunner.EnvironmentVariables.Add("COMPLUS_ProfAPI_ProfilerCompatibilitySetting", "EnableV2Profiler"); |
||||
} |
||||
|
||||
void CreatePartCoverApplication(SelectedTests selectedTests) |
||||
{ |
||||
NUnitConsoleApplication nunitConsoleApp = new NUnitConsoleApplication(selectedTests, options); |
||||
nunitConsoleApp.Results = base.TestResultsMonitor.FileName; |
||||
|
||||
OpenCoverSettings settings = settingsFactory.CreateOpenCoverSettings(selectedTests.Project); |
||||
partCoverApplication = new OpenCoverApplication(nunitConsoleApp, settings); |
||||
} |
||||
|
||||
void RemoveExistingCodeCoverageResultsFile() |
||||
{ |
||||
string fileName = CodeCoverageResultsFileName; |
||||
if (fileSystem.FileExists(fileName)) { |
||||
fileSystem.DeleteFile(fileName); |
||||
} |
||||
} |
||||
|
||||
void CreateDirectoryForCodeCoverageResultsFile() |
||||
{ |
||||
string directory = Path.GetDirectoryName(CodeCoverageResultsFileName); |
||||
if (!fileSystem.DirectoryExists(directory)) { |
||||
fileSystem.CreateDirectory(directory); |
||||
} |
||||
} |
||||
|
||||
void AppendRunningCodeCoverageMessage() |
||||
{ |
||||
string message = ParseString("${res:ICSharpCode.CodeCoverage.RunningCodeCoverage}"); |
||||
OnMessageReceived(message); |
||||
} |
||||
|
||||
protected virtual string ParseString(string text) |
||||
{ |
||||
return StringParser.Parse(text); |
||||
} |
||||
|
||||
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) |
||||
{ |
||||
return partCoverApplication.GetProcessStartInfo(); |
||||
} |
||||
|
||||
protected override TestResult CreateTestResultForTestFramework(TestResult testResult) |
||||
{ |
||||
return new NUnitTestResult(testResult); |
||||
} |
||||
} |
||||
} |
||||
//// 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.Diagnostics;
|
||||
//using System.IO;
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//using ICSharpCode.UnitTesting;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage
|
||||
//{
|
||||
// public class CodeCoverageTestRunner : TestProcessRunnerBase
|
||||
// {
|
||||
// UnitTestingOptions options;
|
||||
// IFileSystem fileSystem;
|
||||
// OpenCoverApplication partCoverApplication;
|
||||
// OpenCoverSettingsFactory settingsFactory;
|
||||
//
|
||||
// public CodeCoverageTestRunner()
|
||||
// : this(new CodeCoverageTestRunnerContext())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public CodeCoverageTestRunner(CodeCoverageTestRunnerContext context)
|
||||
// : base(context)
|
||||
// {
|
||||
// this.options = context.Options;
|
||||
// this.fileSystem = context.CodeCoverageFileSystem;
|
||||
// settingsFactory = new OpenCoverSettingsFactory(fileSystem);
|
||||
// }
|
||||
//
|
||||
// public bool HasCodeCoverageResults()
|
||||
// {
|
||||
// return fileSystem.FileExists(CodeCoverageResultsFileName);
|
||||
// }
|
||||
//
|
||||
// public CodeCoverageResults ReadCodeCoverageResults()
|
||||
// {
|
||||
// TextReader reader = fileSystem.CreateTextReader(CodeCoverageResultsFileName);
|
||||
// return new CodeCoverageResults(reader);
|
||||
// }
|
||||
//
|
||||
// public string CodeCoverageResultsFileName {
|
||||
// get { return partCoverApplication.CodeCoverageResultsFileName; }
|
||||
// }
|
||||
//
|
||||
// public override void Start(SelectedTests selectedTests)
|
||||
// {
|
||||
// AddProfilerEnvironmentVariableToProcessRunner();
|
||||
// CreatePartCoverApplication(selectedTests);
|
||||
// RemoveExistingCodeCoverageResultsFile();
|
||||
// CreateDirectoryForCodeCoverageResultsFile();
|
||||
// AppendRunningCodeCoverageMessage();
|
||||
//
|
||||
// base.Start(selectedTests);
|
||||
// }
|
||||
//
|
||||
// void AddProfilerEnvironmentVariableToProcessRunner()
|
||||
// {
|
||||
// ProcessRunner.EnvironmentVariables.Add("COMPLUS_ProfAPI_ProfilerCompatibilitySetting", "EnableV2Profiler");
|
||||
// }
|
||||
//
|
||||
// void CreatePartCoverApplication(SelectedTests selectedTests)
|
||||
// {
|
||||
// NUnitConsoleApplication nunitConsoleApp = new NUnitConsoleApplication(selectedTests, options);
|
||||
// nunitConsoleApp.Results = base.TestResultsMonitor.FileName;
|
||||
//
|
||||
// OpenCoverSettings settings = settingsFactory.CreateOpenCoverSettings(selectedTests.Project);
|
||||
// partCoverApplication = new OpenCoverApplication(nunitConsoleApp, settings);
|
||||
// }
|
||||
//
|
||||
// void RemoveExistingCodeCoverageResultsFile()
|
||||
// {
|
||||
// string fileName = CodeCoverageResultsFileName;
|
||||
// if (fileSystem.FileExists(fileName)) {
|
||||
// fileSystem.DeleteFile(fileName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void CreateDirectoryForCodeCoverageResultsFile()
|
||||
// {
|
||||
// string directory = Path.GetDirectoryName(CodeCoverageResultsFileName);
|
||||
// if (!fileSystem.DirectoryExists(directory)) {
|
||||
// fileSystem.CreateDirectory(directory);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void AppendRunningCodeCoverageMessage()
|
||||
// {
|
||||
// string message = ParseString("${res:ICSharpCode.CodeCoverage.RunningCodeCoverage}");
|
||||
// OnMessageReceived(message);
|
||||
// }
|
||||
//
|
||||
// protected virtual string ParseString(string text)
|
||||
// {
|
||||
// return StringParser.Parse(text);
|
||||
// }
|
||||
//
|
||||
// protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
|
||||
// {
|
||||
// return partCoverApplication.GetProcessStartInfo();
|
||||
// }
|
||||
//
|
||||
// protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
|
||||
// {
|
||||
// return new NUnitTestResult(testResult);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,40 +1,40 @@
@@ -1,40 +1,40 @@
|
||||
// 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.UnitTesting; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageTestRunnerContext : TestProcessRunnerBaseContext |
||||
{ |
||||
UnitTestingOptions options; |
||||
|
||||
public CodeCoverageTestRunnerContext() |
||||
: this(new UnitTestProcessRunner(), |
||||
new TestResultsMonitor(), |
||||
new FileSystem(), |
||||
new UnitTestMessageService(), |
||||
new UnitTestingOptions()) |
||||
{ |
||||
} |
||||
|
||||
public CodeCoverageTestRunnerContext(IUnitTestProcessRunner processRunner, |
||||
ITestResultsMonitor testResultsMonitor, |
||||
ICSharpCode.CodeCoverage.IFileSystem fileSystem, |
||||
IUnitTestMessageService messageService, |
||||
UnitTestingOptions options) |
||||
: base(processRunner, testResultsMonitor, fileSystem, messageService) |
||||
{ |
||||
this.options = options; |
||||
} |
||||
|
||||
public UnitTestingOptions Options { |
||||
get { return options; } |
||||
} |
||||
|
||||
public ICSharpCode.CodeCoverage.IFileSystem CodeCoverageFileSystem { |
||||
get { return base.FileSystem as ICSharpCode.CodeCoverage.IFileSystem; } |
||||
} |
||||
} |
||||
} |
||||
//// 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.UnitTesting;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage
|
||||
//{
|
||||
// public class CodeCoverageTestRunnerContext : TestProcessRunnerBaseContext
|
||||
// {
|
||||
// UnitTestingOptions options;
|
||||
//
|
||||
// public CodeCoverageTestRunnerContext()
|
||||
// : this(new UnitTestProcessRunner(),
|
||||
// new TestResultsMonitor(),
|
||||
// new FileSystem(),
|
||||
// new UnitTestMessageService(),
|
||||
// new UnitTestingOptions())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public CodeCoverageTestRunnerContext(IUnitTestProcessRunner processRunner,
|
||||
// ITestResultsMonitor testResultsMonitor,
|
||||
// ICSharpCode.CodeCoverage.IFileSystem fileSystem,
|
||||
// IUnitTestMessageService messageService,
|
||||
// UnitTestingOptions options)
|
||||
// : base(processRunner, testResultsMonitor, fileSystem, messageService)
|
||||
// {
|
||||
// this.options = options;
|
||||
// }
|
||||
//
|
||||
// public UnitTestingOptions Options {
|
||||
// get { return options; }
|
||||
// }
|
||||
//
|
||||
// public ICSharpCode.CodeCoverage.IFileSystem CodeCoverageFileSystem {
|
||||
// get { return base.FileSystem as ICSharpCode.CodeCoverage.IFileSystem; }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,16 +1,16 @@
@@ -1,16 +1,16 @@
|
||||
// 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.UnitTesting; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageTestRunnerFactory : ICodeCoverageTestRunnerFactory |
||||
{ |
||||
public CodeCoverageTestRunner CreateCodeCoverageTestRunner() |
||||
{ |
||||
return new CodeCoverageTestRunner(); |
||||
} |
||||
} |
||||
} |
||||
//// 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.UnitTesting;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage
|
||||
//{
|
||||
// public class CodeCoverageTestRunnerFactory : ICodeCoverageTestRunnerFactory
|
||||
// {
|
||||
// public CodeCoverageTestRunner CreateCodeCoverageTestRunner()
|
||||
// {
|
||||
// return new CodeCoverageTestRunner();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public interface ICodeCoverageTestRunnerFactory |
||||
{ |
||||
CodeCoverageTestRunner CreateCodeCoverageTestRunner(); |
||||
} |
||||
} |
||||
//// 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;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage
|
||||
//{
|
||||
// public interface ICodeCoverageTestRunnerFactory
|
||||
// {
|
||||
// CodeCoverageTestRunner CreateCodeCoverageTestRunner();
|
||||
// }
|
||||
//}
|
||||
|
@ -1,237 +1,237 @@
@@ -1,237 +1,237 @@
|
||||
// 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.Generic; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.CodeCoverage; |
||||
using ICSharpCode.CodeCoverage.Tests.Utils; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageTestRunnerTests |
||||
{ |
||||
MockProcessRunner processRunner; |
||||
MockTestResultsMonitor testResultsMonitor; |
||||
UnitTestingOptions options; |
||||
DerivedCodeCoverageTestRunner testRunner; |
||||
MockFileSystem fileSystem; |
||||
MockMessageService messageService; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
processRunner = new MockProcessRunner(); |
||||
testResultsMonitor = new MockTestResultsMonitor(); |
||||
options = new UnitTestingOptions(new Properties()); |
||||
fileSystem = new MockFileSystem(); |
||||
messageService = new MockMessageService(); |
||||
testRunner = new DerivedCodeCoverageTestRunner(processRunner, testResultsMonitor, options, fileSystem, messageService); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateTestResultForTestFrameworkReturnsNUnitTestResult() |
||||
{ |
||||
TestResult testResult = new TestResult("abc"); |
||||
Assert.IsInstanceOf(typeof(NUnitTestResult), testRunner.CallCreateTestResultForTestFramework(testResult)); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasCodeCoverageResultsWhenCoverageFileExistsReturnsTrue() |
||||
{ |
||||
StartTestRunner(); |
||||
|
||||
fileSystem.FileExistsReturnValue = true; |
||||
|
||||
Assert.IsTrue(testRunner.HasCodeCoverageResults()); |
||||
} |
||||
|
||||
void StartTestRunner() |
||||
{ |
||||
FileUtility.ApplicationRootPath = @"d:\sharpdevelop"; |
||||
MockCSharpProject project = new MockCSharpProject(); |
||||
SelectedTests tests = new SelectedTests(project); |
||||
testRunner.Start(tests); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasCodeCoverageResultsWhenCoverageFileDoesNotExistsReturnsFalse() |
||||
{ |
||||
fileSystem.FileExistsReturnValue = false; |
||||
StartTestRunner(); |
||||
Assert.IsFalse(testRunner.HasCodeCoverageResults()); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasCodeCoverageResultsAfterTestRunChecksPassesCodeCoverageFileToFileExistsMethod() |
||||
{ |
||||
fileSystem.FileExistsReturnValue = false; |
||||
fileSystem.FileExistsPathParameter = null; |
||||
StartTestRunner(); |
||||
testRunner.HasCodeCoverageResults(); |
||||
|
||||
string expectedFileName = |
||||
@"c:\projects\MyTests\OpenCover\coverage.xml"; |
||||
|
||||
Assert.AreEqual(expectedFileName, fileSystem.FileExistsPathParameter); |
||||
} |
||||
|
||||
[Test] |
||||
public void ReadCodeCoverageResultsAfterTestRunChecksPassesCodeCoverageFileToCreateTextReaderMethod() |
||||
{ |
||||
StartTestRunner(); |
||||
|
||||
fileSystem.FileExistsReturnValue = true; |
||||
fileSystem.CreateTextReaderPathParameter = null; |
||||
fileSystem.CreateTextReaderReturnValue = new StringReader("<abc/>"); |
||||
|
||||
testRunner.ReadCodeCoverageResults(); |
||||
|
||||
string expectedFileName = |
||||
@"c:\projects\MyTests\OpenCover\coverage.xml"; |
||||
|
||||
Assert.AreEqual(expectedFileName, fileSystem.CreateTextReaderPathParameter); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetProcessStartInfoWhenTestResultsFileNameSetReturnsCommandLineWithTestResultsFileName() |
||||
{ |
||||
FileUtility.ApplicationRootPath = @"d:\sharpdevelop"; |
||||
testResultsMonitor.FileName = @"d:\temp\results.txt"; |
||||
|
||||
fileSystem.CreateTextReaderReturnValue = CreatePartCoverSettingsTextReader(); |
||||
fileSystem.FileExistsReturnValue = true; |
||||
|
||||
MockCSharpProject project = new MockCSharpProject(); |
||||
SelectedTests tests = new SelectedTests(project); |
||||
testRunner.Start(tests); |
||||
ProcessStartInfo processStartInfo = testRunner.CallGetProcessStartInfo(tests); |
||||
|
||||
string expectedCommandLine = |
||||
"-register:user -target:\"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + |
||||
"-targetdir:\"c:\\projects\\MyTests\\bin\\Debug\" " + |
||||
"-targetargs:\"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml /results=\\\"d:\\temp\\results.txt\\\"\" " + |
||||
"-output:\"c:\\projects\\MyTests\\OpenCover\\coverage.xml\" " + |
||||
"-filter:\"+[MyTests]* \""; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments); |
||||
} |
||||
|
||||
TextReader CreatePartCoverSettingsTextReader() |
||||
{ |
||||
OpenCoverSettings settings = new OpenCoverSettings(); |
||||
settings.Include.Add("[MyTests]*"); |
||||
StringBuilder text = new StringBuilder(); |
||||
StringWriter writer = new StringWriter(text); |
||||
settings.Save(writer); |
||||
|
||||
return new StringReader(text.ToString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void StartSetsProfilerEnvironmentVariableInProcessRunner() |
||||
{ |
||||
StartTestRunner(); |
||||
string environmentVariableValue = processRunner.EnvironmentVariables["COMPLUS_ProfAPI_ProfilerCompatibilitySetting"]; |
||||
Assert.AreEqual("EnableV2Profiler", environmentVariableValue); |
||||
} |
||||
|
||||
[Test] |
||||
public void StartWhenCodeCoverageResultsFileExistsDeletesExistingCodeCoverageResultsFile() |
||||
{ |
||||
fileSystem.FileExistsReturnValue = true; |
||||
fileSystem.CreateTextReaderReturnValue = new StringReader("<abc/>"); |
||||
StartTestRunner(); |
||||
|
||||
string expectedFileName = @"c:\projects\MyTests\OpenCover\coverage.xml"; |
||||
Assert.AreEqual(expectedFileName, fileSystem.DeleteFilePathParameter); |
||||
} |
||||
|
||||
[Test] |
||||
public void StartWhenCodeCoverageResultsFileDoesNotExistsCodeCoverageResultsFileIsNotDeleted() |
||||
{ |
||||
fileSystem.FileExistsReturnValue = false; |
||||
StartTestRunner(); |
||||
|
||||
Assert.IsNull(fileSystem.DeleteFilePathParameter); |
||||
} |
||||
|
||||
[Test] |
||||
public void StartCreatesDirectoryCodeCoverageResultsFileIfDoesNotExist() |
||||
{ |
||||
fileSystem.DirectoryExistsReturnValue = false; |
||||
StartTestRunner(); |
||||
|
||||
string expectedDirectory = @"c:\projects\MyTests\OpenCover"; |
||||
Assert.AreEqual(expectedDirectory, fileSystem.CreateDirectoryPathParameter); |
||||
} |
||||
|
||||
[Test] |
||||
public void StartChecksDirectoryForCodeCoverageResultsExists() |
||||
{ |
||||
fileSystem.DirectoryExistsReturnValue = true; |
||||
StartTestRunner(); |
||||
|
||||
string expectedDirectory = @"c:\projects\MyTests\OpenCover"; |
||||
Assert.AreEqual(expectedDirectory, fileSystem.DirectoryExistsPathParameter); |
||||
} |
||||
|
||||
[Test] |
||||
public void StartDoesNotCreateDirectoryForCodeCoverageResultsFileIfItExists() |
||||
{ |
||||
fileSystem.DirectoryExistsReturnValue = true; |
||||
StartTestRunner(); |
||||
|
||||
Assert.IsNull(fileSystem.CreateDirectoryPathParameter); |
||||
} |
||||
|
||||
[Test] |
||||
public void StartFiresMessagesReceivedEventTwice() |
||||
{ |
||||
List<string> messages = new List<string>(); |
||||
testRunner.MessageReceived += delegate(object o, MessageReceivedEventArgs e) { |
||||
messages.Add(e.Message); |
||||
}; |
||||
|
||||
testRunner.ParseStringReturnValue = "Running code coverage"; |
||||
StartTestRunner(); |
||||
|
||||
string[] expectedMessages = new string[] { |
||||
"Running code coverage", |
||||
GetCodeCoverageCommandLine() |
||||
}; |
||||
|
||||
Assert.AreEqual(expectedMessages, messages.ToArray()); |
||||
} |
||||
|
||||
string GetCodeCoverageCommandLine() |
||||
{ |
||||
return |
||||
"\"d:\\sharpdevelop\\bin\\Tools\\OpenCover\\OpenCover.Console.exe\" -register:user " + |
||||
"-target:\"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + |
||||
"-targetdir:\"c:\\projects\\MyTests\\bin\\Debug\" " + |
||||
"-targetargs:\"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " + |
||||
"-output:\"c:\\projects\\MyTests\\OpenCover\\coverage.xml\" " + |
||||
"-filter:\"+[*]* \""; |
||||
} |
||||
|
||||
[Test] |
||||
public void StartParsesTextForRunningCodeCoverageMessages() |
||||
{ |
||||
testRunner.ParseStringReturnValue = "Running code coverage"; |
||||
StartTestRunner(); |
||||
|
||||
string expectedStringResource = "${res:ICSharpCode.CodeCoverage.RunningCodeCoverage}"; |
||||
|
||||
Assert.AreEqual(expectedStringResource, testRunner.ParseStringParameter); |
||||
} |
||||
} |
||||
} |
||||
//// 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.Generic;
|
||||
//using System.Diagnostics;
|
||||
//using System.IO;
|
||||
//using System.Text;
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.CodeCoverage;
|
||||
//using ICSharpCode.CodeCoverage.Tests.Utils;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.UnitTesting;
|
||||
//using NUnit.Framework;
|
||||
//using UnitTesting.Tests.Utils;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage.Tests.Testing
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class CodeCoverageTestRunnerTests
|
||||
// {
|
||||
// MockProcessRunner processRunner;
|
||||
// MockTestResultsMonitor testResultsMonitor;
|
||||
// UnitTestingOptions options;
|
||||
// DerivedCodeCoverageTestRunner testRunner;
|
||||
// MockFileSystem fileSystem;
|
||||
// MockMessageService messageService;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// processRunner = new MockProcessRunner();
|
||||
// testResultsMonitor = new MockTestResultsMonitor();
|
||||
// options = new UnitTestingOptions(new Properties());
|
||||
// fileSystem = new MockFileSystem();
|
||||
// messageService = new MockMessageService();
|
||||
// testRunner = new DerivedCodeCoverageTestRunner(processRunner, testResultsMonitor, options, fileSystem, messageService);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CreateTestResultForTestFrameworkReturnsNUnitTestResult()
|
||||
// {
|
||||
// TestResult testResult = new TestResult("abc");
|
||||
// Assert.IsInstanceOf(typeof(NUnitTestResult), testRunner.CallCreateTestResultForTestFramework(testResult));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void HasCodeCoverageResultsWhenCoverageFileExistsReturnsTrue()
|
||||
// {
|
||||
// StartTestRunner();
|
||||
//
|
||||
// fileSystem.FileExistsReturnValue = true;
|
||||
//
|
||||
// Assert.IsTrue(testRunner.HasCodeCoverageResults());
|
||||
// }
|
||||
//
|
||||
// void StartTestRunner()
|
||||
// {
|
||||
// FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
|
||||
// MockCSharpProject project = new MockCSharpProject();
|
||||
// SelectedTests tests = new SelectedTests(project);
|
||||
// testRunner.Start(tests);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void HasCodeCoverageResultsWhenCoverageFileDoesNotExistsReturnsFalse()
|
||||
// {
|
||||
// fileSystem.FileExistsReturnValue = false;
|
||||
// StartTestRunner();
|
||||
// Assert.IsFalse(testRunner.HasCodeCoverageResults());
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void HasCodeCoverageResultsAfterTestRunChecksPassesCodeCoverageFileToFileExistsMethod()
|
||||
// {
|
||||
// fileSystem.FileExistsReturnValue = false;
|
||||
// fileSystem.FileExistsPathParameter = null;
|
||||
// StartTestRunner();
|
||||
// testRunner.HasCodeCoverageResults();
|
||||
//
|
||||
// string expectedFileName =
|
||||
// @"c:\projects\MyTests\OpenCover\coverage.xml";
|
||||
//
|
||||
// Assert.AreEqual(expectedFileName, fileSystem.FileExistsPathParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ReadCodeCoverageResultsAfterTestRunChecksPassesCodeCoverageFileToCreateTextReaderMethod()
|
||||
// {
|
||||
// StartTestRunner();
|
||||
//
|
||||
// fileSystem.FileExistsReturnValue = true;
|
||||
// fileSystem.CreateTextReaderPathParameter = null;
|
||||
// fileSystem.CreateTextReaderReturnValue = new StringReader("<abc/>");
|
||||
//
|
||||
// testRunner.ReadCodeCoverageResults();
|
||||
//
|
||||
// string expectedFileName =
|
||||
// @"c:\projects\MyTests\OpenCover\coverage.xml";
|
||||
//
|
||||
// Assert.AreEqual(expectedFileName, fileSystem.CreateTextReaderPathParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetProcessStartInfoWhenTestResultsFileNameSetReturnsCommandLineWithTestResultsFileName()
|
||||
// {
|
||||
// FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
|
||||
// testResultsMonitor.FileName = @"d:\temp\results.txt";
|
||||
//
|
||||
// fileSystem.CreateTextReaderReturnValue = CreatePartCoverSettingsTextReader();
|
||||
// fileSystem.FileExistsReturnValue = true;
|
||||
//
|
||||
// MockCSharpProject project = new MockCSharpProject();
|
||||
// SelectedTests tests = new SelectedTests(project);
|
||||
// testRunner.Start(tests);
|
||||
// ProcessStartInfo processStartInfo = testRunner.CallGetProcessStartInfo(tests);
|
||||
//
|
||||
// string expectedCommandLine =
|
||||
// "-register:user -target:\"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " +
|
||||
// "-targetdir:\"c:\\projects\\MyTests\\bin\\Debug\" " +
|
||||
// "-targetargs:\"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml /results=\\\"d:\\temp\\results.txt\\\"\" " +
|
||||
// "-output:\"c:\\projects\\MyTests\\OpenCover\\coverage.xml\" " +
|
||||
// "-filter:\"+[MyTests]* \"";
|
||||
//
|
||||
// Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments);
|
||||
// }
|
||||
//
|
||||
// TextReader CreatePartCoverSettingsTextReader()
|
||||
// {
|
||||
// OpenCoverSettings settings = new OpenCoverSettings();
|
||||
// settings.Include.Add("[MyTests]*");
|
||||
// StringBuilder text = new StringBuilder();
|
||||
// StringWriter writer = new StringWriter(text);
|
||||
// settings.Save(writer);
|
||||
//
|
||||
// return new StringReader(text.ToString());
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StartSetsProfilerEnvironmentVariableInProcessRunner()
|
||||
// {
|
||||
// StartTestRunner();
|
||||
// string environmentVariableValue = processRunner.EnvironmentVariables["COMPLUS_ProfAPI_ProfilerCompatibilitySetting"];
|
||||
// Assert.AreEqual("EnableV2Profiler", environmentVariableValue);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StartWhenCodeCoverageResultsFileExistsDeletesExistingCodeCoverageResultsFile()
|
||||
// {
|
||||
// fileSystem.FileExistsReturnValue = true;
|
||||
// fileSystem.CreateTextReaderReturnValue = new StringReader("<abc/>");
|
||||
// StartTestRunner();
|
||||
//
|
||||
// string expectedFileName = @"c:\projects\MyTests\OpenCover\coverage.xml";
|
||||
// Assert.AreEqual(expectedFileName, fileSystem.DeleteFilePathParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StartWhenCodeCoverageResultsFileDoesNotExistsCodeCoverageResultsFileIsNotDeleted()
|
||||
// {
|
||||
// fileSystem.FileExistsReturnValue = false;
|
||||
// StartTestRunner();
|
||||
//
|
||||
// Assert.IsNull(fileSystem.DeleteFilePathParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StartCreatesDirectoryCodeCoverageResultsFileIfDoesNotExist()
|
||||
// {
|
||||
// fileSystem.DirectoryExistsReturnValue = false;
|
||||
// StartTestRunner();
|
||||
//
|
||||
// string expectedDirectory = @"c:\projects\MyTests\OpenCover";
|
||||
// Assert.AreEqual(expectedDirectory, fileSystem.CreateDirectoryPathParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StartChecksDirectoryForCodeCoverageResultsExists()
|
||||
// {
|
||||
// fileSystem.DirectoryExistsReturnValue = true;
|
||||
// StartTestRunner();
|
||||
//
|
||||
// string expectedDirectory = @"c:\projects\MyTests\OpenCover";
|
||||
// Assert.AreEqual(expectedDirectory, fileSystem.DirectoryExistsPathParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StartDoesNotCreateDirectoryForCodeCoverageResultsFileIfItExists()
|
||||
// {
|
||||
// fileSystem.DirectoryExistsReturnValue = true;
|
||||
// StartTestRunner();
|
||||
//
|
||||
// Assert.IsNull(fileSystem.CreateDirectoryPathParameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StartFiresMessagesReceivedEventTwice()
|
||||
// {
|
||||
// List<string> messages = new List<string>();
|
||||
// testRunner.MessageReceived += delegate(object o, MessageReceivedEventArgs e) {
|
||||
// messages.Add(e.Message);
|
||||
// };
|
||||
//
|
||||
// testRunner.ParseStringReturnValue = "Running code coverage";
|
||||
// StartTestRunner();
|
||||
//
|
||||
// string[] expectedMessages = new string[] {
|
||||
// "Running code coverage",
|
||||
// GetCodeCoverageCommandLine()
|
||||
// };
|
||||
//
|
||||
// Assert.AreEqual(expectedMessages, messages.ToArray());
|
||||
// }
|
||||
//
|
||||
// string GetCodeCoverageCommandLine()
|
||||
// {
|
||||
// return
|
||||
// "\"d:\\sharpdevelop\\bin\\Tools\\OpenCover\\OpenCover.Console.exe\" -register:user " +
|
||||
// "-target:\"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " +
|
||||
// "-targetdir:\"c:\\projects\\MyTests\\bin\\Debug\" " +
|
||||
// "-targetargs:\"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " +
|
||||
// "-output:\"c:\\projects\\MyTests\\OpenCover\\coverage.xml\" " +
|
||||
// "-filter:\"+[*]* \"";
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void StartParsesTextForRunningCodeCoverageMessages()
|
||||
// {
|
||||
// testRunner.ParseStringReturnValue = "Running code coverage";
|
||||
// StartTestRunner();
|
||||
//
|
||||
// string expectedStringResource = "${res:ICSharpCode.CodeCoverage.RunningCodeCoverage}";
|
||||
//
|
||||
// Assert.AreEqual(expectedStringResource, testRunner.ParseStringParameter);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,272 +1,272 @@
@@ -1,272 +1,272 @@
|
||||
// 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.IO; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using ICSharpCode.CodeCoverage.Tests.Utils; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RunTestWithCodeCoverageCommandTests |
||||
{ |
||||
DerivedRunTestWithCodeCoverageCommand command; |
||||
MockRunTestCommandContext context; |
||||
MockCodeCoverageTestRunnerFactory mockCodeCoverageTestRunnerFactory; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
context = new MockRunTestCommandContext(); |
||||
mockCodeCoverageTestRunnerFactory = new MockCodeCoverageTestRunnerFactory(); |
||||
command = new DerivedRunTestWithCodeCoverageCommand(context, mockCodeCoverageTestRunnerFactory); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedCreatesNewMessageViewCategory() |
||||
{ |
||||
command.CodeCoverageMessageViewCategory = null; |
||||
command.CallOnBeforeRunTests(); |
||||
|
||||
Assert.AreEqual("CodeCoverage", command.CodeCoverageMessageViewCategory.Category); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedCreatesNewMessageViewCategoryWithCodeCoverageDisplayCategoryName() |
||||
{ |
||||
command.CodeCoverageMessageViewCategory = null; |
||||
command.ParsedStringToReturn = "Code Coverage"; |
||||
command.CallOnBeforeRunTests(); |
||||
|
||||
string expectedDisplayCategoryName = "Code Coverage"; |
||||
Assert.AreEqual(expectedDisplayCategoryName, command.CodeCoverageMessageViewCategory.DisplayCategory); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedPassedStringResourceToStringParser() |
||||
{ |
||||
command.CodeCoverageMessageViewCategory = null; |
||||
command.ParsedString = null; |
||||
command.CallOnBeforeRunTests(); |
||||
|
||||
string expectedStringResourceName = "${res:ICSharpCode.UnitTesting.CodeCoverage}"; |
||||
Assert.AreEqual(expectedStringResourceName, command.ParsedString); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnBeforeRunTestsWhenCodeCoverageMessageViewCreatedPreviouslyDoesNotCreateAnotherMessageView() |
||||
{ |
||||
MessageViewCategory view = new MessageViewCategory("Test"); |
||||
command.CodeCoverageMessageViewCategory = view; |
||||
command.CallOnBeforeRunTests(); |
||||
Assert.AreEqual(view, command.CodeCoverageMessageViewCategory); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnBeforeRunTestsClearsCodeCoverageMessageViewTextWithSafeAsyncCall() |
||||
{ |
||||
MessageViewCategory view = new MessageViewCategory("Test"); |
||||
view.AppendText("abc"); |
||||
command.CodeCoverageMessageViewCategory = view; |
||||
command.CallOnBeforeRunTests(); |
||||
|
||||
Assert.AreEqual(String.Empty, view.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnBeforeRunTestsClearsCodeCoverageResults() |
||||
{ |
||||
command.CallOnBeforeRunTests(); |
||||
|
||||
Action expectedAction = CodeCoverageService.ClearResults; |
||||
Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnAfterRunTestsWhenNoCriticalTestErrorsCodeCoveragePadIsShown() |
||||
{ |
||||
context.MockTaskService.HasCriticalErrorsReturnValue = false; |
||||
PadDescriptor padDescriptor = AddCodeCoveragePadToMockWorkbench(); |
||||
command.CallOnAfterRunTests(); |
||||
|
||||
Action expectedAction = padDescriptor.BringPadToFront; |
||||
Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]); |
||||
} |
||||
|
||||
PadDescriptor AddCodeCoveragePadToMockWorkbench() |
||||
{ |
||||
PadDescriptor padDescriptor = new PadDescriptor(typeof(CodeCoveragePad), "Code Coverage", String.Empty); |
||||
context.MockUnitTestWorkbench.AddPadDescriptor(padDescriptor); |
||||
return padDescriptor; |
||||
} |
||||
|
||||
[Test] |
||||
public void OnAfterRunTestsWhenCriticalErrorsCodeCoveragePadIsNotShown() |
||||
{ |
||||
context.MockTaskService.HasCriticalErrorsReturnValue = true; |
||||
PadDescriptor padDescriptor = AddCodeCoveragePadToMockWorkbench(); |
||||
command.CallOnAfterRunTests(); |
||||
|
||||
Assert.AreEqual(0, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnAfterRunTestsDoesNotTreatWarningsAsErrors() |
||||
{ |
||||
context.MockTaskService.TreatWarningsAsErrorsParameterPassedToHasCriticalErrors = true; |
||||
AddCodeCoveragePadToMockWorkbench(); |
||||
command.CallOnAfterRunTests(); |
||||
|
||||
Assert.IsFalse(context.MockTaskService.TreatWarningsAsErrorsParameterPassedToHasCriticalErrors); |
||||
} |
||||
|
||||
[Test] |
||||
public void MessageReceivedFromTestRunnerIsAddedToCodeCoverageMessageViewNotUnitTestsMessageView() |
||||
{ |
||||
command.CodeCoverageMessageViewCategory = null; |
||||
MessageReceivedEventArgs e = new MessageReceivedEventArgs("test"); |
||||
command.CallTestRunnerMessageReceived(this, e); |
||||
string expectedText = "test\r\n"; |
||||
Assert.AreEqual(expectedText, command.CodeCoverageMessageViewCategory.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateTestRunnerCreatesNewCodeCoverageTestRunner() |
||||
{ |
||||
CodeCoverageTestRunner expectedTestRunner = mockCodeCoverageTestRunnerFactory.TestRunner; |
||||
Assert.AreEqual(expectedTestRunner, command.CallCreateTestRunner(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeDisplayed() |
||||
{ |
||||
ActionArguments<CodeCoverageResults> actionArgs = |
||||
CreateTestRunnerAndFireCodeCoverageProcessExitEvent(); |
||||
|
||||
Action<CodeCoverageResults> expectedAction = CodeCoverageService.ShowResults; |
||||
Assert.AreEqual(expectedAction, actionArgs.Action); |
||||
} |
||||
|
||||
ActionArguments<CodeCoverageResults> CreateTestRunnerAndFireCodeCoverageProcessExitEvent() |
||||
{ |
||||
command.CallCreateTestRunner(null); |
||||
MockCSharpProject project = new MockCSharpProject(); |
||||
SelectedTests tests = new SelectedTests(project); |
||||
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true; |
||||
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>"); |
||||
mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests); |
||||
|
||||
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = CreateCodeCoverageResultsTextReader(); |
||||
|
||||
mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent(); |
||||
|
||||
object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0]; |
||||
return (ActionArguments<CodeCoverageResults>)actionArgsAsObject; |
||||
} |
||||
|
||||
[Test] |
||||
public void CodeCoverageResultsFromXmlHasModuleCalledMyTests() |
||||
{ |
||||
CodeCoverageResults results = CreateCodeCoverageResults(); |
||||
string expectedName = "MyTests"; |
||||
Assert.AreEqual(expectedName, results.Modules[0].Name); |
||||
} |
||||
|
||||
CodeCoverageResults CreateCodeCoverageResults() |
||||
{ |
||||
TextReader reader = CreateCodeCoverageResultsTextReader(); |
||||
return new CodeCoverageResults(reader); |
||||
} |
||||
|
||||
TextReader CreateCodeCoverageResultsTextReader() |
||||
{ |
||||
string xml = |
||||
"<CoverageSession xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" + |
||||
" <Modules>\r\n" + |
||||
" <Module hash=\"44-54-B6-13-97-49-45-F8-6A-74-9E-49-0C-77-87-C6-9C-54-47-7A\">\r\n" + |
||||
" <FullName>C:\\Projects\\MyTests\\bin\\MyTests.DLL</FullName>\r\n" + |
||||
" <ModuleName>MyTests</ModuleName>\r\n" + |
||||
" <Files>\r\n" + |
||||
" <File uid=\"1\" fullPath=\"c:\\Projects\\MyTests\\MyTestFixture.cs\" />\r\n" + |
||||
" </Files>\r\n" + |
||||
" <Classes>\r\n" + |
||||
" <Class>\r\n" + |
||||
" <FullName>MyTests.Tests.MyTestFixture</FullName>\r\n" + |
||||
" <Methods>\r\n" + |
||||
" <Method visited=\"true\" cyclomaticComplexity=\"1\" sequenceCoverage=\"100\" branchCoverage=\"100\" isConstructor=\"false\" isStatic=\"false\" isGetter=\"false\" isSetter=\"false\">\r\n" + |
||||
" <MetadataToken>100663297</MetadataToken>\r\n" + |
||||
" <Name>System.Void MyTests.Tests.MyTestFixture::SimpleTest1()</Name>\r\n" + |
||||
" <FileRef uid=\"1\" />\r\n" + |
||||
" <SequencePoints>\r\n" + |
||||
" <SequencePoint vc='12' sl='20' sc='3' el='20' ec='4'/>\r\n" + |
||||
" </SequencePoints>\r\n" + |
||||
" </Method>\r\n" + |
||||
" </Methods>\r\n" + |
||||
" </Class>\r\n" + |
||||
" </Classes>\r\n" + |
||||
" </Module>\r\n" + |
||||
" </Modules>\r\n" + |
||||
"</CoverageSession>"; |
||||
|
||||
return new StringReader(xml); |
||||
} |
||||
|
||||
[Test] |
||||
public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeReadFromFile() |
||||
{ |
||||
ActionArguments<CodeCoverageResults> actionArgs = |
||||
CreateTestRunnerAndFireCodeCoverageProcessExitEvent(); |
||||
|
||||
CodeCoverageResults result = actionArgs.Arg; |
||||
Assert.AreEqual("MyTests", result.Modules[0].Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsTaskToTaskList() |
||||
{ |
||||
ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced(); |
||||
Action<Task> expectedAction = context.MockTaskService.Add; |
||||
Assert.AreEqual(expectedAction, args.Action); |
||||
} |
||||
|
||||
ActionArguments<Task> CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced() |
||||
{ |
||||
command.CallCreateTestRunner(null); |
||||
|
||||
MockCSharpProject project = new MockCSharpProject(); |
||||
SelectedTests tests = new SelectedTests(project); |
||||
|
||||
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true; |
||||
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>"); |
||||
mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests); |
||||
|
||||
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = false; |
||||
mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent(); |
||||
|
||||
object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0]; |
||||
return (ActionArguments<Task>)actionArgsAsObject; |
||||
} |
||||
|
||||
[Test] |
||||
public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsErrorTaskToTaskList() |
||||
{ |
||||
command.ParsedStringToReturn = "No code coverage results file generated."; |
||||
ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced(); |
||||
Task task = args.Arg; |
||||
|
||||
string description = @"No code coverage results file generated. c:\projects\MyTests\OpenCover\coverage.xml"; |
||||
int column = 1; |
||||
int line = 1; |
||||
Task expectedTask = new Task(null, description, column, line, TaskType.Error); |
||||
|
||||
TaskComparison comparison = new TaskComparison(expectedTask, task); |
||||
|
||||
Assert.IsTrue(comparison.IsMatch, comparison.MismatchReason); |
||||
} |
||||
} |
||||
} |
||||
//// 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.IO;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.SharpDevelop.Gui;
|
||||
//using ICSharpCode.UnitTesting;
|
||||
//using NUnit.Framework;
|
||||
//using ICSharpCode.CodeCoverage.Tests.Utils;
|
||||
//using UnitTesting.Tests.Utils;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage.Tests.Testing
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class RunTestWithCodeCoverageCommandTests
|
||||
// {
|
||||
// DerivedRunTestWithCodeCoverageCommand command;
|
||||
// MockRunTestCommandContext context;
|
||||
// MockCodeCoverageTestRunnerFactory mockCodeCoverageTestRunnerFactory;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// context = new MockRunTestCommandContext();
|
||||
// mockCodeCoverageTestRunnerFactory = new MockCodeCoverageTestRunnerFactory();
|
||||
// command = new DerivedRunTestWithCodeCoverageCommand(context, mockCodeCoverageTestRunnerFactory);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedCreatesNewMessageViewCategory()
|
||||
// {
|
||||
// command.CodeCoverageMessageViewCategory = null;
|
||||
// command.CallOnBeforeRunTests();
|
||||
//
|
||||
// Assert.AreEqual("CodeCoverage", command.CodeCoverageMessageViewCategory.Category);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedCreatesNewMessageViewCategoryWithCodeCoverageDisplayCategoryName()
|
||||
// {
|
||||
// command.CodeCoverageMessageViewCategory = null;
|
||||
// command.ParsedStringToReturn = "Code Coverage";
|
||||
// command.CallOnBeforeRunTests();
|
||||
//
|
||||
// string expectedDisplayCategoryName = "Code Coverage";
|
||||
// Assert.AreEqual(expectedDisplayCategoryName, command.CodeCoverageMessageViewCategory.DisplayCategory);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnBeforeRunTestsWhenNoCodeCoverageMessageViewCreatedPassedStringResourceToStringParser()
|
||||
// {
|
||||
// command.CodeCoverageMessageViewCategory = null;
|
||||
// command.ParsedString = null;
|
||||
// command.CallOnBeforeRunTests();
|
||||
//
|
||||
// string expectedStringResourceName = "${res:ICSharpCode.UnitTesting.CodeCoverage}";
|
||||
// Assert.AreEqual(expectedStringResourceName, command.ParsedString);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnBeforeRunTestsWhenCodeCoverageMessageViewCreatedPreviouslyDoesNotCreateAnotherMessageView()
|
||||
// {
|
||||
// MessageViewCategory view = new MessageViewCategory("Test");
|
||||
// command.CodeCoverageMessageViewCategory = view;
|
||||
// command.CallOnBeforeRunTests();
|
||||
// Assert.AreEqual(view, command.CodeCoverageMessageViewCategory);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnBeforeRunTestsClearsCodeCoverageMessageViewTextWithSafeAsyncCall()
|
||||
// {
|
||||
// MessageViewCategory view = new MessageViewCategory("Test");
|
||||
// view.AppendText("abc");
|
||||
// command.CodeCoverageMessageViewCategory = view;
|
||||
// command.CallOnBeforeRunTests();
|
||||
//
|
||||
// Assert.AreEqual(String.Empty, view.Text);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnBeforeRunTestsClearsCodeCoverageResults()
|
||||
// {
|
||||
// command.CallOnBeforeRunTests();
|
||||
//
|
||||
// Action expectedAction = CodeCoverageService.ClearResults;
|
||||
// Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnAfterRunTestsWhenNoCriticalTestErrorsCodeCoveragePadIsShown()
|
||||
// {
|
||||
// context.MockTaskService.HasCriticalErrorsReturnValue = false;
|
||||
// PadDescriptor padDescriptor = AddCodeCoveragePadToMockWorkbench();
|
||||
// command.CallOnAfterRunTests();
|
||||
//
|
||||
// Action expectedAction = padDescriptor.BringPadToFront;
|
||||
// Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]);
|
||||
// }
|
||||
//
|
||||
// PadDescriptor AddCodeCoveragePadToMockWorkbench()
|
||||
// {
|
||||
// PadDescriptor padDescriptor = new PadDescriptor(typeof(CodeCoveragePad), "Code Coverage", String.Empty);
|
||||
// context.MockUnitTestWorkbench.AddPadDescriptor(padDescriptor);
|
||||
// return padDescriptor;
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnAfterRunTestsWhenCriticalErrorsCodeCoveragePadIsNotShown()
|
||||
// {
|
||||
// context.MockTaskService.HasCriticalErrorsReturnValue = true;
|
||||
// PadDescriptor padDescriptor = AddCodeCoveragePadToMockWorkbench();
|
||||
// command.CallOnAfterRunTests();
|
||||
//
|
||||
// Assert.AreEqual(0, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OnAfterRunTestsDoesNotTreatWarningsAsErrors()
|
||||
// {
|
||||
// context.MockTaskService.TreatWarningsAsErrorsParameterPassedToHasCriticalErrors = true;
|
||||
// AddCodeCoveragePadToMockWorkbench();
|
||||
// command.CallOnAfterRunTests();
|
||||
//
|
||||
// Assert.IsFalse(context.MockTaskService.TreatWarningsAsErrorsParameterPassedToHasCriticalErrors);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MessageReceivedFromTestRunnerIsAddedToCodeCoverageMessageViewNotUnitTestsMessageView()
|
||||
// {
|
||||
// command.CodeCoverageMessageViewCategory = null;
|
||||
// MessageReceivedEventArgs e = new MessageReceivedEventArgs("test");
|
||||
// command.CallTestRunnerMessageReceived(this, e);
|
||||
// string expectedText = "test\r\n";
|
||||
// Assert.AreEqual(expectedText, command.CodeCoverageMessageViewCategory.Text);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CreateTestRunnerCreatesNewCodeCoverageTestRunner()
|
||||
// {
|
||||
// CodeCoverageTestRunner expectedTestRunner = mockCodeCoverageTestRunnerFactory.TestRunner;
|
||||
// Assert.AreEqual(expectedTestRunner, command.CallCreateTestRunner(null));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeDisplayed()
|
||||
// {
|
||||
// ActionArguments<CodeCoverageResults> actionArgs =
|
||||
// CreateTestRunnerAndFireCodeCoverageProcessExitEvent();
|
||||
//
|
||||
// Action<CodeCoverageResults> expectedAction = CodeCoverageService.ShowResults;
|
||||
// Assert.AreEqual(expectedAction, actionArgs.Action);
|
||||
// }
|
||||
//
|
||||
// ActionArguments<CodeCoverageResults> CreateTestRunnerAndFireCodeCoverageProcessExitEvent()
|
||||
// {
|
||||
// command.CallCreateTestRunner(null);
|
||||
// MockCSharpProject project = new MockCSharpProject();
|
||||
// SelectedTests tests = new SelectedTests(project);
|
||||
// mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
|
||||
// mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>");
|
||||
// mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests);
|
||||
//
|
||||
// mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = CreateCodeCoverageResultsTextReader();
|
||||
//
|
||||
// mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent();
|
||||
//
|
||||
// object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0];
|
||||
// return (ActionArguments<CodeCoverageResults>)actionArgsAsObject;
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CodeCoverageResultsFromXmlHasModuleCalledMyTests()
|
||||
// {
|
||||
// CodeCoverageResults results = CreateCodeCoverageResults();
|
||||
// string expectedName = "MyTests";
|
||||
// Assert.AreEqual(expectedName, results.Modules[0].Name);
|
||||
// }
|
||||
//
|
||||
// CodeCoverageResults CreateCodeCoverageResults()
|
||||
// {
|
||||
// TextReader reader = CreateCodeCoverageResultsTextReader();
|
||||
// return new CodeCoverageResults(reader);
|
||||
// }
|
||||
//
|
||||
// TextReader CreateCodeCoverageResultsTextReader()
|
||||
// {
|
||||
// string xml =
|
||||
// "<CoverageSession xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" +
|
||||
// " <Modules>\r\n" +
|
||||
// " <Module hash=\"44-54-B6-13-97-49-45-F8-6A-74-9E-49-0C-77-87-C6-9C-54-47-7A\">\r\n" +
|
||||
// " <FullName>C:\\Projects\\MyTests\\bin\\MyTests.DLL</FullName>\r\n" +
|
||||
// " <ModuleName>MyTests</ModuleName>\r\n" +
|
||||
// " <Files>\r\n" +
|
||||
// " <File uid=\"1\" fullPath=\"c:\\Projects\\MyTests\\MyTestFixture.cs\" />\r\n" +
|
||||
// " </Files>\r\n" +
|
||||
// " <Classes>\r\n" +
|
||||
// " <Class>\r\n" +
|
||||
// " <FullName>MyTests.Tests.MyTestFixture</FullName>\r\n" +
|
||||
// " <Methods>\r\n" +
|
||||
// " <Method visited=\"true\" cyclomaticComplexity=\"1\" sequenceCoverage=\"100\" branchCoverage=\"100\" isConstructor=\"false\" isStatic=\"false\" isGetter=\"false\" isSetter=\"false\">\r\n" +
|
||||
// " <MetadataToken>100663297</MetadataToken>\r\n" +
|
||||
// " <Name>System.Void MyTests.Tests.MyTestFixture::SimpleTest1()</Name>\r\n" +
|
||||
// " <FileRef uid=\"1\" />\r\n" +
|
||||
// " <SequencePoints>\r\n" +
|
||||
// " <SequencePoint vc='12' sl='20' sc='3' el='20' ec='4'/>\r\n" +
|
||||
// " </SequencePoints>\r\n" +
|
||||
// " </Method>\r\n" +
|
||||
// " </Methods>\r\n" +
|
||||
// " </Class>\r\n" +
|
||||
// " </Classes>\r\n" +
|
||||
// " </Module>\r\n" +
|
||||
// " </Modules>\r\n" +
|
||||
// "</CoverageSession>";
|
||||
//
|
||||
// return new StringReader(xml);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeReadFromFile()
|
||||
// {
|
||||
// ActionArguments<CodeCoverageResults> actionArgs =
|
||||
// CreateTestRunnerAndFireCodeCoverageProcessExitEvent();
|
||||
//
|
||||
// CodeCoverageResults result = actionArgs.Arg;
|
||||
// Assert.AreEqual("MyTests", result.Modules[0].Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsTaskToTaskList()
|
||||
// {
|
||||
// ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced();
|
||||
// Action<Task> expectedAction = context.MockTaskService.Add;
|
||||
// Assert.AreEqual(expectedAction, args.Action);
|
||||
// }
|
||||
//
|
||||
// ActionArguments<Task> CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced()
|
||||
// {
|
||||
// command.CallCreateTestRunner(null);
|
||||
//
|
||||
// MockCSharpProject project = new MockCSharpProject();
|
||||
// SelectedTests tests = new SelectedTests(project);
|
||||
//
|
||||
// mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
|
||||
// mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>");
|
||||
// mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests);
|
||||
//
|
||||
// mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = false;
|
||||
// mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent();
|
||||
//
|
||||
// object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0];
|
||||
// return (ActionArguments<Task>)actionArgsAsObject;
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsErrorTaskToTaskList()
|
||||
// {
|
||||
// command.ParsedStringToReturn = "No code coverage results file generated.";
|
||||
// ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced();
|
||||
// Task task = args.Arg;
|
||||
//
|
||||
// string description = @"No code coverage results file generated. c:\projects\MyTests\OpenCover\coverage.xml";
|
||||
// int column = 1;
|
||||
// int line = 1;
|
||||
// Task expectedTask = new Task(null, description, column, line, TaskType.Error);
|
||||
//
|
||||
// TaskComparison comparison = new TaskComparison(expectedTask, task);
|
||||
//
|
||||
// Assert.IsTrue(comparison.IsMatch, comparison.MismatchReason);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,41 +1,41 @@
@@ -1,41 +1,41 @@
|
||||
// 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.Diagnostics; |
||||
using ICSharpCode.CodeCoverage; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests.Utils |
||||
{ |
||||
public class DerivedCodeCoverageTestRunner : CodeCoverageTestRunner |
||||
{ |
||||
public string ParseStringReturnValue; |
||||
public string ParseStringParameter; |
||||
|
||||
public DerivedCodeCoverageTestRunner(IUnitTestProcessRunner processRunner, |
||||
ITestResultsMonitor testResultsMonitor, |
||||
UnitTestingOptions options, |
||||
IFileSystem fileSystem, |
||||
IUnitTestMessageService messageService) |
||||
: base(new CodeCoverageTestRunnerContext(processRunner, testResultsMonitor, fileSystem, messageService, options)) |
||||
{ |
||||
} |
||||
|
||||
public ProcessStartInfo CallGetProcessStartInfo(SelectedTests selectedTests) |
||||
{ |
||||
return base.GetProcessStartInfo(selectedTests); |
||||
} |
||||
|
||||
public TestResult CallCreateTestResultForTestFramework(TestResult testResult) |
||||
{ |
||||
return base.CreateTestResultForTestFramework(testResult); |
||||
} |
||||
|
||||
protected override string ParseString(string text) |
||||
{ |
||||
ParseStringParameter = text; |
||||
return ParseStringReturnValue; |
||||
} |
||||
} |
||||
} |
||||
//// 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.Diagnostics;
|
||||
//using ICSharpCode.CodeCoverage;
|
||||
//using ICSharpCode.UnitTesting;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage.Tests.Utils
|
||||
//{
|
||||
// public class DerivedCodeCoverageTestRunner : CodeCoverageTestRunner
|
||||
// {
|
||||
// public string ParseStringReturnValue;
|
||||
// public string ParseStringParameter;
|
||||
//
|
||||
// public DerivedCodeCoverageTestRunner(IUnitTestProcessRunner processRunner,
|
||||
// ITestResultsMonitor testResultsMonitor,
|
||||
// UnitTestingOptions options,
|
||||
// IFileSystem fileSystem,
|
||||
// IUnitTestMessageService messageService)
|
||||
// : base(new CodeCoverageTestRunnerContext(processRunner, testResultsMonitor, fileSystem, messageService, options))
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public ProcessStartInfo CallGetProcessStartInfo(SelectedTests selectedTests)
|
||||
// {
|
||||
// return base.GetProcessStartInfo(selectedTests);
|
||||
// }
|
||||
//
|
||||
// public TestResult CallCreateTestResultForTestFramework(TestResult testResult)
|
||||
// {
|
||||
// return base.CreateTestResultForTestFramework(testResult);
|
||||
// }
|
||||
//
|
||||
// protected override string ParseString(string text)
|
||||
// {
|
||||
// ParseStringParameter = text;
|
||||
// return ParseStringReturnValue;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,59 +1,59 @@
@@ -1,59 +1,59 @@
|
||||
// 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.CodeCoverage; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests.Utils |
||||
{ |
||||
public class DerivedRunTestWithCodeCoverageCommand : RunTestWithCodeCoverageCommand |
||||
{ |
||||
public string ParsedStringToReturn = String.Empty; |
||||
public string ParsedString; |
||||
|
||||
public DerivedRunTestWithCodeCoverageCommand(IRunTestCommandContext context, |
||||
ICodeCoverageTestRunnerFactory factory) |
||||
: base(context, factory) |
||||
{ |
||||
} |
||||
|
||||
public void CallOnBeforeRunTests() |
||||
{ |
||||
base.OnBeforeRunTests(); |
||||
} |
||||
|
||||
public void CallOnAfterRunTests() |
||||
{ |
||||
base.OnAfterRunTests(); |
||||
} |
||||
|
||||
protected override MessageViewCategory CreateMessageViewCategory(string category, string displayCategory) |
||||
{ |
||||
return new MessageViewCategory(category, displayCategory); |
||||
} |
||||
|
||||
public MessageViewCategory CodeCoverageMessageViewCategory { |
||||
get { return base.Category; } |
||||
set { base.Category = value;} |
||||
} |
||||
|
||||
protected override string StringParse(string text) |
||||
{ |
||||
ParsedString = text; |
||||
return ParsedStringToReturn; |
||||
} |
||||
|
||||
public void CallTestRunnerMessageReceived(object source, MessageReceivedEventArgs e) |
||||
{ |
||||
base.TestRunnerMessageReceived(source, e); |
||||
} |
||||
|
||||
public ITestRunner CallCreateTestRunner(IProject project) |
||||
{ |
||||
return base.CreateTestRunner(project); |
||||
} |
||||
} |
||||
} |
||||
//// 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.CodeCoverage;
|
||||
//using ICSharpCode.SharpDevelop.Gui;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//using ICSharpCode.UnitTesting;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage.Tests.Utils
|
||||
//{
|
||||
// public class DerivedRunTestWithCodeCoverageCommand : RunTestWithCodeCoverageCommand
|
||||
// {
|
||||
// public string ParsedStringToReturn = String.Empty;
|
||||
// public string ParsedString;
|
||||
//
|
||||
// public DerivedRunTestWithCodeCoverageCommand(IRunTestCommandContext context,
|
||||
// ICodeCoverageTestRunnerFactory factory)
|
||||
// : base(context, factory)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public void CallOnBeforeRunTests()
|
||||
// {
|
||||
// base.OnBeforeRunTests();
|
||||
// }
|
||||
//
|
||||
// public void CallOnAfterRunTests()
|
||||
// {
|
||||
// base.OnAfterRunTests();
|
||||
// }
|
||||
//
|
||||
// protected override MessageViewCategory CreateMessageViewCategory(string category, string displayCategory)
|
||||
// {
|
||||
// return new MessageViewCategory(category, displayCategory);
|
||||
// }
|
||||
//
|
||||
// public MessageViewCategory CodeCoverageMessageViewCategory {
|
||||
// get { return base.Category; }
|
||||
// set { base.Category = value;}
|
||||
// }
|
||||
//
|
||||
// protected override string StringParse(string text)
|
||||
// {
|
||||
// ParsedString = text;
|
||||
// return ParsedStringToReturn;
|
||||
// }
|
||||
//
|
||||
// public void CallTestRunnerMessageReceived(object source, MessageReceivedEventArgs e)
|
||||
// {
|
||||
// base.TestRunnerMessageReceived(source, e);
|
||||
// }
|
||||
//
|
||||
// public ITestRunner CallCreateTestRunner(IProject project)
|
||||
// {
|
||||
// return base.CreateTestRunner(project);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,40 +1,40 @@
@@ -1,40 +1,40 @@
|
||||
// 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.CodeCoverage; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.UnitTesting; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests.Utils |
||||
{ |
||||
public class MockCodeCoverageTestRunnerFactory : ICodeCoverageTestRunnerFactory |
||||
{ |
||||
public MockProcessRunner ProcessRunner; |
||||
public MockTestResultsMonitor TestResultsMonitor; |
||||
public UnitTestingOptions Options; |
||||
public CodeCoverageTestRunner TestRunner; |
||||
public MockFileSystem FileSystem; |
||||
public MockMessageService MessageService; |
||||
|
||||
public MockCodeCoverageTestRunnerFactory() |
||||
{ |
||||
ProcessRunner = new MockProcessRunner(); |
||||
TestResultsMonitor = new MockTestResultsMonitor(); |
||||
Options = new UnitTestingOptions(new Properties()); |
||||
FileSystem = new MockFileSystem(); |
||||
CodeCoverageTestRunnerContext context = new CodeCoverageTestRunnerContext(ProcessRunner, |
||||
TestResultsMonitor, |
||||
FileSystem, |
||||
MessageService, |
||||
Options); |
||||
TestRunner = new CodeCoverageTestRunner(context); |
||||
} |
||||
|
||||
public CodeCoverageTestRunner CreateCodeCoverageTestRunner() |
||||
{ |
||||
return TestRunner; |
||||
} |
||||
} |
||||
} |
||||
//// 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.CodeCoverage;
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.UnitTesting;
|
||||
//using UnitTesting.Tests.Utils;
|
||||
//
|
||||
//namespace ICSharpCode.CodeCoverage.Tests.Utils
|
||||
//{
|
||||
// public class MockCodeCoverageTestRunnerFactory : ICodeCoverageTestRunnerFactory
|
||||
// {
|
||||
// public MockProcessRunner ProcessRunner;
|
||||
// public MockTestResultsMonitor TestResultsMonitor;
|
||||
// public UnitTestingOptions Options;
|
||||
// public CodeCoverageTestRunner TestRunner;
|
||||
// public MockFileSystem FileSystem;
|
||||
// public MockMessageService MessageService;
|
||||
//
|
||||
// public MockCodeCoverageTestRunnerFactory()
|
||||
// {
|
||||
// ProcessRunner = new MockProcessRunner();
|
||||
// TestResultsMonitor = new MockTestResultsMonitor();
|
||||
// Options = new UnitTestingOptions(new Properties());
|
||||
// FileSystem = new MockFileSystem();
|
||||
// CodeCoverageTestRunnerContext context = new CodeCoverageTestRunnerContext(ProcessRunner,
|
||||
// TestResultsMonitor,
|
||||
// FileSystem,
|
||||
// MessageService,
|
||||
// Options);
|
||||
// TestRunner = new CodeCoverageTestRunner(context);
|
||||
// }
|
||||
//
|
||||
// public CodeCoverageTestRunner CreateCodeCoverageTestRunner()
|
||||
// {
|
||||
// return TestRunner;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,43 +0,0 @@
@@ -1,43 +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.Windows.Input; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class DelegateCommand : ICommand |
||||
{ |
||||
Action<object> execute; |
||||
Predicate<object> canExecute; |
||||
|
||||
public DelegateCommand(Action<object> execute, Predicate<object> canExecute) |
||||
{ |
||||
this.execute = execute; |
||||
this.canExecute = canExecute; |
||||
} |
||||
|
||||
public DelegateCommand(Action<object> execute) |
||||
: this(execute, null) |
||||
{ |
||||
} |
||||
|
||||
public event EventHandler CanExecuteChanged { |
||||
add { CommandManager.RequerySuggested += value; } |
||||
remove { CommandManager.RequerySuggested -= value; } |
||||
} |
||||
|
||||
public void Execute(object parameter) |
||||
{ |
||||
execute(parameter); |
||||
} |
||||
|
||||
public bool CanExecute(object parameter) |
||||
{ |
||||
if (canExecute != null) { |
||||
return canExecute(parameter); |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,340 @@
@@ -0,0 +1,340 @@
|
||||
// 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 CSharpBinding.Completion; |
||||
using CSharpBinding.Parser; |
||||
using CSharpBinding.Refactoring; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.NRefactory.TypeSystem.Implementation; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||
using System; |
||||
using System.Linq; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Parser; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using NUnit.Framework; |
||||
using Rhino.Mocks; |
||||
|
||||
namespace CSharpBinding.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CSharpCodeGeneratorTests |
||||
{ |
||||
string program = @"using System;
|
||||
using System.Reflection; |
||||
|
||||
[assembly: AssemblyTitle(""CSharpBinding.Tests"")] |
||||
|
||||
class MySimpleAttribute : Attribute {} |
||||
|
||||
class TargetClass |
||||
{ |
||||
void TargetA() |
||||
{ |
||||
} |
||||
|
||||
public int TargetB { get; set; } |
||||
|
||||
public int TargetC_ { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
interface TargetInterface |
||||
{ |
||||
} |
||||
";
|
||||
|
||||
MockTextEditor textEditor; |
||||
CSharpCodeGenerator gen; |
||||
|
||||
static readonly IUnresolvedAssembly Corlib = new CecilLoader().LoadAssemblyFile(typeof(object).Assembly.Location); |
||||
|
||||
[SetUp] |
||||
public void SetUp() |
||||
{ |
||||
SD.InitializeForUnitTests(); |
||||
textEditor = new MockTextEditor(); |
||||
textEditor.Document.Text = program; |
||||
var parseInfo = textEditor.CreateParseInformation(); |
||||
IProject project = MockRepository.GenerateStrictMock<IProject>(); |
||||
var pc = new CSharpProjectContent().AddOrUpdateFiles(parseInfo.UnresolvedFile); |
||||
pc = pc.AddAssemblyReferences(new[] { Corlib }); |
||||
var compilation = pc.CreateCompilation(); |
||||
SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStrictMock<IParserService>()); |
||||
|
||||
SD.ParserService.Stub(p => p.GetCachedParseInformation(textEditor.FileName)).Return(parseInfo); |
||||
SD.ParserService.Stub(p => p.GetCompilation(project)).Return(compilation); |
||||
SD.ParserService.Stub(p => p.GetCompilationForFile(textEditor.FileName)).Return(compilation); |
||||
SD.ParserService.Stub(p => p.Parse(textEditor.FileName, textEditor.Document)).WhenCalled( |
||||
i => { |
||||
var syntaxTree = new CSharpParser().Parse(textEditor.Document, textEditor.FileName); |
||||
i.ReturnValue = new CSharpFullParseInformation(syntaxTree.ToTypeSystem(), null, syntaxTree); |
||||
}).Return(parseInfo); // fake Return to make it work
|
||||
SD.Services.AddService(typeof(IFileService), MockRepository.GenerateStrictMock<IFileService>()); |
||||
IViewContent view = MockRepository.GenerateStrictMock<IViewContent>(); |
||||
view.Stub(v => v.GetService(typeof(ITextEditor))).Return(textEditor); |
||||
SD.FileService.Stub(f => f.OpenFile(textEditor.FileName, false)).Return(view); |
||||
gen = new CSharpCodeGenerator(project); |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
SD.TearDownForUnitTests(); |
||||
} |
||||
|
||||
[Test] |
||||
public void AddSimpleAttributeToClass() |
||||
{ |
||||
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName); |
||||
var entity = FindEntity<ITypeDefinition>("TargetClass"); |
||||
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute")); |
||||
gen.AddAttribute(entity, new DefaultAttribute(attribute)); |
||||
|
||||
Assert.AreEqual(@"using System;
|
||||
using System.Reflection; |
||||
|
||||
[assembly: AssemblyTitle(""CSharpBinding.Tests"")] |
||||
|
||||
class MySimpleAttribute : Attribute {} |
||||
|
||||
[MySimple] |
||||
class TargetClass |
||||
{ |
||||
void TargetA() |
||||
{ |
||||
} |
||||
|
||||
public int TargetB { get; set; } |
||||
|
||||
public int TargetC_ { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
interface TargetInterface |
||||
{ |
||||
} |
||||
", textEditor.Document.Text);
|
||||
} |
||||
|
||||
[Test] |
||||
public void AddSimpleAttributeToMethod() |
||||
{ |
||||
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName); |
||||
var entity = FindEntity<IMethod>("TargetA"); |
||||
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute")); |
||||
gen.AddAttribute(entity, new DefaultAttribute(attribute)); |
||||
|
||||
Assert.AreEqual(@"using System;
|
||||
using System.Reflection; |
||||
|
||||
[assembly: AssemblyTitle(""CSharpBinding.Tests"")] |
||||
|
||||
class MySimpleAttribute : Attribute {} |
||||
|
||||
class TargetClass |
||||
{ |
||||
[MySimple] |
||||
void TargetA() |
||||
{ |
||||
} |
||||
|
||||
public int TargetB { get; set; } |
||||
|
||||
public int TargetC_ { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
interface TargetInterface |
||||
{ |
||||
} |
||||
", textEditor.Document.Text);
|
||||
} |
||||
|
||||
[Test] |
||||
public void AddSimpleAttributeToInterface() |
||||
{ |
||||
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName); |
||||
var entity = FindEntity<ITypeDefinition>("TargetInterface"); |
||||
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute")); |
||||
gen.AddAttribute(entity, new DefaultAttribute(attribute)); |
||||
|
||||
Assert.AreEqual(@"using System;
|
||||
using System.Reflection; |
||||
|
||||
[assembly: AssemblyTitle(""CSharpBinding.Tests"")] |
||||
|
||||
class MySimpleAttribute : Attribute {} |
||||
|
||||
class TargetClass |
||||
{ |
||||
void TargetA() |
||||
{ |
||||
} |
||||
|
||||
public int TargetB { get; set; } |
||||
|
||||
public int TargetC_ { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
[MySimple] |
||||
interface TargetInterface |
||||
{ |
||||
} |
||||
", textEditor.Document.Text);
|
||||
} |
||||
|
||||
[Test] |
||||
public void AddSimpleAttributeToProperty() |
||||
{ |
||||
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName); |
||||
var entity = FindEntity<IProperty>("TargetB"); |
||||
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute")); |
||||
gen.AddAttribute(entity, new DefaultAttribute(attribute)); |
||||
|
||||
Assert.AreEqual(@"using System;
|
||||
using System.Reflection; |
||||
|
||||
[assembly: AssemblyTitle(""CSharpBinding.Tests"")] |
||||
|
||||
class MySimpleAttribute : Attribute {} |
||||
|
||||
class TargetClass |
||||
{ |
||||
void TargetA() |
||||
{ |
||||
} |
||||
|
||||
[MySimple] |
||||
public int TargetB { get; set; } |
||||
|
||||
public int TargetC_ { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
interface TargetInterface |
||||
{ |
||||
} |
||||
", textEditor.Document.Text);
|
||||
} |
||||
|
||||
[Test] |
||||
public void AddSimpleAttributeToPropertyGetter() |
||||
{ |
||||
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName); |
||||
var entity = FindEntity<IProperty>("TargetC_"); |
||||
Assert.IsTrue(entity.CanGet); |
||||
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute")); |
||||
gen.AddAttribute(entity.Getter, new DefaultAttribute(attribute)); |
||||
|
||||
Assert.AreEqual(@"using System;
|
||||
using System.Reflection; |
||||
|
||||
[assembly: AssemblyTitle(""CSharpBinding.Tests"")] |
||||
|
||||
class MySimpleAttribute : Attribute {} |
||||
|
||||
class TargetClass |
||||
{ |
||||
void TargetA() |
||||
{ |
||||
} |
||||
|
||||
public int TargetB { get; set; } |
||||
|
||||
public int TargetC_ { |
||||
[MySimple] |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
interface TargetInterface |
||||
{ |
||||
} |
||||
", textEditor.Document.Text);
|
||||
} |
||||
|
||||
[Test] |
||||
[Ignore("The C# parser provides empty location info for AttributeSections.")] |
||||
public void AddSimpleAssemblyAttribute() |
||||
{ |
||||
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName); |
||||
var attribute = compilation.FindType(new FullTypeName("MySimpleAttribute")); |
||||
gen.AddAssemblyAttribute(new DefaultAttribute(attribute)); |
||||
|
||||
Assert.AreEqual(@"using System;
|
||||
using System.Reflection; |
||||
|
||||
[assembly: MySimple] |
||||
[assembly: AssemblyTitle(""CSharpBinding.Tests"")] |
||||
|
||||
class MySimpleAttribute : Attribute {} |
||||
|
||||
[MySimple] |
||||
class TargetClass |
||||
{ |
||||
void TargetA() |
||||
{ |
||||
} |
||||
|
||||
public int TargetB { get; set; } |
||||
|
||||
public int TargetC_ { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
interface TargetInterface |
||||
{ |
||||
} |
||||
", textEditor.Document.Text);
|
||||
} |
||||
|
||||
|
||||
T FindEntity<T>(string targetClass) where T : IEntity |
||||
{ |
||||
var compilation = SD.ParserService.GetCompilationForFile(textEditor.FileName); |
||||
var parseInfo = SD.ParserService.Parse(textEditor.FileName, textEditor.Document); |
||||
|
||||
int i = textEditor.Document.IndexOf(targetClass, 0, textEditor.Document.TextLength, StringComparison.Ordinal); |
||||
Assert.Greater(i, -1); |
||||
TextLocation location = textEditor.Document.GetLocation(i); |
||||
var member = parseInfo.UnresolvedFile.GetMember(location); |
||||
var type = parseInfo.UnresolvedFile.GetInnermostTypeDefinition(location); |
||||
|
||||
var context = new SimpleTypeResolveContext(compilation.MainAssembly); |
||||
var rt = type.Resolve(context).GetDefinition(); |
||||
|
||||
if (member != null) { |
||||
return (T)member.CreateResolved(context.WithCurrentTypeDefinition(rt)); |
||||
} |
||||
|
||||
return (T)rt; |
||||
} |
||||
} |
||||
} |
@ -1,20 +1,20 @@
@@ -1,20 +1,20 @@
|
||||
// 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.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
|
||||
namespace ICSharpCode.Scripting |
||||
{ |
||||
public interface IScriptingDesignerGenerator : IDesignerGenerator |
||||
{ |
||||
/// <summary>
|
||||
/// Updates the form or user control's InitializeComponent method with any
|
||||
/// changes to the designed form or user control.
|
||||
/// </summary>
|
||||
void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager); |
||||
} |
||||
} |
||||
//// 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.Design;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting
|
||||
//{
|
||||
// public interface IScriptingDesignerGenerator : IDesignerGenerator
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Updates the form or user control's InitializeComponent method with any
|
||||
// /// changes to the designed form or user control.
|
||||
// /// </summary>
|
||||
// void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager);
|
||||
// }
|
||||
//}
|
||||
|
@ -1,290 +1,290 @@
@@ -1,290 +1,290 @@
|
||||
// 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.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.Scripting |
||||
{ |
||||
public abstract class ScriptingDesignerGenerator : IScriptingDesignerGenerator |
||||
{ |
||||
FormsDesignerViewContent viewContent; |
||||
ITextEditorOptions textEditorOptions; |
||||
|
||||
public ITextEditorOptions TextEditorOptions { |
||||
get { return textEditorOptions; } |
||||
} |
||||
|
||||
public ScriptingDesignerGenerator(ITextEditorOptions textEditorOptions) |
||||
{ |
||||
this.textEditorOptions = textEditorOptions; |
||||
} |
||||
|
||||
public CodeDomProvider CodeDomProvider { |
||||
get { return null; } |
||||
} |
||||
|
||||
public FormsDesignerViewContent ViewContent { |
||||
get { return viewContent; } |
||||
} |
||||
|
||||
public void Attach(FormsDesignerViewContent viewContent) |
||||
{ |
||||
this.viewContent = viewContent; |
||||
} |
||||
|
||||
public void Detach() |
||||
{ |
||||
this.viewContent = null; |
||||
} |
||||
|
||||
public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile) |
||||
{ |
||||
designerCodeFile = viewContent.PrimaryFile; |
||||
return new [] {designerCodeFile}; |
||||
} |
||||
|
||||
public void MergeFormChanges(CodeCompileUnit unit) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns a list of method names that could be used as an
|
||||
/// event handler with the specified event.
|
||||
/// </summary>
|
||||
public ICollection GetCompatibleMethods(EventDescriptor edesc) |
||||
{ |
||||
ParseInformation parseInfo = ParseFile(); |
||||
return GetCompatibleMethods(parseInfo); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Parses the form or user control being designed.
|
||||
/// </summary>
|
||||
ParseInformation ParseFile() |
||||
{ |
||||
string fileName = viewContent.DesignerCodeFile.FileName; |
||||
string textContent = viewContent.DesignerCodeFileContent; |
||||
return ParseFile(fileName, textContent); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The default implementation calls the ParserService.ParseFile. This
|
||||
/// method is overridable so the class can be easily tested without
|
||||
/// the ParserService being required.
|
||||
/// </summary>
|
||||
protected virtual ParseInformation ParseFile(string fileName, string textContent) |
||||
{ |
||||
return ParserService.ParseFile(fileName, new StringTextBuffer(textContent)); |
||||
} |
||||
|
||||
ICollection GetCompatibleMethods(ParseInformation parseInfo) |
||||
{ |
||||
IClass c = GetClass(parseInfo.CompilationUnit); |
||||
return GetCompatibleMethods(c); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the form or user control class from the compilation unit.
|
||||
/// </summary>
|
||||
IClass GetClass(ICompilationUnit unit) |
||||
{ |
||||
return unit.Classes[0]; |
||||
} |
||||
|
||||
ICollection GetCompatibleMethods(IClass c) |
||||
{ |
||||
ArrayList methods = new ArrayList(); |
||||
foreach (IMethod method in c.Methods) { |
||||
if (IsCompatibleMethod(method)) { |
||||
methods.Add(method.Name); |
||||
} |
||||
} |
||||
return methods; |
||||
} |
||||
|
||||
bool IsCompatibleMethod(IMethod method) |
||||
{ |
||||
return method.Parameters.Count == 2; |
||||
} |
||||
|
||||
public void NotifyComponentRenamed(object component, string newName, string oldName) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the InitializeComponent method's body with the generated code.
|
||||
/// </summary>
|
||||
public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager) |
||||
{ |
||||
ParseInformation parseInfo = ParseFile(); |
||||
Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, serializationManager); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Merges the generated code into the specified document.
|
||||
/// </summary>
|
||||
/// <param name="component">The designer host.</param>
|
||||
/// <param name="document">The document that the generated code will be merged into.</param>
|
||||
/// <param name="parseInfo">The current compilation unit for the <paramref name="document"/>.</param>
|
||||
public void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, IDesignerSerializationManager serializationManager) |
||||
{ |
||||
IMethod method = GetInitializeComponents(compilationUnit); |
||||
string methodBody = GenerateMethodBody(method, host, serializationManager); |
||||
UpdateMethodBody(document, method, methodBody); |
||||
} |
||||
|
||||
public string GenerateMethodBody(IMethod method, IDesignerHost host, IDesignerSerializationManager serializationManager) |
||||
{ |
||||
int indent = GetIndent(method); |
||||
string rootNamespace = GetProjectRootNamespace(method.CompilationUnit); |
||||
IScriptingCodeDomSerializer serializer = CreateCodeDomSerializer(textEditorOptions); |
||||
return serializer.GenerateInitializeComponentMethodBody(host, serializationManager, rootNamespace, indent); |
||||
} |
||||
|
||||
public int GetIndent(IMethod method) |
||||
{ |
||||
int indent = method.Region.BeginColumn; |
||||
if (textEditorOptions.ConvertTabsToSpaces) { |
||||
indent = (indent / textEditorOptions.IndentationSize); |
||||
if (textEditorOptions.IndentationSize > 1) { |
||||
indent += 1; |
||||
} |
||||
} |
||||
return indent; |
||||
} |
||||
|
||||
public string GetProjectRootNamespace(ICompilationUnit compilationUnit) |
||||
{ |
||||
IProject project = compilationUnit.ProjectContent.Project as IProject; |
||||
if (project != null) { |
||||
return project.RootNamespace; |
||||
} |
||||
return String.Empty; |
||||
} |
||||
|
||||
public virtual IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public void UpdateMethodBody(IDocument document, IMethod method, string methodBody) |
||||
{ |
||||
DomRegion methodRegion = GetBodyRegionInDocument(method); |
||||
int startOffset = GetStartOffset(document, methodRegion); |
||||
int endOffset = GetEndOffset(document, methodRegion); |
||||
|
||||
document.Replace(startOffset, endOffset - startOffset, methodBody); |
||||
} |
||||
|
||||
public virtual DomRegion GetBodyRegionInDocument(IMethod method) |
||||
{ |
||||
return DomRegion.Empty; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the non-generated InitializeComponents from parse info.
|
||||
/// </summary>
|
||||
public static IMethod GetInitializeComponents(ParseInformation parseInfo) |
||||
{ |
||||
return GetInitializeComponents(parseInfo.CompilationUnit); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the non-generated InitializeComponents from the compilation unit.
|
||||
/// </summary>
|
||||
public static IMethod GetInitializeComponents(ICompilationUnit unit) |
||||
{ |
||||
foreach (IClass c in unit.Classes) { |
||||
if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) { |
||||
IMethod method = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c); |
||||
if (method != null) { |
||||
return method; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the start offset of the region.
|
||||
/// </summary>
|
||||
static int GetStartOffset(IDocument document, DomRegion region) |
||||
{ |
||||
return document.PositionToOffset(region.BeginLine, region.BeginColumn); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the end offset of the region.
|
||||
/// </summary>
|
||||
static int GetEndOffset(IDocument document, DomRegion region) |
||||
{ |
||||
if (region.EndLine > document.TotalNumberOfLines) { |
||||
// At end of document.
|
||||
return document.TextLength; |
||||
} |
||||
return document.PositionToOffset(region.EndLine, region.EndColumn); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts an event handler.
|
||||
/// </summary>
|
||||
public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position) |
||||
{ |
||||
position = GetExistingEventHandler(eventMethodName); |
||||
if (position == -1) { |
||||
// Ensure the text editor has the latest version
|
||||
// of the source code before we insert any new code.
|
||||
viewContent.MergeFormChanges(); |
||||
|
||||
// Insert the event handler at the end of the class.
|
||||
IDocument doc = ViewContent.DesignerCodeFileDocument; |
||||
string eventHandler = CreateEventHandler(eventMethodName, body, TextEditorOptions.IndentationString); |
||||
position = InsertEventHandler(doc, eventHandler); |
||||
} |
||||
|
||||
// Set the filename so it refers to the form being designed.
|
||||
file = ViewContent.DesignerCodeFile.FileName; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks if the event handler already exists.
|
||||
/// </summary>
|
||||
/// <returns>The line position of the first line of the existing event handler.</returns>
|
||||
int GetExistingEventHandler(string methodName) |
||||
{ |
||||
ParseInformation parseInfo = ParseFile(); |
||||
IClass c = GetClass(parseInfo.CompilationUnit); |
||||
foreach (IMethod method in c.Methods) { |
||||
if ((method.Name == methodName) && (method.Parameters.Count == 2)) { |
||||
return method.Region.BeginLine; |
||||
} |
||||
} |
||||
return -1; |
||||
} |
||||
|
||||
public virtual string CreateEventHandler(string eventMethodName, string body, string indentation) |
||||
{ |
||||
return String.Empty; |
||||
} |
||||
|
||||
public virtual int InsertEventHandler(IDocument document, string eventHandler) |
||||
{ |
||||
return 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.Collections.Generic;
|
||||
//using System.ComponentModel;
|
||||
//using System.ComponentModel.Design;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting
|
||||
//{
|
||||
// public abstract class ScriptingDesignerGenerator : IScriptingDesignerGenerator
|
||||
// {
|
||||
// FormsDesignerViewContent viewContent;
|
||||
// ITextEditorOptions textEditorOptions;
|
||||
//
|
||||
// public ITextEditorOptions TextEditorOptions {
|
||||
// get { return textEditorOptions; }
|
||||
// }
|
||||
//
|
||||
// public ScriptingDesignerGenerator(ITextEditorOptions textEditorOptions)
|
||||
// {
|
||||
// this.textEditorOptions = textEditorOptions;
|
||||
// }
|
||||
//
|
||||
// public CodeDomProvider CodeDomProvider {
|
||||
// get { return null; }
|
||||
// }
|
||||
//
|
||||
// public FormsDesignerViewContent ViewContent {
|
||||
// get { return viewContent; }
|
||||
// }
|
||||
//
|
||||
// public void Attach(FormsDesignerViewContent viewContent)
|
||||
// {
|
||||
// this.viewContent = viewContent;
|
||||
// }
|
||||
//
|
||||
// public void Detach()
|
||||
// {
|
||||
// this.viewContent = null;
|
||||
// }
|
||||
//
|
||||
// public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
|
||||
// {
|
||||
// designerCodeFile = viewContent.PrimaryFile;
|
||||
// return new [] {designerCodeFile};
|
||||
// }
|
||||
//
|
||||
// public void MergeFormChanges(CodeCompileUnit unit)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Returns a list of method names that could be used as an
|
||||
// /// event handler with the specified event.
|
||||
// /// </summary>
|
||||
// public ICollection GetCompatibleMethods(EventDescriptor edesc)
|
||||
// {
|
||||
// ParseInformation parseInfo = ParseFile();
|
||||
// return GetCompatibleMethods(parseInfo);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Parses the form or user control being designed.
|
||||
// /// </summary>
|
||||
// ParseInformation ParseFile()
|
||||
// {
|
||||
// string fileName = viewContent.DesignerCodeFile.FileName;
|
||||
// string textContent = viewContent.DesignerCodeFileContent;
|
||||
// return ParseFile(fileName, textContent);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// The default implementation calls the ParserService.ParseFile. This
|
||||
// /// method is overridable so the class can be easily tested without
|
||||
// /// the ParserService being required.
|
||||
// /// </summary>
|
||||
// protected virtual ParseInformation ParseFile(string fileName, string textContent)
|
||||
// {
|
||||
// return ParserService.ParseFile(fileName, new StringTextBuffer(textContent));
|
||||
// }
|
||||
//
|
||||
// ICollection GetCompatibleMethods(ParseInformation parseInfo)
|
||||
// {
|
||||
// IClass c = GetClass(parseInfo.CompilationUnit);
|
||||
// return GetCompatibleMethods(c);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the form or user control class from the compilation unit.
|
||||
// /// </summary>
|
||||
// IClass GetClass(ICompilationUnit unit)
|
||||
// {
|
||||
// return unit.Classes[0];
|
||||
// }
|
||||
//
|
||||
// ICollection GetCompatibleMethods(IClass c)
|
||||
// {
|
||||
// ArrayList methods = new ArrayList();
|
||||
// foreach (IMethod method in c.Methods) {
|
||||
// if (IsCompatibleMethod(method)) {
|
||||
// methods.Add(method.Name);
|
||||
// }
|
||||
// }
|
||||
// return methods;
|
||||
// }
|
||||
//
|
||||
// bool IsCompatibleMethod(IMethod method)
|
||||
// {
|
||||
// return method.Parameters.Count == 2;
|
||||
// }
|
||||
//
|
||||
// public void NotifyComponentRenamed(object component, string newName, string oldName)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Updates the InitializeComponent method's body with the generated code.
|
||||
// /// </summary>
|
||||
// public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
|
||||
// {
|
||||
// ParseInformation parseInfo = ParseFile();
|
||||
// Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, serializationManager);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Merges the generated code into the specified document.
|
||||
// /// </summary>
|
||||
// /// <param name="component">The designer host.</param>
|
||||
// /// <param name="document">The document that the generated code will be merged into.</param>
|
||||
// /// <param name="parseInfo">The current compilation unit for the <paramref name="document"/>.</param>
|
||||
// public void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, IDesignerSerializationManager serializationManager)
|
||||
// {
|
||||
// IMethod method = GetInitializeComponents(compilationUnit);
|
||||
// string methodBody = GenerateMethodBody(method, host, serializationManager);
|
||||
// UpdateMethodBody(document, method, methodBody);
|
||||
// }
|
||||
//
|
||||
// public string GenerateMethodBody(IMethod method, IDesignerHost host, IDesignerSerializationManager serializationManager)
|
||||
// {
|
||||
// int indent = GetIndent(method);
|
||||
// string rootNamespace = GetProjectRootNamespace(method.CompilationUnit);
|
||||
// IScriptingCodeDomSerializer serializer = CreateCodeDomSerializer(textEditorOptions);
|
||||
// return serializer.GenerateInitializeComponentMethodBody(host, serializationManager, rootNamespace, indent);
|
||||
// }
|
||||
//
|
||||
// public int GetIndent(IMethod method)
|
||||
// {
|
||||
// int indent = method.Region.BeginColumn;
|
||||
// if (textEditorOptions.ConvertTabsToSpaces) {
|
||||
// indent = (indent / textEditorOptions.IndentationSize);
|
||||
// if (textEditorOptions.IndentationSize > 1) {
|
||||
// indent += 1;
|
||||
// }
|
||||
// }
|
||||
// return indent;
|
||||
// }
|
||||
//
|
||||
// public string GetProjectRootNamespace(ICompilationUnit compilationUnit)
|
||||
// {
|
||||
// IProject project = compilationUnit.ProjectContent.Project as IProject;
|
||||
// if (project != null) {
|
||||
// return project.RootNamespace;
|
||||
// }
|
||||
// return String.Empty;
|
||||
// }
|
||||
//
|
||||
// public virtual IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public void UpdateMethodBody(IDocument document, IMethod method, string methodBody)
|
||||
// {
|
||||
// DomRegion methodRegion = GetBodyRegionInDocument(method);
|
||||
// int startOffset = GetStartOffset(document, methodRegion);
|
||||
// int endOffset = GetEndOffset(document, methodRegion);
|
||||
//
|
||||
// document.Replace(startOffset, endOffset - startOffset, methodBody);
|
||||
// }
|
||||
//
|
||||
// public virtual DomRegion GetBodyRegionInDocument(IMethod method)
|
||||
// {
|
||||
// return DomRegion.Empty;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the non-generated InitializeComponents from parse info.
|
||||
// /// </summary>
|
||||
// public static IMethod GetInitializeComponents(ParseInformation parseInfo)
|
||||
// {
|
||||
// return GetInitializeComponents(parseInfo.CompilationUnit);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the non-generated InitializeComponents from the compilation unit.
|
||||
// /// </summary>
|
||||
// public static IMethod GetInitializeComponents(ICompilationUnit unit)
|
||||
// {
|
||||
// foreach (IClass c in unit.Classes) {
|
||||
// if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) {
|
||||
// IMethod method = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
|
||||
// if (method != null) {
|
||||
// return method;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the start offset of the region.
|
||||
// /// </summary>
|
||||
// static int GetStartOffset(IDocument document, DomRegion region)
|
||||
// {
|
||||
// return document.PositionToOffset(region.BeginLine, region.BeginColumn);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the end offset of the region.
|
||||
// /// </summary>
|
||||
// static int GetEndOffset(IDocument document, DomRegion region)
|
||||
// {
|
||||
// if (region.EndLine > document.TotalNumberOfLines) {
|
||||
// // At end of document.
|
||||
// return document.TextLength;
|
||||
// }
|
||||
// return document.PositionToOffset(region.EndLine, region.EndColumn);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Inserts an event handler.
|
||||
// /// </summary>
|
||||
// public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
|
||||
// {
|
||||
// position = GetExistingEventHandler(eventMethodName);
|
||||
// if (position == -1) {
|
||||
// // Ensure the text editor has the latest version
|
||||
// // of the source code before we insert any new code.
|
||||
// viewContent.MergeFormChanges();
|
||||
//
|
||||
// // Insert the event handler at the end of the class.
|
||||
// IDocument doc = ViewContent.DesignerCodeFileDocument;
|
||||
// string eventHandler = CreateEventHandler(eventMethodName, body, TextEditorOptions.IndentationString);
|
||||
// position = InsertEventHandler(doc, eventHandler);
|
||||
// }
|
||||
//
|
||||
// // Set the filename so it refers to the form being designed.
|
||||
// file = ViewContent.DesignerCodeFile.FileName;
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Checks if the event handler already exists.
|
||||
// /// </summary>
|
||||
// /// <returns>The line position of the first line of the existing event handler.</returns>
|
||||
// int GetExistingEventHandler(string methodName)
|
||||
// {
|
||||
// ParseInformation parseInfo = ParseFile();
|
||||
// IClass c = GetClass(parseInfo.CompilationUnit);
|
||||
// foreach (IMethod method in c.Methods) {
|
||||
// if ((method.Name == methodName) && (method.Parameters.Count == 2)) {
|
||||
// return method.Region.BeginLine;
|
||||
// }
|
||||
// }
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// public virtual string CreateEventHandler(string eventMethodName, string body, string indentation)
|
||||
// {
|
||||
// return String.Empty;
|
||||
// }
|
||||
//
|
||||
// public virtual int InsertEventHandler(IDocument document, string eventHandler)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,168 +1,168 @@
@@ -1,168 +1,168 @@
|
||||
// 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 System.Text; |
||||
|
||||
using ICSharpCode.Core; |
||||
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; |
||||
} |
||||
|
||||
protected override void ReportFlushErrors(ICollection errors) |
||||
{ |
||||
StringBuilder sb = new StringBuilder(StringParser.Parse("${res:ICSharpCode.SharpDevelop.FormDesigner.ReportFlushErrors}") + Environment.NewLine + Environment.NewLine); |
||||
foreach (var error in errors) { |
||||
sb.AppendLine(error.ToString()); |
||||
sb.AppendLine(); |
||||
} |
||||
MessageService.ShowError(sb.ToString()); |
||||
} |
||||
} |
||||
} |
||||
//// 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 System.Text;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//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;
|
||||
// }
|
||||
//
|
||||
// protected override void ReportFlushErrors(ICollection errors)
|
||||
// {
|
||||
// StringBuilder sb = new StringBuilder(StringParser.Parse("${res:ICSharpCode.SharpDevelop.FormDesigner.ReportFlushErrors}") + Environment.NewLine + Environment.NewLine);
|
||||
// foreach (var error in errors) {
|
||||
// sb.AppendLine(error.ToString());
|
||||
// sb.AppendLine();
|
||||
// }
|
||||
// MessageService.ShowError(sb.ToString());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,47 +1,47 @@
@@ -1,47 +1,47 @@
|
||||
// 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 ICSharpCode.FormsDesigner; |
||||
|
||||
namespace ICSharpCode.Scripting |
||||
{ |
||||
public class ScriptingNameCreationService : INameCreationService |
||||
{ |
||||
IDesignerHost host; |
||||
XmlDesignerNameCreationService nameCreationService; |
||||
|
||||
public ScriptingNameCreationService(IDesignerHost host) |
||||
{ |
||||
this.host = host; |
||||
nameCreationService = new XmlDesignerNameCreationService(host); |
||||
} |
||||
|
||||
public string CreateName(IContainer container, Type dataType) |
||||
{ |
||||
return nameCreationService.CreateName(container, dataType); |
||||
} |
||||
|
||||
public bool IsValidName(string name) |
||||
{ |
||||
if (!nameCreationService.IsValidName(name)) { |
||||
return false; |
||||
} |
||||
|
||||
if (host.Container != null) { |
||||
return host.Container.Components[name] == null; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public void ValidateName(string name) |
||||
{ |
||||
if (!IsValidName(name)) { |
||||
throw new Exception("Invalid name " + name); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
//// 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 ICSharpCode.FormsDesigner;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting
|
||||
//{
|
||||
// public class ScriptingNameCreationService : INameCreationService
|
||||
// {
|
||||
// IDesignerHost host;
|
||||
// XmlDesignerNameCreationService nameCreationService;
|
||||
//
|
||||
// public ScriptingNameCreationService(IDesignerHost host)
|
||||
// {
|
||||
// this.host = host;
|
||||
// nameCreationService = new XmlDesignerNameCreationService(host);
|
||||
// }
|
||||
//
|
||||
// public string CreateName(IContainer container, Type dataType)
|
||||
// {
|
||||
// return nameCreationService.CreateName(container, dataType);
|
||||
// }
|
||||
//
|
||||
// public bool IsValidName(string name)
|
||||
// {
|
||||
// if (!nameCreationService.IsValidName(name)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (host.Container != null) {
|
||||
// return host.Container.Components[name] == null;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public void ValidateName(string name)
|
||||
// {
|
||||
// if (!IsValidName(name)) {
|
||||
// throw new Exception("Invalid name " + name);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,44 +1,44 @@
@@ -1,44 +1,44 @@
|
||||
// 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.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
public abstract class CallBeginInitOnLoadTestsBase : LoadFormTestsBase |
||||
{ |
||||
public SupportInitCustomControl Control { |
||||
get { return Form.Controls[0] as SupportInitCustomControl; } |
||||
} |
||||
|
||||
public SupportInitCustomControl LocalControl { |
||||
get { return base.ComponentCreator.GetInstance("localVariable") as SupportInitCustomControl; } |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginInitCalled() |
||||
{ |
||||
Assert.IsTrue(Control.IsBeginInitCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void EndInitCalled() |
||||
{ |
||||
Assert.IsTrue(Control.IsEndInitCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginInitCalledOnLocalVariable() |
||||
{ |
||||
Assert.IsTrue(LocalControl.IsBeginInitCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void EndInitCalledOnLocalVariable() |
||||
{ |
||||
Assert.IsTrue(LocalControl.IsEndInitCalled); |
||||
} |
||||
} |
||||
} |
||||
//// 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.Scripting.Tests.Utils;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Designer
|
||||
//{
|
||||
// public abstract class CallBeginInitOnLoadTestsBase : LoadFormTestsBase
|
||||
// {
|
||||
// public SupportInitCustomControl Control {
|
||||
// get { return Form.Controls[0] as SupportInitCustomControl; }
|
||||
// }
|
||||
//
|
||||
// public SupportInitCustomControl LocalControl {
|
||||
// get { return base.ComponentCreator.GetInstance("localVariable") as SupportInitCustomControl; }
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void BeginInitCalled()
|
||||
// {
|
||||
// Assert.IsTrue(Control.IsBeginInitCalled);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void EndInitCalled()
|
||||
// {
|
||||
// Assert.IsTrue(Control.IsEndInitCalled);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void BeginInitCalledOnLocalVariable()
|
||||
// {
|
||||
// Assert.IsTrue(LocalControl.IsBeginInitCalled);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void EndInitCalledOnLocalVariable()
|
||||
// {
|
||||
// Assert.IsTrue(LocalControl.IsEndInitCalled);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,51 +1,51 @@
@@ -1,51 +1,51 @@
|
||||
// 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.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
public abstract class GenerateAcceptButtonFormTestsBase : GenerateDesignerCodeTestsBase |
||||
{ |
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) { |
||||
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); |
||||
IEventBindingService eventBindingService = new MockEventBindingService(host); |
||||
Form form = (Form)host.RootComponent; |
||||
form.ClientSize = new Size(200, 300); |
||||
|
||||
Button button = (Button)host.CreateComponent(typeof(Button), "button1"); |
||||
button.Location = new Point(0, 0); |
||||
button.Size = new Size(10, 10); |
||||
button.Text = "button1"; |
||||
button.UseCompatibleTextRendering = false; |
||||
form.Controls.Add(button); |
||||
|
||||
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); |
||||
PropertyDescriptor acceptButtonPropertyDescriptor = descriptors.Find("AcceptButton", false); |
||||
acceptButtonPropertyDescriptor.SetValue(form, button); |
||||
|
||||
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false); |
||||
namePropertyDescriptor.SetValue(form, "MainForm"); |
||||
|
||||
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host); |
||||
using (serializationManager.CreateSession()) { |
||||
IScriptingCodeDomSerializer serializer = CreateSerializer(); |
||||
generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
//// 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.Generic;
|
||||
//using System.ComponentModel;
|
||||
//using System.ComponentModel.Design;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//using System.Drawing;
|
||||
//using System.Windows.Forms;
|
||||
//
|
||||
//using ICSharpCode.Scripting;
|
||||
//using ICSharpCode.Scripting.Tests.Utils;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Designer
|
||||
//{
|
||||
// public abstract class GenerateAcceptButtonFormTestsBase : GenerateDesignerCodeTestsBase
|
||||
// {
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
|
||||
// IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
|
||||
// IEventBindingService eventBindingService = new MockEventBindingService(host);
|
||||
// Form form = (Form)host.RootComponent;
|
||||
// form.ClientSize = new Size(200, 300);
|
||||
//
|
||||
// Button button = (Button)host.CreateComponent(typeof(Button), "button1");
|
||||
// button.Location = new Point(0, 0);
|
||||
// button.Size = new Size(10, 10);
|
||||
// button.Text = "button1";
|
||||
// button.UseCompatibleTextRendering = false;
|
||||
// form.Controls.Add(button);
|
||||
//
|
||||
// PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
|
||||
// PropertyDescriptor acceptButtonPropertyDescriptor = descriptors.Find("AcceptButton", false);
|
||||
// acceptButtonPropertyDescriptor.SetValue(form, button);
|
||||
//
|
||||
// PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
|
||||
// namePropertyDescriptor.SetValue(form, "MainForm");
|
||||
//
|
||||
// DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
|
||||
// using (serializationManager.CreateSession()) {
|
||||
// IScriptingCodeDomSerializer serializer = CreateSerializer();
|
||||
// generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,14 +1,14 @@
@@ -1,14 +1,14 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
public abstract class GenerateDesignerCodeTestsBase |
||||
{ |
||||
protected string generatedCode; |
||||
|
||||
protected abstract IScriptingCodeDomSerializer CreateSerializer(); |
||||
} |
||||
} |
||||
//// 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;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Designer
|
||||
//{
|
||||
// public abstract class GenerateDesignerCodeTestsBase
|
||||
// {
|
||||
// protected string generatedCode;
|
||||
//
|
||||
// protected abstract IScriptingCodeDomSerializer CreateSerializer();
|
||||
// }
|
||||
//}
|
||||
|
@ -1,42 +1,42 @@
@@ -1,42 +1,42 @@
|
||||
// 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.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Scripting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
public abstract class GenerateEnabledUsingPropertyDescriptorTestsBase : GenerateDesignerCodeTestsBase |
||||
{ |
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) { |
||||
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); |
||||
Form form = (Form)host.RootComponent; |
||||
form.ClientSize = new Size(284, 264); |
||||
form.AllowDrop = false; |
||||
form.Enabled = false; |
||||
|
||||
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); |
||||
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false); |
||||
namePropertyDescriptor.SetValue(form, "MainForm"); |
||||
|
||||
PropertyDescriptor enabledPropertyDescriptor = descriptors.Find("Enabled", false); |
||||
enabledPropertyDescriptor.SetValue(form, false); |
||||
|
||||
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host); |
||||
using (serializationManager.CreateSession()) { |
||||
IScriptingCodeDomSerializer serializer = CreateSerializer(); |
||||
generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
//// 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.Drawing;
|
||||
//using System.Windows.Forms;
|
||||
//using ICSharpCode.Scripting;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Designer
|
||||
//{
|
||||
// public abstract class GenerateEnabledUsingPropertyDescriptorTestsBase : GenerateDesignerCodeTestsBase
|
||||
// {
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
|
||||
// IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
|
||||
// Form form = (Form)host.RootComponent;
|
||||
// form.ClientSize = new Size(284, 264);
|
||||
// form.AllowDrop = false;
|
||||
// form.Enabled = false;
|
||||
//
|
||||
// PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
|
||||
// PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
|
||||
// namePropertyDescriptor.SetValue(form, "MainForm");
|
||||
//
|
||||
// PropertyDescriptor enabledPropertyDescriptor = descriptors.Find("Enabled", false);
|
||||
// enabledPropertyDescriptor.SetValue(form, false);
|
||||
//
|
||||
// DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
|
||||
// using (serializationManager.CreateSession()) {
|
||||
// IScriptingCodeDomSerializer serializer = CreateSerializer();
|
||||
// generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,45 +1,45 @@
@@ -1,45 +1,45 @@
|
||||
// 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.Drawing; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
public abstract class GenerateUserControlWithNullPropertyValueTestsBase : GenerateDesignerCodeTestsBase |
||||
{ |
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) { |
||||
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); |
||||
IEventBindingService eventBindingService = new MockEventBindingService(host); |
||||
UserControl userControl = (UserControl)host.RootComponent; |
||||
userControl.ClientSize = new Size(200, 300); |
||||
|
||||
NullPropertyUserControl control = (NullPropertyUserControl)host.CreateComponent(typeof(NullPropertyUserControl), "userControl1"); |
||||
control.Location = new Point(0, 0); |
||||
control.Size = new Size(10, 10); |
||||
userControl.Controls.Add(control); |
||||
|
||||
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(userControl); |
||||
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false); |
||||
namePropertyDescriptor.SetValue(userControl, "MainControl"); |
||||
|
||||
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host); |
||||
using (serializationManager.CreateSession()) { |
||||
IScriptingCodeDomSerializer serializer = CreateSerializer(); |
||||
generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
//// 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.Drawing;
|
||||
//using System.Windows.Forms;
|
||||
//
|
||||
//using ICSharpCode.Scripting;
|
||||
//using ICSharpCode.Scripting.Tests.Utils;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Designer
|
||||
//{
|
||||
// public abstract class GenerateUserControlWithNullPropertyValueTestsBase : GenerateDesignerCodeTestsBase
|
||||
// {
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
|
||||
// IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
|
||||
// IEventBindingService eventBindingService = new MockEventBindingService(host);
|
||||
// UserControl userControl = (UserControl)host.RootComponent;
|
||||
// userControl.ClientSize = new Size(200, 300);
|
||||
//
|
||||
// NullPropertyUserControl control = (NullPropertyUserControl)host.CreateComponent(typeof(NullPropertyUserControl), "userControl1");
|
||||
// control.Location = new Point(0, 0);
|
||||
// control.Size = new Size(10, 10);
|
||||
// userControl.Controls.Add(control);
|
||||
//
|
||||
// PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(userControl);
|
||||
// PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
|
||||
// namePropertyDescriptor.SetValue(userControl, "MainControl");
|
||||
//
|
||||
// DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
|
||||
// using (serializationManager.CreateSession()) {
|
||||
// IScriptingCodeDomSerializer serializer = CreateSerializer();
|
||||
// generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,60 +1,60 @@
@@ -1,60 +1,60 @@
|
||||
// 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.Drawing; |
||||
using System.Reflection; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
public abstract class LoadFormTestsBase |
||||
{ |
||||
MockComponentCreator componentCreator = new MockComponentCreator(); |
||||
Form form; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
BeforeSetUpFixture(); |
||||
IComponentWalker walker = CreateComponentWalker(componentCreator); |
||||
form = walker.CreateComponent(Code) as Form; |
||||
} |
||||
|
||||
[TestFixtureTearDown] |
||||
public void TearDownFixture() |
||||
{ |
||||
if (form != null) { |
||||
form.Dispose(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Called at the start of SetUpFixture method before anything is setup.
|
||||
/// </summary>
|
||||
public virtual void BeforeSetUpFixture() |
||||
{ |
||||
} |
||||
|
||||
protected abstract IComponentWalker CreateComponentWalker(IComponentCreator componentCreator); |
||||
|
||||
/// <summary>
|
||||
/// Gets the code that will be loaded.
|
||||
/// </summary>
|
||||
public virtual string Code { |
||||
get { return String.Empty; } |
||||
} |
||||
|
||||
protected MockComponentCreator ComponentCreator { |
||||
get { return componentCreator; } |
||||
} |
||||
|
||||
protected Form Form { |
||||
get { return form; } |
||||
} |
||||
} |
||||
} |
||||
//// 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.Drawing;
|
||||
//using System.Reflection;
|
||||
//using System.Windows.Forms;
|
||||
//
|
||||
//using ICSharpCode.Scripting;
|
||||
//using ICSharpCode.Scripting.Tests.Utils;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Designer
|
||||
//{
|
||||
// public abstract class LoadFormTestsBase
|
||||
// {
|
||||
// MockComponentCreator componentCreator = new MockComponentCreator();
|
||||
// Form form;
|
||||
//
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// BeforeSetUpFixture();
|
||||
// IComponentWalker walker = CreateComponentWalker(componentCreator);
|
||||
// form = walker.CreateComponent(Code) as Form;
|
||||
// }
|
||||
//
|
||||
// [TestFixtureTearDown]
|
||||
// public void TearDownFixture()
|
||||
// {
|
||||
// if (form != null) {
|
||||
// form.Dispose();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Called at the start of SetUpFixture method before anything is setup.
|
||||
// /// </summary>
|
||||
// public virtual void BeforeSetUpFixture()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// protected abstract IComponentWalker CreateComponentWalker(IComponentCreator componentCreator);
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the code that will be loaded.
|
||||
// /// </summary>
|
||||
// public virtual string Code {
|
||||
// get { return String.Empty; }
|
||||
// }
|
||||
//
|
||||
// protected MockComponentCreator ComponentCreator {
|
||||
// get { return componentCreator; }
|
||||
// }
|
||||
//
|
||||
// protected Form Form {
|
||||
// get { return form; }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,102 +1,102 @@
@@ -1,102 +1,102 @@
|
||||
// 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.Design.Serialization; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
[TestFixture] |
||||
public class NameCreationServiceTestFixture |
||||
{ |
||||
ScriptingNameCreationService nameCreationService; |
||||
MockDesignerLoaderHost host; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
host = new MockDesignerLoaderHost(); |
||||
host.Container.Add(new Button(), "button1"); |
||||
nameCreationService = new ScriptingNameCreationService(host); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsValidNameReturnsFalseIfComponentInContainerAlreadyUsesName() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName("button1")); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsValidNameReturnsTrueIfNameNotInUse() |
||||
{ |
||||
Assert.IsTrue(nameCreationService.IsValidName("unknown")); |
||||
} |
||||
|
||||
[Test] |
||||
public void NullReferenceNotThrownWhenHostContainerIsNull() |
||||
{ |
||||
host.Container = null; |
||||
Assert.IsTrue(nameCreationService.IsValidName("button1")); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateNameReturnsTypeNameFollowedByNumberOne() |
||||
{ |
||||
Assert.AreEqual("button1", nameCreationService.CreateName(null, typeof(Button))); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateNameReturnsTypeNameFollowedByNumberTwoIfNameExistsInContainer() |
||||
{ |
||||
Assert.AreEqual("button2", nameCreationService.CreateName(host.Container, typeof(Button))); |
||||
} |
||||
|
||||
[Test] |
||||
public void ValidateNameThrowsExceptionIfNameExistsInContainer() |
||||
{ |
||||
Exception ex = Assert.Throws<Exception>(delegate { nameCreationService.ValidateName("button1"); }); |
||||
Assert.AreEqual("Invalid name button1", ex.Message); |
||||
} |
||||
|
||||
[Test] |
||||
public void ValidateNameDoesNotThrowExceptionIfNameDoesNotExistInContainer() |
||||
{ |
||||
Assert.DoesNotThrow(delegate { nameCreationService.ValidateName("button2"); }); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsValidReturnsFalseWhenNameIsNull() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsValidReturnsFalseWhenNameIsEmptyString() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName(String.Empty)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsValidReturnsFalseWhenNameContainsNonLetterOrDigit() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName("a%b")); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsValidReturnsFalseWhenFirstCharacterOfNameIsNumber() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName("1abc")); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsValidReturnsTrueWhenFirstCharacterOfNameIsUnderscore() |
||||
{ |
||||
Assert.IsTrue(nameCreationService.IsValidName("_abc")); |
||||
} |
||||
} |
||||
} |
||||
//// 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.Design.Serialization;
|
||||
//using System.Windows.Forms;
|
||||
//
|
||||
//using ICSharpCode.Scripting;
|
||||
//using ICSharpCode.Scripting.Tests.Utils;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Designer
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class NameCreationServiceTestFixture
|
||||
// {
|
||||
// ScriptingNameCreationService nameCreationService;
|
||||
// MockDesignerLoaderHost host;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// host = new MockDesignerLoaderHost();
|
||||
// host.Container.Add(new Button(), "button1");
|
||||
// nameCreationService = new ScriptingNameCreationService(host);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void IsValidNameReturnsFalseIfComponentInContainerAlreadyUsesName()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName("button1"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void IsValidNameReturnsTrueIfNameNotInUse()
|
||||
// {
|
||||
// Assert.IsTrue(nameCreationService.IsValidName("unknown"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NullReferenceNotThrownWhenHostContainerIsNull()
|
||||
// {
|
||||
// host.Container = null;
|
||||
// Assert.IsTrue(nameCreationService.IsValidName("button1"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CreateNameReturnsTypeNameFollowedByNumberOne()
|
||||
// {
|
||||
// Assert.AreEqual("button1", nameCreationService.CreateName(null, typeof(Button)));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CreateNameReturnsTypeNameFollowedByNumberTwoIfNameExistsInContainer()
|
||||
// {
|
||||
// Assert.AreEqual("button2", nameCreationService.CreateName(host.Container, typeof(Button)));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ValidateNameThrowsExceptionIfNameExistsInContainer()
|
||||
// {
|
||||
// Exception ex = Assert.Throws<Exception>(delegate { nameCreationService.ValidateName("button1"); });
|
||||
// Assert.AreEqual("Invalid name button1", ex.Message);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ValidateNameDoesNotThrowExceptionIfNameDoesNotExistInContainer()
|
||||
// {
|
||||
// Assert.DoesNotThrow(delegate { nameCreationService.ValidateName("button2"); });
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void IsValidReturnsFalseWhenNameIsNull()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName(null));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void IsValidReturnsFalseWhenNameIsEmptyString()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName(String.Empty));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void IsValidReturnsFalseWhenNameContainsNonLetterOrDigit()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName("a%b"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void IsValidReturnsFalseWhenFirstCharacterOfNameIsNumber()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName("1abc"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void IsValidReturnsTrueWhenFirstCharacterOfNameIsUnderscore()
|
||||
// {
|
||||
// Assert.IsTrue(nameCreationService.IsValidName("_abc"));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,246 +1,246 @@
@@ -1,246 +1,246 @@
|
||||
// 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 ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Designer |
||||
{ |
||||
[TestFixture] |
||||
[RequiresSTA] |
||||
public class ScriptingDesignerGeneratorTests |
||||
{ |
||||
MockTextEditorOptions textEditorOptions; |
||||
TestableScriptingDesignerGenerator generator; |
||||
FormsDesignerViewContent formsDesignerView; |
||||
MockTextEditorViewContent textEditorViewContent; |
||||
MockOpenedFile formsDesignerOpenedFile; |
||||
MockDesignerLoaderHost host; |
||||
FakeDesignerSerializationManager serializationManager; |
||||
FakeCodeDomSerializer serializer; |
||||
MockMethod method; |
||||
|
||||
[Test] |
||||
public void GetSourceFiles_FormDesignerViewHasOpenFile_ReturnsOneFile() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
OpenedFile designerOpenedFile; |
||||
IEnumerable<OpenedFile> files = generator.GetSourceFiles(out designerOpenedFile); |
||||
int count = HowManyInCollection(files); |
||||
|
||||
Assert.AreEqual(1, count); |
||||
} |
||||
|
||||
void CreateDesignerGenerator() |
||||
{ |
||||
textEditorViewContent = new MockTextEditorViewContent(); |
||||
formsDesignerOpenedFile = new MockOpenedFile("test.py"); |
||||
textEditorViewContent.PrimaryFile = formsDesignerOpenedFile; |
||||
formsDesignerView = new FormsDesignerViewContent(textEditorViewContent, formsDesignerOpenedFile); |
||||
textEditorOptions = new MockTextEditorOptions(); |
||||
generator = new TestableScriptingDesignerGenerator(textEditorOptions); |
||||
generator.Attach(formsDesignerView); |
||||
generator.ParseInfoToReturnFromParseFile = generator.CreateParseInfoWithOneClass(); |
||||
} |
||||
|
||||
int HowManyInCollection(IEnumerable<OpenedFile> files) |
||||
{ |
||||
int count = 0; |
||||
foreach (OpenedFile file in files) { |
||||
count++; |
||||
} |
||||
return count; |
||||
} |
||||
|
||||
[Test] |
||||
public void GetSourceFiles_FormsDesignerHasOpenFile_DesignerOpenedFileParameterIsSetToFormsDesignerViewOpenedFile() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
OpenedFile designerOpenedFile; |
||||
generator.GetSourceFiles(out designerOpenedFile); |
||||
|
||||
AssertAreEqual(formsDesignerOpenedFile, designerOpenedFile); |
||||
} |
||||
|
||||
void AssertAreEqual(OpenedFile expectedOpenedFile, OpenedFile actualOpenedFile) |
||||
{ |
||||
string fileName = actualOpenedFile.FileName.ToString(); |
||||
string expectedFileName = expectedOpenedFile.FileName.ToString(); |
||||
|
||||
Assert.AreEqual(expectedFileName, fileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetSourceFiles_FormsDesignerHasOpenFile_FormsDesignerFileReturnedInFiles() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
OpenedFile designerOpenedFile; |
||||
IEnumerable<OpenedFile> files = generator.GetSourceFiles(out designerOpenedFile); |
||||
IEnumerator<OpenedFile> enumerator = files.GetEnumerator(); |
||||
enumerator.MoveNext(); |
||||
OpenedFile file = enumerator.Current; |
||||
|
||||
AssertAreEqual(formsDesignerOpenedFile, file); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompatibleMethods_OneClassMethod_CallsParseFile() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
CallGetCompatibleMethods(); |
||||
Assert.IsTrue(generator.IsParseFileCalled); |
||||
} |
||||
|
||||
ICollection CallGetCompatibleMethods() |
||||
{ |
||||
MockEventDescriptor descriptor = new MockEventDescriptor("Click"); |
||||
return generator.GetCompatibleMethods(descriptor); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompatibleMethods_OneClassMethod_ParseFilePassedFileNameOpenInTextEditor() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
CallGetCompatibleMethods(); |
||||
|
||||
string fileName = generator.FileNamePassedToParseFile; |
||||
string expectedFileName = "test.py"; |
||||
|
||||
Assert.AreEqual(expectedFileName, fileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompatibleMethods_OneClassMethod_ParseFilePassedTextContentInTextEditor() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
formsDesignerView.DesignerCodeFileContent = "code"; |
||||
CallGetCompatibleMethods(); |
||||
|
||||
string textContent = generator.TextContentPassedToParseFile; |
||||
string expectedTextContent = "code"; |
||||
|
||||
Assert.AreEqual(expectedTextContent, textContent); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompatibleMethods_OneMethodWithTwoParameters_MethodNameReturnedInCompatibleMethods() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
ParseInformation parseInfo = generator.CreateParseInfoWithOneMethodWithTwoParameters("button1_click"); |
||||
generator.ParseInfoToReturnFromParseFile = parseInfo; |
||||
ICollection methods = CallGetCompatibleMethods(); |
||||
|
||||
string[] expectedMethods = new string[] { "button1_click" }; |
||||
|
||||
Assert.AreEqual(expectedMethods, methods); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompatibleMethods_OneMethodWithNoParameters_NoMethodsReturnedInCompatibleMethods() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
ParseInformation parseInfo = generator.CreateParseInfoWithOneMethod("button1_click"); |
||||
generator.ParseInfoToReturnFromParseFile = parseInfo; |
||||
ICollection methods = CallGetCompatibleMethods(); |
||||
|
||||
Assert.AreEqual(0, methods.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void Detach_FormsDesignerViewAlreadyAttached_SetsViewContentToNull() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
generator.Detach(); |
||||
Assert.IsNull(generator.ViewContent); |
||||
} |
||||
|
||||
[Test] |
||||
public void GenerateMethodBody_PassedDesignerHost_DesignerHostPassedToCodeDomSerializer() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
CreateParametersForGenerateMethodBodyCall(); |
||||
CallGenerateMethodBody(); |
||||
|
||||
Assert.AreEqual(host, serializer.HostPassedToGenerateInitializeComponentMethodBody); |
||||
} |
||||
|
||||
void CreateParametersForGenerateMethodBodyCall() |
||||
{ |
||||
serializer = new FakeCodeDomSerializer(); |
||||
generator.SerializerToReturnFromCreateCodeDomSerializer = serializer; |
||||
method = MockMethod.CreateMockMethodWithoutAnyAttributes(); |
||||
host = new MockDesignerLoaderHost(); |
||||
serializationManager = new FakeDesignerSerializationManager(); |
||||
} |
||||
|
||||
string CallGenerateMethodBody() |
||||
{ |
||||
return generator.GenerateMethodBody(method, host, serializationManager); |
||||
} |
||||
|
||||
[Test] |
||||
public void GenerateMethodBody_MethodBodyCreated_ReturnsMethodBodyFromCodeDomSerializer() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
CreateParametersForGenerateMethodBodyCall(); |
||||
serializer.MethodBodyToReturnFromGenerateMethodBodyCall = "test"; |
||||
string methodBody = CallGenerateMethodBody(); |
||||
|
||||
string expectedMethodBody = "test"; |
||||
Assert.AreEqual(expectedMethodBody, methodBody); |
||||
} |
||||
|
||||
[Test] |
||||
public void GenerateMethodBody_PassedDesignerSerializationManager_DesignerSerializationManagerPassedToCodeDomSerializer() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
CreateParametersForGenerateMethodBodyCall(); |
||||
CallGenerateMethodBody(); |
||||
|
||||
Assert.AreEqual(serializationManager, serializer.SerializationManagerGenerateInitializeComponentMethodBody); |
||||
} |
||||
|
||||
[Test] |
||||
public void GenerateMethodBody_TextEditorOptionsConvertTabsToSpacesIsFalse_MethodBeginColumnIsIndentPassedToGenerateMethodBody() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
CreateParametersForGenerateMethodBodyCall(); |
||||
|
||||
int beginLine = 1; |
||||
int beginColumn = 3; |
||||
int endLine = 2; |
||||
int endColumn = 1; |
||||
method.Region = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
||||
|
||||
textEditorOptions.ConvertTabsToSpaces = false; |
||||
|
||||
CallGenerateMethodBody(); |
||||
|
||||
int expectedIndent = 3; |
||||
|
||||
Assert.AreEqual(expectedIndent, serializer.InitialIndentPassedToGenerateInitializeComponentMethodBody); |
||||
} |
||||
|
||||
[Test] |
||||
public void GenerateMethodBody_ProjectHasRootNamespace_RootNamespacePassedToCodeDomSerializer() |
||||
{ |
||||
CreateDesignerGenerator(); |
||||
CreateParametersForGenerateMethodBodyCall(); |
||||
|
||||
method.MockDeclaringType.MockProjectContent.ProjectAsIProject.RootNamespace = "Test"; |
||||
|
||||
CallGenerateMethodBody(); |
||||
|
||||
string expectedRootNamespace = "Test"; |
||||
Assert.AreEqual(expectedRootNamespace, serializer.RootNamespacePassedToGenerateInitializeComponentMethodBody); |
||||
} |
||||
} |
||||
} |
||||
//// 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 ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.Scripting;
|
||||
//using ICSharpCode.Scripting.Tests.Utils;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//using UnitTesting.Tests.Utils;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Designer
|
||||
//{
|
||||
// [TestFixture]
|
||||
// [RequiresSTA]
|
||||
// public class ScriptingDesignerGeneratorTests
|
||||
// {
|
||||
// MockTextEditorOptions textEditorOptions;
|
||||
// TestableScriptingDesignerGenerator generator;
|
||||
// FormsDesignerViewContent formsDesignerView;
|
||||
// MockTextEditorViewContent textEditorViewContent;
|
||||
// MockOpenedFile formsDesignerOpenedFile;
|
||||
// MockDesignerLoaderHost host;
|
||||
// FakeDesignerSerializationManager serializationManager;
|
||||
// FakeCodeDomSerializer serializer;
|
||||
// MockMethod method;
|
||||
//
|
||||
// [Test]
|
||||
// public void GetSourceFiles_FormDesignerViewHasOpenFile_ReturnsOneFile()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// OpenedFile designerOpenedFile;
|
||||
// IEnumerable<OpenedFile> files = generator.GetSourceFiles(out designerOpenedFile);
|
||||
// int count = HowManyInCollection(files);
|
||||
//
|
||||
// Assert.AreEqual(1, count);
|
||||
// }
|
||||
//
|
||||
// void CreateDesignerGenerator()
|
||||
// {
|
||||
// textEditorViewContent = new MockTextEditorViewContent();
|
||||
// formsDesignerOpenedFile = new MockOpenedFile("test.py");
|
||||
// textEditorViewContent.PrimaryFile = formsDesignerOpenedFile;
|
||||
// formsDesignerView = new FormsDesignerViewContent(textEditorViewContent, formsDesignerOpenedFile);
|
||||
// textEditorOptions = new MockTextEditorOptions();
|
||||
// generator = new TestableScriptingDesignerGenerator(textEditorOptions);
|
||||
// generator.Attach(formsDesignerView);
|
||||
// generator.ParseInfoToReturnFromParseFile = generator.CreateParseInfoWithOneClass();
|
||||
// }
|
||||
//
|
||||
// int HowManyInCollection(IEnumerable<OpenedFile> files)
|
||||
// {
|
||||
// int count = 0;
|
||||
// foreach (OpenedFile file in files) {
|
||||
// count++;
|
||||
// }
|
||||
// return count;
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetSourceFiles_FormsDesignerHasOpenFile_DesignerOpenedFileParameterIsSetToFormsDesignerViewOpenedFile()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// OpenedFile designerOpenedFile;
|
||||
// generator.GetSourceFiles(out designerOpenedFile);
|
||||
//
|
||||
// AssertAreEqual(formsDesignerOpenedFile, designerOpenedFile);
|
||||
// }
|
||||
//
|
||||
// void AssertAreEqual(OpenedFile expectedOpenedFile, OpenedFile actualOpenedFile)
|
||||
// {
|
||||
// string fileName = actualOpenedFile.FileName.ToString();
|
||||
// string expectedFileName = expectedOpenedFile.FileName.ToString();
|
||||
//
|
||||
// Assert.AreEqual(expectedFileName, fileName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetSourceFiles_FormsDesignerHasOpenFile_FormsDesignerFileReturnedInFiles()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// OpenedFile designerOpenedFile;
|
||||
// IEnumerable<OpenedFile> files = generator.GetSourceFiles(out designerOpenedFile);
|
||||
// IEnumerator<OpenedFile> enumerator = files.GetEnumerator();
|
||||
// enumerator.MoveNext();
|
||||
// OpenedFile file = enumerator.Current;
|
||||
//
|
||||
// AssertAreEqual(formsDesignerOpenedFile, file);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetCompatibleMethods_OneClassMethod_CallsParseFile()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// CallGetCompatibleMethods();
|
||||
// Assert.IsTrue(generator.IsParseFileCalled);
|
||||
// }
|
||||
//
|
||||
// ICollection CallGetCompatibleMethods()
|
||||
// {
|
||||
// MockEventDescriptor descriptor = new MockEventDescriptor("Click");
|
||||
// return generator.GetCompatibleMethods(descriptor);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetCompatibleMethods_OneClassMethod_ParseFilePassedFileNameOpenInTextEditor()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// CallGetCompatibleMethods();
|
||||
//
|
||||
// string fileName = generator.FileNamePassedToParseFile;
|
||||
// string expectedFileName = "test.py";
|
||||
//
|
||||
// Assert.AreEqual(expectedFileName, fileName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetCompatibleMethods_OneClassMethod_ParseFilePassedTextContentInTextEditor()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// formsDesignerView.DesignerCodeFileContent = "code";
|
||||
// CallGetCompatibleMethods();
|
||||
//
|
||||
// string textContent = generator.TextContentPassedToParseFile;
|
||||
// string expectedTextContent = "code";
|
||||
//
|
||||
// Assert.AreEqual(expectedTextContent, textContent);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetCompatibleMethods_OneMethodWithTwoParameters_MethodNameReturnedInCompatibleMethods()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// ParseInformation parseInfo = generator.CreateParseInfoWithOneMethodWithTwoParameters("button1_click");
|
||||
// generator.ParseInfoToReturnFromParseFile = parseInfo;
|
||||
// ICollection methods = CallGetCompatibleMethods();
|
||||
//
|
||||
// string[] expectedMethods = new string[] { "button1_click" };
|
||||
//
|
||||
// Assert.AreEqual(expectedMethods, methods);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetCompatibleMethods_OneMethodWithNoParameters_NoMethodsReturnedInCompatibleMethods()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// ParseInformation parseInfo = generator.CreateParseInfoWithOneMethod("button1_click");
|
||||
// generator.ParseInfoToReturnFromParseFile = parseInfo;
|
||||
// ICollection methods = CallGetCompatibleMethods();
|
||||
//
|
||||
// Assert.AreEqual(0, methods.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Detach_FormsDesignerViewAlreadyAttached_SetsViewContentToNull()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// generator.Detach();
|
||||
// Assert.IsNull(generator.ViewContent);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenerateMethodBody_PassedDesignerHost_DesignerHostPassedToCodeDomSerializer()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// CreateParametersForGenerateMethodBodyCall();
|
||||
// CallGenerateMethodBody();
|
||||
//
|
||||
// Assert.AreEqual(host, serializer.HostPassedToGenerateInitializeComponentMethodBody);
|
||||
// }
|
||||
//
|
||||
// void CreateParametersForGenerateMethodBodyCall()
|
||||
// {
|
||||
// serializer = new FakeCodeDomSerializer();
|
||||
// generator.SerializerToReturnFromCreateCodeDomSerializer = serializer;
|
||||
// method = MockMethod.CreateMockMethodWithoutAnyAttributes();
|
||||
// host = new MockDesignerLoaderHost();
|
||||
// serializationManager = new FakeDesignerSerializationManager();
|
||||
// }
|
||||
//
|
||||
// string CallGenerateMethodBody()
|
||||
// {
|
||||
// return generator.GenerateMethodBody(method, host, serializationManager);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenerateMethodBody_MethodBodyCreated_ReturnsMethodBodyFromCodeDomSerializer()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// CreateParametersForGenerateMethodBodyCall();
|
||||
// serializer.MethodBodyToReturnFromGenerateMethodBodyCall = "test";
|
||||
// string methodBody = CallGenerateMethodBody();
|
||||
//
|
||||
// string expectedMethodBody = "test";
|
||||
// Assert.AreEqual(expectedMethodBody, methodBody);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenerateMethodBody_PassedDesignerSerializationManager_DesignerSerializationManagerPassedToCodeDomSerializer()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// CreateParametersForGenerateMethodBodyCall();
|
||||
// CallGenerateMethodBody();
|
||||
//
|
||||
// Assert.AreEqual(serializationManager, serializer.SerializationManagerGenerateInitializeComponentMethodBody);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenerateMethodBody_TextEditorOptionsConvertTabsToSpacesIsFalse_MethodBeginColumnIsIndentPassedToGenerateMethodBody()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// CreateParametersForGenerateMethodBodyCall();
|
||||
//
|
||||
// int beginLine = 1;
|
||||
// int beginColumn = 3;
|
||||
// int endLine = 2;
|
||||
// int endColumn = 1;
|
||||
// method.Region = new DomRegion(beginLine, beginColumn, endLine, endColumn);
|
||||
//
|
||||
// textEditorOptions.ConvertTabsToSpaces = false;
|
||||
//
|
||||
// CallGenerateMethodBody();
|
||||
//
|
||||
// int expectedIndent = 3;
|
||||
//
|
||||
// Assert.AreEqual(expectedIndent, serializer.InitialIndentPassedToGenerateInitializeComponentMethodBody);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GenerateMethodBody_ProjectHasRootNamespace_RootNamespacePassedToCodeDomSerializer()
|
||||
// {
|
||||
// CreateDesignerGenerator();
|
||||
// CreateParametersForGenerateMethodBodyCall();
|
||||
//
|
||||
// method.MockDeclaringType.MockProjectContent.ProjectAsIProject.RootNamespace = "Test";
|
||||
//
|
||||
// CallGenerateMethodBody();
|
||||
//
|
||||
// string expectedRootNamespace = "Test";
|
||||
// Assert.AreEqual(expectedRootNamespace, serializer.RootNamespacePassedToGenerateInitializeComponentMethodBody);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,127 +1,127 @@
@@ -1,127 +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); |
||||
} |
||||
} |
||||
} |
||||
//// 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);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,400 +1,400 @@
@@ -1,400 +1,400 @@
|
||||
// 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.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); |
||||
} |
||||
} |
||||
} |
||||
//// 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.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);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,69 +1,69 @@
@@ -1,69 +1,69 @@
|
||||
// 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.IO; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
public class AddInPathHelper |
||||
{ |
||||
string addInName; |
||||
string identity; |
||||
string fileName; |
||||
|
||||
public AddInPathHelper(string addInName) |
||||
{ |
||||
this.addInName = addInName; |
||||
identity = String.Format("ICSharpCode.{0}", addInName); |
||||
fileName = String.Format(@"C:\SharpDevelop\AddIns\{0}\{0}.addin", addInName); |
||||
} |
||||
|
||||
public AddIn CreateDummyAddInInsideAddInTree() |
||||
{ |
||||
RemoveOldAddIn(); |
||||
AddIn addin = CreateAddIn(); |
||||
AddInTree.InsertAddIn(addin); |
||||
return addin; |
||||
} |
||||
|
||||
void RemoveOldAddIn() |
||||
{ |
||||
AddIn oldAddin = FindOldAddIn(); |
||||
if (oldAddin != null) { |
||||
AddInTree.RemoveAddIn(oldAddin); |
||||
} |
||||
} |
||||
|
||||
AddIn FindOldAddIn() |
||||
{ |
||||
foreach (AddIn addin in AddInTree.AddIns) { |
||||
if (addin.Manifest.PrimaryIdentity == identity) { |
||||
return addin; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
AddIn CreateAddIn() |
||||
{ |
||||
string xml = GetAddInXml(); |
||||
AddIn addin = AddIn.Load(new StringReader(xml)); |
||||
addin.FileName = fileName; |
||||
return addin; |
||||
} |
||||
|
||||
string GetAddInXml() |
||||
{ |
||||
string format = |
||||
"<AddIn name='{0}' author= '' copyright='' description=''>\r\n" + |
||||
" <Manifest>\r\n" + |
||||
" <Identity name='{1}'/>\r\n" + |
||||
" </Manifest>\r\n" + |
||||
"</AddIn>"; |
||||
|
||||
return String.Format(format, addInName, identity); |
||||
} |
||||
} |
||||
} |
||||
//// 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.IO;
|
||||
//using ICSharpCode.Core;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Utils
|
||||
//{
|
||||
// public class AddInPathHelper
|
||||
// {
|
||||
// string addInName;
|
||||
// string identity;
|
||||
// string fileName;
|
||||
//
|
||||
// public AddInPathHelper(string addInName)
|
||||
// {
|
||||
// this.addInName = addInName;
|
||||
// identity = String.Format("ICSharpCode.{0}", addInName);
|
||||
// fileName = String.Format(@"C:\SharpDevelop\AddIns\{0}\{0}.addin", addInName);
|
||||
// }
|
||||
//
|
||||
// public AddIn CreateDummyAddInInsideAddInTree()
|
||||
// {
|
||||
// RemoveOldAddIn();
|
||||
// AddIn addin = CreateAddIn();
|
||||
// AddInTree.InsertAddIn(addin);
|
||||
// return addin;
|
||||
// }
|
||||
//
|
||||
// void RemoveOldAddIn()
|
||||
// {
|
||||
// AddIn oldAddin = FindOldAddIn();
|
||||
// if (oldAddin != null) {
|
||||
// AddInTree.RemoveAddIn(oldAddin);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// AddIn FindOldAddIn()
|
||||
// {
|
||||
// foreach (AddIn addin in AddInTree.AddIns) {
|
||||
// if (addin.Manifest.PrimaryIdentity == identity) {
|
||||
// return addin;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// AddIn CreateAddIn()
|
||||
// {
|
||||
// string xml = GetAddInXml();
|
||||
// AddIn addin = AddIn.Load(new StringReader(xml));
|
||||
// addin.FileName = fileName;
|
||||
// return addin;
|
||||
// }
|
||||
//
|
||||
// string GetAddInXml()
|
||||
// {
|
||||
// string format =
|
||||
// "<AddIn name='{0}' author= '' copyright='' description=''>\r\n" +
|
||||
// " <Manifest>\r\n" +
|
||||
// " <Identity name='{1}'/>\r\n" +
|
||||
// " </Manifest>\r\n" +
|
||||
// "</AddIn>";
|
||||
//
|
||||
// return String.Format(format, addInName, identity);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,35 +1,35 @@
@@ -1,35 +1,35 @@
|
||||
// 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.FormsDesigner; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// Derived FormDesignerViewContent class that is used for
|
||||
/// unit testing the PythonDesignerGenerator.
|
||||
/// </summary>
|
||||
public class DerivedFormDesignerViewContent : FormsDesignerViewContent |
||||
{ |
||||
bool mergeFormChangesCalled; |
||||
|
||||
public DerivedFormDesignerViewContent(IViewContent view, ICSharpCode.SharpDevelop.OpenedFile mockFile) |
||||
: base(view, mockFile) |
||||
{ |
||||
} |
||||
|
||||
public override void MergeFormChanges() |
||||
{ |
||||
mergeFormChangesCalled = true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the MergeFormChanges method was called.
|
||||
/// </summary>
|
||||
public bool MergeFormChangesCalled { |
||||
get { return mergeFormChangesCalled; } |
||||
} |
||||
} |
||||
} |
||||
//// 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.FormsDesigner;
|
||||
//using ICSharpCode.SharpDevelop.Gui;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Utils
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Derived FormDesignerViewContent class that is used for
|
||||
// /// unit testing the PythonDesignerGenerator.
|
||||
// /// </summary>
|
||||
// public class DerivedFormDesignerViewContent : FormsDesignerViewContent
|
||||
// {
|
||||
// bool mergeFormChangesCalled;
|
||||
//
|
||||
// public DerivedFormDesignerViewContent(IViewContent view, ICSharpCode.SharpDevelop.OpenedFile mockFile)
|
||||
// : base(view, mockFile)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public override void MergeFormChanges()
|
||||
// {
|
||||
// mergeFormChangesCalled = true;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets whether the MergeFormChanges method was called.
|
||||
// /// </summary>
|
||||
// public bool MergeFormChangesCalled {
|
||||
// get { return mergeFormChangesCalled; }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// 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.NRefactory.TypeSystem; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
// public class MockAttribute : IAttribute
|
||||
// {
|
||||
// IReturnType type;
|
||||
//
|
||||
// public MockAttribute(string name)
|
||||
// {
|
||||
// type = new DefaultReturnType(new MockClass(name));
|
||||
// }
|
||||
//
|
||||
// public IReturnType AttributeType {
|
||||
// get {
|
||||
// return type;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
} |
@ -0,0 +1,166 @@
@@ -0,0 +1,166 @@
|
||||
//// 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 ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Utils
|
||||
//{
|
||||
// public class MockClass : DefaultClass
|
||||
// {
|
||||
// string dotNetName;
|
||||
// IClass compoundClass;
|
||||
//
|
||||
// public MockClass()
|
||||
// : this(String.Empty)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockClass(IProjectContent projectContent)
|
||||
// : this(projectContent, String.Empty)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockClass(IProjectContent projectContent, string fullyQualifiedName)
|
||||
// : this(projectContent, fullyQualifiedName, null)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockClass(string fullyQualifiedName)
|
||||
// : this(fullyQualifiedName, fullyQualifiedName)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockClass(string fullyQualifiedName, string dotNetName)
|
||||
// : this(fullyQualifiedName, dotNetName, null)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockClass(string fullyQualifiedName, string dotNetName, IClass declaringType)
|
||||
// : this(new MockProjectContent(), fullyQualifiedName, dotNetName, declaringType)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockClass(IProjectContent projectContent, string fullyQualifiedName, IClass declaringType)
|
||||
// : this(projectContent, fullyQualifiedName, fullyQualifiedName, declaringType)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockClass(IProjectContent projectContent, string fullyQualifiedName, string dotNetName, IClass declaringType)
|
||||
// : base(new DefaultCompilationUnit(projectContent), declaringType)
|
||||
// {
|
||||
// this.FullyQualifiedName = fullyQualifiedName;
|
||||
// this.dotNetName = dotNetName;
|
||||
//
|
||||
// if (declaringType != null) {
|
||||
// declaringType.InnerClasses.Add(this);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public override string DotNetName {
|
||||
// get { return dotNetName; }
|
||||
// }
|
||||
//
|
||||
// public void SetDotNetName(string name)
|
||||
// {
|
||||
// dotNetName = name;
|
||||
// }
|
||||
//
|
||||
// public MockProjectContent MockProjectContent {
|
||||
// get { return ProjectContent as MockProjectContent; }
|
||||
// }
|
||||
//
|
||||
// public IProject Project {
|
||||
// get { return ProjectContent.Project as IProject; }
|
||||
// }
|
||||
//
|
||||
// public static MockClass CreateMockClassWithoutAnyAttributes()
|
||||
// {
|
||||
// return CreateMockClassWithAttributes(new MockAttribute[0]);
|
||||
// }
|
||||
//
|
||||
// public static MockClass CreateMockClassWithAttributes(IList<MockAttribute> attributes)
|
||||
// {
|
||||
// MockClass mockClass = new MockClass();
|
||||
// mockClass.MockProjectContent.Project = new MockCSharpProject();
|
||||
// mockClass.MockProjectContent.Classes.Add(mockClass);
|
||||
//
|
||||
// foreach (MockAttribute attribute in attributes) {
|
||||
// mockClass.Attributes.Add(attribute);
|
||||
// }
|
||||
// return mockClass;
|
||||
// }
|
||||
//
|
||||
// public static MockClass CreateMockClassWithAttribute(MockAttribute attribute)
|
||||
// {
|
||||
// List<MockAttribute> attributes = new List<MockAttribute>();
|
||||
// attributes.Add(attribute);
|
||||
//
|
||||
// return CreateMockClassWithAttributes(attributes);
|
||||
// }
|
||||
//
|
||||
// public static MockClass CreateClassWithBaseType(string baseTypeName)
|
||||
// {
|
||||
// MockClass baseType = MockClass.CreateMockClassWithoutAnyAttributes();
|
||||
// baseType.FullyQualifiedName = baseTypeName;
|
||||
// MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
|
||||
// c.BaseTypes.Add(new DefaultReturnType(baseType));
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// public void SetCompoundClass(IClass c)
|
||||
// {
|
||||
// this.compoundClass = c;
|
||||
// }
|
||||
//
|
||||
// protected override IReturnType CreateDefaultReturnType()
|
||||
// {
|
||||
// if (compoundClass != null) {
|
||||
// return new DefaultReturnType(compoundClass);
|
||||
// }
|
||||
// return base.CreateDefaultReturnType();
|
||||
// }
|
||||
//
|
||||
// public void AddBaseClass(IClass baseClass)
|
||||
// {
|
||||
// DefaultReturnType returnType = new DefaultReturnType(baseClass);
|
||||
// BaseTypes.Add(returnType);
|
||||
// }
|
||||
//
|
||||
// public DefaultProperty AddProperty(string name)
|
||||
// {
|
||||
// DefaultProperty property = new DefaultProperty(this, name);
|
||||
// Properties.Add(property);
|
||||
// return property;
|
||||
// }
|
||||
//
|
||||
// public void InsertPropertyAtStart(string name)
|
||||
// {
|
||||
// DefaultProperty property = new DefaultProperty(this, name);
|
||||
// Properties.Insert(0, property);
|
||||
// }
|
||||
//
|
||||
// public DefaultEvent AddEvent(string name)
|
||||
// {
|
||||
// DefaultEvent classEvent = new DefaultEvent(this, name);
|
||||
// Events.Add(classEvent);
|
||||
// return classEvent;
|
||||
// }
|
||||
//
|
||||
// public DefaultField AddField(string name)
|
||||
// {
|
||||
// DefaultField field = new DefaultField(this, name);
|
||||
// Fields.Add(field);
|
||||
// return field;
|
||||
// }
|
||||
//
|
||||
// public DefaultMethod AddMethod(string name)
|
||||
// {
|
||||
// DefaultMethod method = new DefaultMethod(this, name);
|
||||
// Methods.Add(method);
|
||||
// return method;
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,174 +1,174 @@
@@ -1,174 +1,174 @@
|
||||
// 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.Diagnostics; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
public class MockDebugger : IDebugger |
||||
{ |
||||
ProcessStartInfo processStartInfo; |
||||
bool startMethodCalled; |
||||
bool startWithoutDebuggingMethodCalled; |
||||
bool stopMethodCalled; |
||||
|
||||
public MockDebugger() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the ProcessStartInfo passed to the Start or StartWithoutDebugging methods.
|
||||
/// </summary>
|
||||
public ProcessStartInfo ProcessStartInfo { |
||||
get { return processStartInfo; } |
||||
} |
||||
|
||||
public bool StartMethodCalled { |
||||
get { return startMethodCalled; } |
||||
} |
||||
|
||||
public bool StartWithoutDebuggingMethodCalled { |
||||
get { return startWithoutDebuggingMethodCalled; } |
||||
} |
||||
|
||||
public bool StopMethodCalled { |
||||
get { return stopMethodCalled; } |
||||
} |
||||
|
||||
public event EventHandler DebugStarting; |
||||
public event EventHandler DebugStarted; |
||||
public event EventHandler IsProcessRunningChanged; |
||||
public event EventHandler DebugStopped; |
||||
|
||||
public bool IsDebugging { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsProcessRunning { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool CanDebug(IProject project) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Start(ProcessStartInfo processStartInfo) |
||||
{ |
||||
this.processStartInfo = processStartInfo; |
||||
startMethodCalled = true; |
||||
} |
||||
|
||||
public void StartWithoutDebugging(ProcessStartInfo processStartInfo) |
||||
{ |
||||
this.processStartInfo = processStartInfo; |
||||
startWithoutDebuggingMethodCalled = true; |
||||
} |
||||
|
||||
public void Stop() |
||||
{ |
||||
stopMethodCalled = true; |
||||
} |
||||
|
||||
public void Break() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Continue() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void StepInto() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void StepOver() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void StepOut() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void ShowAttachDialog() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Attach(System.Diagnostics.Process process) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Detach() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public string GetValueAsString(string variable) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public object GetTooltipControl(Location logicalPosition, string variable) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool SetInstructionPointer(string filename, int line, int column, bool dryRun) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
protected virtual void OnDebugStarting(EventArgs e) |
||||
{ |
||||
if (DebugStarting != null) { |
||||
DebugStarting(this, e); |
||||
} |
||||
} |
||||
|
||||
|
||||
protected virtual void OnDebugStarted(EventArgs e) |
||||
{ |
||||
if (DebugStarted != null) { |
||||
DebugStarted(this, e); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnIsProcessRunningChanged(EventArgs e) |
||||
{ |
||||
if (IsProcessRunningChanged != null) { |
||||
IsProcessRunningChanged(this, e); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnDebugStopped(EventArgs e) |
||||
{ |
||||
if (DebugStopped != null) { |
||||
DebugStopped(this, e); |
||||
} |
||||
} |
||||
|
||||
public bool BreakAtBeginning { get; set; } |
||||
|
||||
public bool IsAttached { get; set; } |
||||
} |
||||
} |
||||
//// 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.Diagnostics;
|
||||
//using ICSharpCode.NRefactory;
|
||||
//using ICSharpCode.SharpDevelop.Debugging;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Utils
|
||||
//{
|
||||
// public class MockDebugger : IDebugger
|
||||
// {
|
||||
// ProcessStartInfo processStartInfo;
|
||||
// bool startMethodCalled;
|
||||
// bool startWithoutDebuggingMethodCalled;
|
||||
// bool stopMethodCalled;
|
||||
//
|
||||
// public MockDebugger()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the ProcessStartInfo passed to the Start or StartWithoutDebugging methods.
|
||||
// /// </summary>
|
||||
// public ProcessStartInfo ProcessStartInfo {
|
||||
// get { return processStartInfo; }
|
||||
// }
|
||||
//
|
||||
// public bool StartMethodCalled {
|
||||
// get { return startMethodCalled; }
|
||||
// }
|
||||
//
|
||||
// public bool StartWithoutDebuggingMethodCalled {
|
||||
// get { return startWithoutDebuggingMethodCalled; }
|
||||
// }
|
||||
//
|
||||
// public bool StopMethodCalled {
|
||||
// get { return stopMethodCalled; }
|
||||
// }
|
||||
//
|
||||
// public event EventHandler DebugStarting;
|
||||
// public event EventHandler DebugStarted;
|
||||
// public event EventHandler IsProcessRunningChanged;
|
||||
// public event EventHandler DebugStopped;
|
||||
//
|
||||
// public bool IsDebugging {
|
||||
// get {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool IsProcessRunning {
|
||||
// get {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool CanDebug(IProject project)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void Start(ProcessStartInfo processStartInfo)
|
||||
// {
|
||||
// this.processStartInfo = processStartInfo;
|
||||
// startMethodCalled = true;
|
||||
// }
|
||||
//
|
||||
// public void StartWithoutDebugging(ProcessStartInfo processStartInfo)
|
||||
// {
|
||||
// this.processStartInfo = processStartInfo;
|
||||
// startWithoutDebuggingMethodCalled = true;
|
||||
// }
|
||||
//
|
||||
// public void Stop()
|
||||
// {
|
||||
// stopMethodCalled = true;
|
||||
// }
|
||||
//
|
||||
// public void Break()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void Continue()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void StepInto()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void StepOver()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void StepOut()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void ShowAttachDialog()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void Attach(System.Diagnostics.Process process)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void Detach()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public string GetValueAsString(string variable)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public object GetTooltipControl(TextLocation logicalPosition, string variable)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public bool SetInstructionPointer(string filename, int line, int column, bool dryRun)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void Dispose()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// protected virtual void OnDebugStarting(EventArgs e)
|
||||
// {
|
||||
// if (DebugStarting != null) {
|
||||
// DebugStarting(this, e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// protected virtual void OnDebugStarted(EventArgs e)
|
||||
// {
|
||||
// if (DebugStarted != null) {
|
||||
// DebugStarted(this, e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected virtual void OnIsProcessRunningChanged(EventArgs e)
|
||||
// {
|
||||
// if (IsProcessRunningChanged != null) {
|
||||
// IsProcessRunningChanged(this, e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected virtual void OnDebugStopped(EventArgs e)
|
||||
// {
|
||||
// if (DebugStopped != null) {
|
||||
// DebugStopped(this, e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool BreakAtBeginning { get; set; }
|
||||
//
|
||||
// public bool IsAttached { get; set; }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,91 +1,91 @@
@@ -1,91 +1,91 @@
|
||||
// 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.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Reflection; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
public class MockDesignerGenerator : IScriptingDesignerGenerator |
||||
{ |
||||
FormsDesignerViewContent viewContent; |
||||
IDesignerHost mergeChangesHost; |
||||
IDesignerSerializationManager mergeChangesSerializationManager; |
||||
|
||||
public MockDesignerGenerator() |
||||
{ |
||||
} |
||||
|
||||
public CodeDomProvider CodeDomProvider { |
||||
get { return null; } |
||||
} |
||||
|
||||
public FormsDesignerViewContent ViewContent { |
||||
get { return this.viewContent; } |
||||
} |
||||
|
||||
public void Attach(FormsDesignerViewContent viewContent) |
||||
{ |
||||
this.viewContent = viewContent; |
||||
} |
||||
|
||||
public void Detach() |
||||
{ |
||||
this.viewContent = null; |
||||
} |
||||
|
||||
public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile) |
||||
{ |
||||
designerCodeFile = this.viewContent.DesignerCodeFile; |
||||
return new [] {designerCodeFile}; |
||||
} |
||||
|
||||
public void MergeFormChanges(CodeCompileUnit unit) |
||||
{ |
||||
} |
||||
|
||||
public void NotifyComponentRenamed(object component, string newName, string oldName) |
||||
{ |
||||
} |
||||
|
||||
public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager) |
||||
{ |
||||
mergeChangesHost = host; |
||||
mergeChangesSerializationManager = serializationManager; |
||||
} |
||||
|
||||
public IDesignerHost MergeChangesHost { |
||||
get { return mergeChangesHost; } |
||||
} |
||||
|
||||
public IDesignerSerializationManager MergeChangesSerializationManager { |
||||
get { return mergeChangesSerializationManager; } |
||||
} |
||||
|
||||
public bool InsertComponentEvent(IComponent component, System.ComponentModel.EventDescriptor edesc, string eventMethodName, string body, out string file, out int position) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ICollection GetCompatibleMethods(EventDescriptor edesc) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ICollection GetCompatibleMethods(EventInfo edesc) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
||||
//// 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.Collections.Generic;
|
||||
//using System.ComponentModel;
|
||||
//using System.ComponentModel.Design;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//using System.Reflection;
|
||||
//using System.Windows.Forms;
|
||||
//
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Utils
|
||||
//{
|
||||
// public class MockDesignerGenerator : IScriptingDesignerGenerator
|
||||
// {
|
||||
// FormsDesignerViewContent viewContent;
|
||||
// IDesignerHost mergeChangesHost;
|
||||
// IDesignerSerializationManager mergeChangesSerializationManager;
|
||||
//
|
||||
// public MockDesignerGenerator()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public CodeDomProvider CodeDomProvider {
|
||||
// get { return null; }
|
||||
// }
|
||||
//
|
||||
// public FormsDesignerViewContent ViewContent {
|
||||
// get { return this.viewContent; }
|
||||
// }
|
||||
//
|
||||
// public void Attach(FormsDesignerViewContent viewContent)
|
||||
// {
|
||||
// this.viewContent = viewContent;
|
||||
// }
|
||||
//
|
||||
// public void Detach()
|
||||
// {
|
||||
// this.viewContent = null;
|
||||
// }
|
||||
//
|
||||
// public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
|
||||
// {
|
||||
// designerCodeFile = this.viewContent.DesignerCodeFile;
|
||||
// return new [] {designerCodeFile};
|
||||
// }
|
||||
//
|
||||
// public void MergeFormChanges(CodeCompileUnit unit)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public void NotifyComponentRenamed(object component, string newName, string oldName)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
|
||||
// {
|
||||
// mergeChangesHost = host;
|
||||
// mergeChangesSerializationManager = serializationManager;
|
||||
// }
|
||||
//
|
||||
// public IDesignerHost MergeChangesHost {
|
||||
// get { return mergeChangesHost; }
|
||||
// }
|
||||
//
|
||||
// public IDesignerSerializationManager MergeChangesSerializationManager {
|
||||
// get { return mergeChangesSerializationManager; }
|
||||
// }
|
||||
//
|
||||
// public bool InsertComponentEvent(IComponent component, System.ComponentModel.EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public ICollection GetCompatibleMethods(EventDescriptor edesc)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public ICollection GetCompatibleMethods(EventInfo edesc)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
//// 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.Generic;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Utils
|
||||
//{
|
||||
// public class MockMethod : DefaultMethod
|
||||
// {
|
||||
// public MockMethod()
|
||||
// : this(String.Empty)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockMethod(string name)
|
||||
// : this(null, name)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockMethod(IClass declaringType)
|
||||
// : this(declaringType, String.Empty)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public MockMethod(IClass declaringType, string name)
|
||||
// : base(declaringType, name)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public static MockMethod CreateMockMethodWithoutAnyAttributes()
|
||||
// {
|
||||
// return CreateMockMethodWithAttributes(new MockAttribute[0]);
|
||||
// }
|
||||
//
|
||||
// public static MockMethod CreateMockMethodWithAttributes(IList<MockAttribute> attributes)
|
||||
// {
|
||||
// MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes();
|
||||
// MockMethod mockMethod = new MockMethod(mockClass);
|
||||
//
|
||||
// foreach (MockAttribute attribute in attributes) {
|
||||
// mockMethod.Attributes.Add(attribute);
|
||||
// }
|
||||
//
|
||||
// return mockMethod;
|
||||
// }
|
||||
//
|
||||
// public static MockMethod CreateMockMethodWithAttribute(MockAttribute attribute)
|
||||
// {
|
||||
// List<MockAttribute> attributes = new List<MockAttribute>();
|
||||
// attributes.Add(attribute);
|
||||
//
|
||||
// return CreateMockMethodWithAttributes(attributes);
|
||||
// }
|
||||
//
|
||||
// public MockClass MockDeclaringType {
|
||||
// get { return DeclaringType as MockClass; }
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,294 +1,294 @@
@@ -1,294 +1,294 @@
|
||||
// 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 ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
public class MockProjectContent : IProjectContent |
||||
{ |
||||
string namespacePassedToNamespaceExistsMethod; |
||||
List<string> namespacesToAdd = new List<string>(); |
||||
SearchTypeResult searchTypeResult; |
||||
bool searchTypeCalled; |
||||
SearchTypeRequest searchTypeRequest; |
||||
IClass classToReturnFromGetClass; |
||||
string getClassName; |
||||
List<IClass> classesInProjectContent = new List<IClass>(); |
||||
string namespacePassedToGetNamespaceContentsMethod; |
||||
string classNameForGetClass; |
||||
bool namespaceExistsCalled; |
||||
object project; |
||||
Dictionary<string, List<ICompletionEntry>> namespaceContents = new Dictionary<string, List<ICompletionEntry>>(); |
||||
LanguageProperties language = LanguageProperties.CSharp; |
||||
List<IProjectContent> referencedContents = new List<IProjectContent>(); |
||||
|
||||
/// <summary>
|
||||
/// Gets the namespaces that will be added when the
|
||||
/// AddNamespaceContents method is called.
|
||||
/// </summary>
|
||||
public List<string> NamespacesToAdd { |
||||
get { return namespacesToAdd; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the NamespaceExists method was called.
|
||||
/// </summary>
|
||||
public bool NamespaceExistsCalled { |
||||
get { return namespaceExistsCalled; } |
||||
} |
||||
|
||||
public string NamespacePassedToNamespaceExistsMethod { |
||||
get { return namespacePassedToNamespaceExistsMethod; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the SearchTypeResult to return from the
|
||||
/// SearchType method.
|
||||
/// </summary>
|
||||
public SearchTypeResult SearchTypeResultToReturn { |
||||
get { return searchTypeResult; } |
||||
set { searchTypeResult = value; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the SearchType method was called.
|
||||
/// </summary>
|
||||
public bool SearchTypeCalled { |
||||
get { return searchTypeCalled; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the search type request passed to the SearchType method.
|
||||
/// </summary>
|
||||
public SearchTypeRequest SearchTypeRequest { |
||||
get { return searchTypeRequest; } |
||||
} |
||||
|
||||
public void SetClassToReturnFromGetClass(string className, IClass classToReturn) |
||||
{ |
||||
classToReturnFromGetClass = classToReturn; |
||||
classNameForGetClass = className; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the name passed to the GetClass method.
|
||||
/// </summary>
|
||||
public string GetClassName { |
||||
get { return getClassName; } |
||||
} |
||||
|
||||
public string NamespacePassedToGetNamespaceContentsMethod { |
||||
get { return namespacePassedToGetNamespaceContentsMethod; } |
||||
} |
||||
|
||||
#region IProjectContent
|
||||
public event EventHandler ReferencedContentsChanged; |
||||
|
||||
public LanguageProperties Language { |
||||
get { return language; } |
||||
} |
||||
|
||||
public XmlDoc XmlDoc { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public bool IsUpToDate { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public ICollection<IClass> Classes { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public ICollection<string> NamespaceNames { |
||||
get { |
||||
List<string> names = new List<string>(); |
||||
foreach (string existingNamespace in namespaceContents.Keys) { |
||||
names.Add(existingNamespace); |
||||
} |
||||
return names; |
||||
} |
||||
} |
||||
|
||||
public ICollection<IProjectContent> ReferencedContents { |
||||
get { return this.referencedContents; } |
||||
} |
||||
|
||||
public IUsing DefaultImports { |
||||
get { return null; } |
||||
} |
||||
|
||||
public object Project { |
||||
get { return project; } |
||||
set { project = value; } |
||||
} |
||||
|
||||
public SystemTypes SystemTypes { |
||||
get { |
||||
return new SystemTypes(this); |
||||
} |
||||
} |
||||
|
||||
public string GetXmlDocumentation(string memberTag) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public void AddClassToNamespaceList(IClass addClass) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void RemoveCompilationUnit(ICompilationUnit oldUnit) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IClass GetClass(string typeName, int typeParameterCount) |
||||
{ |
||||
getClassName = typeName; |
||||
|
||||
// If a class name is specified then only return a class
|
||||
// if we have a match.
|
||||
if (classNameForGetClass != null) { |
||||
if (typeName == classNameForGetClass) { |
||||
return classToReturnFromGetClass; |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
return classToReturnFromGetClass; |
||||
} |
||||
|
||||
public void AddExistingNamespaceContents(string namespaceName, List<ICompletionEntry> items) |
||||
{ |
||||
namespaceContents.Add(namespaceName, items); |
||||
} |
||||
|
||||
public bool NamespaceExists(string name) |
||||
{ |
||||
namespaceExistsCalled = true; |
||||
namespacePassedToNamespaceExistsMethod = name; |
||||
|
||||
return namespaceContents.ContainsKey(name); |
||||
} |
||||
|
||||
public List<ICompletionEntry> GetNamespaceContents(string nameSpace) |
||||
{ |
||||
namespacePassedToGetNamespaceContentsMethod = nameSpace; |
||||
|
||||
List<ICompletionEntry> items; |
||||
if (namespaceContents.TryGetValue(nameSpace, out items)) { |
||||
return items; |
||||
} |
||||
return new List<ICompletionEntry>(); |
||||
} |
||||
|
||||
public IClass GetClass(string typeName, int typeParameterCount, LanguageProperties language, GetClassOptions options) |
||||
{ |
||||
return GetClass(typeName, typeParameterCount); |
||||
} |
||||
|
||||
public bool NamespaceExists(string name, LanguageProperties language, bool lookInReferences) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void AddNamespaceContents(List<ICompletionEntry> list, string subNameSpace, LanguageProperties language, bool lookInReferences) |
||||
{ |
||||
// Add the namespaces to the list.
|
||||
foreach (string ns in namespacesToAdd) { |
||||
list.Add(new NamespaceEntry(ns)); |
||||
} |
||||
|
||||
// Add the classes in this project content.
|
||||
foreach (IClass c in classesInProjectContent) { |
||||
list.Add(c); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of classes that will be added to the list
|
||||
/// when the AddNamespaceContents is called.
|
||||
/// </summary>
|
||||
public List<IClass> ClassesInProjectContent { |
||||
get { return classesInProjectContent; } |
||||
} |
||||
|
||||
public string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public SearchTypeResult SearchType(SearchTypeRequest request) |
||||
{ |
||||
searchTypeCalled = true; |
||||
searchTypeRequest = request; |
||||
return searchTypeResult; |
||||
} |
||||
|
||||
public IClass GetClassByReflectionName(string fullMemberName, bool lookInReferences) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public FilePosition GetPosition(IEntity entity) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IList<IAttribute> GetAssemblyAttributes() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool InternalsVisibleTo(IProjectContent otherProjectContent) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public string AssemblyName { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public List<ICompletionEntry> GetAllContents() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void AddAllContents(List<ICompletionEntry> list, LanguageProperties language, bool lookInReferences) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
#endregion
|
||||
|
||||
protected virtual void OnReferencedContentsChanged(EventArgs e) |
||||
{ |
||||
if (ReferencedContentsChanged != null) { |
||||
ReferencedContentsChanged(this, e); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
//// 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 ICSharpCode.SharpDevelop.Dom;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Utils
|
||||
//{
|
||||
// public class MockProjectContent : IProjectContent
|
||||
// {
|
||||
// string namespacePassedToNamespaceExistsMethod;
|
||||
// List<string> namespacesToAdd = new List<string>();
|
||||
// SearchTypeResult searchTypeResult;
|
||||
// bool searchTypeCalled;
|
||||
// SearchTypeRequest searchTypeRequest;
|
||||
// IClass classToReturnFromGetClass;
|
||||
// string getClassName;
|
||||
// List<IClass> classesInProjectContent = new List<IClass>();
|
||||
// string namespacePassedToGetNamespaceContentsMethod;
|
||||
// string classNameForGetClass;
|
||||
// bool namespaceExistsCalled;
|
||||
// object project;
|
||||
// Dictionary<string, List<ICompletionEntry>> namespaceContents = new Dictionary<string, List<ICompletionEntry>>();
|
||||
// LanguageProperties language = LanguageProperties.CSharp;
|
||||
// List<IProjectContent> referencedContents = new List<IProjectContent>();
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the namespaces that will be added when the
|
||||
// /// AddNamespaceContents method is called.
|
||||
// /// </summary>
|
||||
// public List<string> NamespacesToAdd {
|
||||
// get { return namespacesToAdd; }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets whether the NamespaceExists method was called.
|
||||
// /// </summary>
|
||||
// public bool NamespaceExistsCalled {
|
||||
// get { return namespaceExistsCalled; }
|
||||
// }
|
||||
//
|
||||
// public string NamespacePassedToNamespaceExistsMethod {
|
||||
// get { return namespacePassedToNamespaceExistsMethod; }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets or sets the SearchTypeResult to return from the
|
||||
// /// SearchType method.
|
||||
// /// </summary>
|
||||
// public SearchTypeResult SearchTypeResultToReturn {
|
||||
// get { return searchTypeResult; }
|
||||
// set { searchTypeResult = value; }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets whether the SearchType method was called.
|
||||
// /// </summary>
|
||||
// public bool SearchTypeCalled {
|
||||
// get { return searchTypeCalled; }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the search type request passed to the SearchType method.
|
||||
// /// </summary>
|
||||
// public SearchTypeRequest SearchTypeRequest {
|
||||
// get { return searchTypeRequest; }
|
||||
// }
|
||||
//
|
||||
// public void SetClassToReturnFromGetClass(string className, IClass classToReturn)
|
||||
// {
|
||||
// classToReturnFromGetClass = classToReturn;
|
||||
// classNameForGetClass = className;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the name passed to the GetClass method.
|
||||
// /// </summary>
|
||||
// public string GetClassName {
|
||||
// get { return getClassName; }
|
||||
// }
|
||||
//
|
||||
// public string NamespacePassedToGetNamespaceContentsMethod {
|
||||
// get { return namespacePassedToGetNamespaceContentsMethod; }
|
||||
// }
|
||||
//
|
||||
// #region IProjectContent
|
||||
// public event EventHandler ReferencedContentsChanged;
|
||||
//
|
||||
// public LanguageProperties Language {
|
||||
// get { return language; }
|
||||
// }
|
||||
//
|
||||
// public XmlDoc XmlDoc {
|
||||
// get {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool IsUpToDate {
|
||||
// get {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public ICollection<IClass> Classes {
|
||||
// get {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public ICollection<string> NamespaceNames {
|
||||
// get {
|
||||
// List<string> names = new List<string>();
|
||||
// foreach (string existingNamespace in namespaceContents.Keys) {
|
||||
// names.Add(existingNamespace);
|
||||
// }
|
||||
// return names;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public ICollection<IProjectContent> ReferencedContents {
|
||||
// get { return this.referencedContents; }
|
||||
// }
|
||||
//
|
||||
// public IUsing DefaultImports {
|
||||
// get { return null; }
|
||||
// }
|
||||
//
|
||||
// public object Project {
|
||||
// get { return project; }
|
||||
// set { project = value; }
|
||||
// }
|
||||
//
|
||||
// public SystemTypes SystemTypes {
|
||||
// get {
|
||||
// return new SystemTypes(this);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public string GetXmlDocumentation(string memberTag)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public void AddClassToNamespaceList(IClass addClass)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void RemoveCompilationUnit(ICompilationUnit oldUnit)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public IClass GetClass(string typeName, int typeParameterCount)
|
||||
// {
|
||||
// getClassName = typeName;
|
||||
//
|
||||
// // If a class name is specified then only return a class
|
||||
// // if we have a match.
|
||||
// if (classNameForGetClass != null) {
|
||||
// if (typeName == classNameForGetClass) {
|
||||
// return classToReturnFromGetClass;
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// return classToReturnFromGetClass;
|
||||
// }
|
||||
//
|
||||
// public void AddExistingNamespaceContents(string namespaceName, List<ICompletionEntry> items)
|
||||
// {
|
||||
// namespaceContents.Add(namespaceName, items);
|
||||
// }
|
||||
//
|
||||
// public bool NamespaceExists(string name)
|
||||
// {
|
||||
// namespaceExistsCalled = true;
|
||||
// namespacePassedToNamespaceExistsMethod = name;
|
||||
//
|
||||
// return namespaceContents.ContainsKey(name);
|
||||
// }
|
||||
//
|
||||
// public List<ICompletionEntry> GetNamespaceContents(string nameSpace)
|
||||
// {
|
||||
// namespacePassedToGetNamespaceContentsMethod = nameSpace;
|
||||
//
|
||||
// List<ICompletionEntry> items;
|
||||
// if (namespaceContents.TryGetValue(nameSpace, out items)) {
|
||||
// return items;
|
||||
// }
|
||||
// return new List<ICompletionEntry>();
|
||||
// }
|
||||
//
|
||||
// public IClass GetClass(string typeName, int typeParameterCount, LanguageProperties language, GetClassOptions options)
|
||||
// {
|
||||
// return GetClass(typeName, typeParameterCount);
|
||||
// }
|
||||
//
|
||||
// public bool NamespaceExists(string name, LanguageProperties language, bool lookInReferences)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void AddNamespaceContents(List<ICompletionEntry> list, string subNameSpace, LanguageProperties language, bool lookInReferences)
|
||||
// {
|
||||
// // Add the namespaces to the list.
|
||||
// foreach (string ns in namespacesToAdd) {
|
||||
// list.Add(new NamespaceEntry(ns));
|
||||
// }
|
||||
//
|
||||
// // Add the classes in this project content.
|
||||
// foreach (IClass c in classesInProjectContent) {
|
||||
// list.Add(c);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the list of classes that will be added to the list
|
||||
// /// when the AddNamespaceContents is called.
|
||||
// /// </summary>
|
||||
// public List<IClass> ClassesInProjectContent {
|
||||
// get { return classesInProjectContent; }
|
||||
// }
|
||||
//
|
||||
// public string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public SearchTypeResult SearchType(SearchTypeRequest request)
|
||||
// {
|
||||
// searchTypeCalled = true;
|
||||
// searchTypeRequest = request;
|
||||
// return searchTypeResult;
|
||||
// }
|
||||
//
|
||||
// public IClass GetClassByReflectionName(string fullMemberName, bool lookInReferences)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public FilePosition GetPosition(IEntity entity)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void Dispose()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public IList<IAttribute> GetAssemblyAttributes()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public bool InternalsVisibleTo(IProjectContent otherProjectContent)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public string AssemblyName {
|
||||
// get {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public List<ICompletionEntry> GetAllContents()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
//
|
||||
// public void AddAllContents(List<ICompletionEntry> list, LanguageProperties language, bool lookInReferences)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
// protected virtual void OnReferencedContentsChanged(EventArgs e)
|
||||
// {
|
||||
// if (ReferencedContentsChanged != null) {
|
||||
// ReferencedContentsChanged(this, e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,73 +1,73 @@
@@ -1,73 +1,73 @@
|
||||
// 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.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace ICSharpCode.Scripting.Tests.Utils |
||||
{ |
||||
public class TestableScriptingDesignerGenerator : ScriptingDesignerGenerator |
||||
{ |
||||
public bool IsParseFileCalled; |
||||
public ParseInformation ParseInfoToReturnFromParseFile; |
||||
public string FileNamePassedToParseFile; |
||||
public string TextContentPassedToParseFile; |
||||
public FakeCodeDomSerializer SerializerToReturnFromCreateCodeDomSerializer; |
||||
|
||||
public TestableScriptingDesignerGenerator(ITextEditorOptions textEditorOptions) |
||||
: base(textEditorOptions) |
||||
{ |
||||
} |
||||
|
||||
public ParseInformation CreateParseInfoWithOneClass() |
||||
{ |
||||
MockClass c = CreateClass(); |
||||
return new ParseInformation(c.CompilationUnit); |
||||
} |
||||
|
||||
MockClass CreateClass() |
||||
{ |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
c.CompilationUnit.Classes.Add(c); |
||||
return c; |
||||
} |
||||
|
||||
protected override ParseInformation ParseFile(string fileName, string textContent) |
||||
{ |
||||
IsParseFileCalled = true; |
||||
FileNamePassedToParseFile = fileName; |
||||
TextContentPassedToParseFile = textContent; |
||||
|
||||
return ParseInfoToReturnFromParseFile; |
||||
} |
||||
|
||||
public ParseInformation CreateParseInfoWithOneMethod(string name) |
||||
{ |
||||
MockMethod method = CreateMethod(name); |
||||
return new ParseInformation(method.CompilationUnit); |
||||
} |
||||
|
||||
MockMethod CreateMethod(string name) |
||||
{ |
||||
MockClass c = CreateClass(); |
||||
MockMethod method = new MockMethod(c, name); |
||||
c.Methods.Add(method); |
||||
return method; |
||||
} |
||||
|
||||
public ParseInformation CreateParseInfoWithOneMethodWithTwoParameters(string name) |
||||
{ |
||||
MockMethod method = CreateMethod(name); |
||||
method.Parameters.Add(new MockParameter()); |
||||
method.Parameters.Add(new MockParameter()); |
||||
return new ParseInformation(method.CompilationUnit); |
||||
} |
||||
|
||||
public override IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options) |
||||
{ |
||||
return SerializerToReturnFromCreateCodeDomSerializer; |
||||
} |
||||
} |
||||
} |
||||
//// 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.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using UnitTesting.Tests.Utils;
|
||||
//
|
||||
//namespace ICSharpCode.Scripting.Tests.Utils
|
||||
//{
|
||||
// public class TestableScriptingDesignerGenerator : ScriptingDesignerGenerator
|
||||
// {
|
||||
// public bool IsParseFileCalled;
|
||||
// public ParseInformation ParseInfoToReturnFromParseFile;
|
||||
// public string FileNamePassedToParseFile;
|
||||
// public string TextContentPassedToParseFile;
|
||||
// public FakeCodeDomSerializer SerializerToReturnFromCreateCodeDomSerializer;
|
||||
//
|
||||
// public TestableScriptingDesignerGenerator(ITextEditorOptions textEditorOptions)
|
||||
// : base(textEditorOptions)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public ParseInformation CreateParseInfoWithOneClass()
|
||||
// {
|
||||
// MockClass c = CreateClass();
|
||||
// return new ParseInformation(c.CompilationUnit);
|
||||
// }
|
||||
//
|
||||
// MockClass CreateClass()
|
||||
// {
|
||||
// MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
|
||||
// c.CompilationUnit.Classes.Add(c);
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// protected override ParseInformation ParseFile(string fileName, string textContent)
|
||||
// {
|
||||
// IsParseFileCalled = true;
|
||||
// FileNamePassedToParseFile = fileName;
|
||||
// TextContentPassedToParseFile = textContent;
|
||||
//
|
||||
// return ParseInfoToReturnFromParseFile;
|
||||
// }
|
||||
//
|
||||
// public ParseInformation CreateParseInfoWithOneMethod(string name)
|
||||
// {
|
||||
// MockMethod method = CreateMethod(name);
|
||||
// return new ParseInformation(method.CompilationUnit);
|
||||
// }
|
||||
//
|
||||
// MockMethod CreateMethod(string name)
|
||||
// {
|
||||
// MockClass c = CreateClass();
|
||||
// MockMethod method = new MockMethod(c, name);
|
||||
// c.Methods.Add(method);
|
||||
// return method;
|
||||
// }
|
||||
//
|
||||
// public ParseInformation CreateParseInfoWithOneMethodWithTwoParameters(string name)
|
||||
// {
|
||||
// MockMethod method = CreateMethod(name);
|
||||
// method.Parameters.Add(new MockParameter());
|
||||
// method.Parameters.Add(new MockParameter());
|
||||
// return new ParseInformation(method.CompilationUnit);
|
||||
// }
|
||||
//
|
||||
// public override IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
|
||||
// {
|
||||
// return SerializerToReturnFromCreateCodeDomSerializer;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,36 +1,36 @@
@@ -1,36 +1,36 @@
|
||||
// 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.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; |
||||
} |
||||
} |
||||
} |
||||
//// 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.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;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue