From 42ae86a467dafca54686ab9bfbebacd72c9a1dbc Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 8 Sep 2012 17:10:39 +0200 Subject: [PATCH] Started porting UnitTesting.Tests to the new architecture. --- .../IRegisteredTestFrameworks.cs | 0 .../ITestFramework.cs | 0 .../ITestFrameworkFactory.cs | 0 .../ITestResultsMonitor.cs | 0 .../RegisteredTestFrameworks.cs | 0 .../TestFrameworkDescriptor.cs | 0 .../TestFrameworkDoozer.cs | 0 .../TestFrameworkFactory.cs | 0 .../TestService.cs | 0 .../Analysis/UnitTesting/Model/TestClass.cs | 4 +- .../Analysis/UnitTesting/Model/TestProject.cs | 28 +- .../NUnit/NUnitConsoleApplication.cs | 2 +- .../UnitTesting/NUnit/NUnitTestFramework.cs | 17 +- .../NUnitTestFrameworkIsTestClassTests.cs | 1 - .../NUnitTestFrameworkIsTestMemberTests.cs | 1 - .../NUnitTestResultFailureTestFixture.cs | 1 - ...ConditionIsValidForClassNodeTestFixture.cs | 8 +- ...stableConditionIsValidMethodTestFixture.cs | 5 +- .../UnitTestingOptionsPanelTestFixture.cs | 149 ---------- ...ractBaseClassWithTestMethodsTestFixture.cs | 6 +- .../Test/Project/BaseTestMethodTestFixture.cs | 7 +- .../DoubleNestedTestClassWithBaseType.cs | 7 +- .../DuplicateClassNameChangedTestFixture.cs | 15 +- .../Project/DuplicateClassNameTestFixture.cs | 35 +-- .../Project/DuplicateMethodNameTestFixture.cs | 7 +- ...uplicateProjectRootNamespaceTestFixture.cs | 1 - .../Test/Project/EmptyProjectTestFixture.cs | 84 ++---- .../Project/EmptyRootNamespaceTestFixture.cs | 1 - .../Project/InnerClassInTestFixtureTests.cs | 93 ++---- .../InnerClassMethodRenamedTestFixture.cs | 67 ++--- .../InnerClassNameChangesTestFixture.cs | 50 +++- .../Test/Project/InnerClassTestFixture.cs | 43 +-- ...sTestFixtureAttributeRemovedTestFixture.cs | 50 ++-- .../Test/Project/InnerClassTestFixtureBase.cs | 61 ---- .../OverriddenBaseTestMethodTestFixture.cs | 6 +- .../Test/Project/ProjectTestFixtureBase.cs | 70 +++++ .../Test/Project/RemovedClassesTestFixture.cs | 107 ------- ...TestMethodUsesTestFrameworksTestFixture.cs | 57 ---- ...efinedAsTestMembersByTestFrameworkTests.cs | 39 +-- .../TestClassWithOneMethodTestFixture.cs | 84 ++---- .../TestClassWithTwoMethodsTestFixture.cs | 9 +- .../TestMethodsInBaseClassTestFixture.cs | 14 +- ...estProjectUsesTestFrameworksTestFixture.cs | 86 ------ .../TestProjectWithOneClassTestFixture.cs | 20 +- .../ThreeTestClassesTestResultsTestFixture.cs | 1 - .../ThreeTestMethodsTestResultsTestFixture.cs | 1 - ...woBaseClassesWithTestMethodsTestFixture.cs | 8 +- .../TwoProjectRootNamespacesTestFixture.cs | 2 - .../ClassTestFixtureSelectedTestFixture.cs | 1 - .../ClassWithNoRootNamespaceTestFixture.cs | 2 +- .../GoToSelectedBaseClassMethodTestFixture.cs | 2 - .../Test/Tree/OneTestClassTestFixture.cs | 9 +- ...UnitTestsPadWithSolutionOpenTestFixture.cs | 1 - .../Test/Tree/RunProjectTestsTestFixture.cs | 7 +- .../Tree/TestResultFailureTaskTestFixture.cs | 3 +- ...sultFailureTaskWithNoMessageTestFixture.cs | 3 +- .../Tree/TestResultIgnoreTaskTestFixture.cs | 3 +- ...esultIgnoreTaskWithNoMessageTestFixture.cs | 2 +- ...askWithoutMatchingTestMethodTestFixture.cs | 3 +- .../Test/Tree/TestableConditionTests.cs | 7 +- .../Test/Tree/TreeNodeSortingTestFixture.cs | 6 +- ...ClassesInDifferentNamespacesTestFixture.cs | 1 - .../UnitTesting/Test/UnitTesting.Tests.csproj | 114 ++----- .../Test/Utils/DerivedTestProjectTreeNode.cs | 28 -- .../Test/Utils/DerivedTestTreeView.cs | 29 -- .../Utils/DerivedUnitTestingOptionsPanel.cs | 38 --- .../Test/Utils/DerivedUnitTestsPad.cs | 150 ---------- .../Utils/DummyParserServiceTestTreeView.cs | 43 --- .../UnitTesting/Test/Utils/MockAddInTree.cs | 35 ++- .../UnitTesting/Test/Utils/MockAmbience.cs | 98 ------ .../UnitTesting/Test/Utils/MockAttribute.cs | 65 ---- .../Test/Utils/MockCSharpProject.cs | 9 +- .../UnitTesting/Test/Utils/MockClass.cs | 166 ----------- .../UnitTesting/Test/Utils/MockDebugger.cs | 10 +- .../UnitTesting/Test/Utils/MockFileService.cs | 24 +- .../UnitTesting/Test/Utils/MockMember.cs | 272 ----------------- .../UnitTesting/Test/Utils/MockMemberNode.cs | 21 -- .../Test/Utils/MockMessageService.cs | 30 -- .../UnitTesting/Test/Utils/MockMethod.cs | 62 ---- .../Test/Utils/MockNUnitTestFramework.cs | 14 +- .../Test/Utils/MockNUnitTestRunnerContext.cs | 4 - .../UnitTesting/Test/Utils/MockParameter.cs | 94 ------ .../Test/Utils/MockProjectContent.cs | 190 ------------ .../Utils/MockRegisteredTestFrameworks.cs | 1 - .../Test/Utils/MockRunTestCommandContext.cs | 4 +- .../UnitTesting/Test/Utils/MockTaskService.cs | 4 +- .../Test/Utils/MockTestFramework.cs | 31 +- .../Test/Utils/MockTestResultsMonitor.cs | 2 +- .../UnitTesting/Test/Utils/MockTestRunner.cs | 4 +- .../Test/Utils/MockTestTreeView.cs | 9 +- .../UnitTesting/Test/Utils/TaskComparison.cs | 6 +- .../Test/Utils/TestProjectHelper.cs | 3 +- ...reateMockClassWithAttributesTestFixture.cs | 91 ------ ...MockClassWithSingleAttributeTestFixture.cs | 49 --- ...ockClassWithoutAnyAttributesTestFixture.cs | 52 ---- ...eateMockMethodWithAttributesTestFixture.cs | 67 ----- ...ockMethodWithSingleAttributeTestFixture.cs | 49 --- ...ckMethodWithoutAnyAttributesTestFixture.cs | 40 --- .../CreateProjectWithOutputPathTestFixture.cs | 1 - ...TestProjectWithOneTestMethodTestFixture.cs | 7 +- ...estProjectWithTwoTestMethodsTestFixture.cs | 7 +- .../Test/Utils/Tests/MockClassTests.cs | 281 ------------------ .../Utils/Tests/MockFileServiceTestFixture.cs | 1 - .../Tests/MockMessageServiceTestFixture.cs | 65 ---- .../Test/Utils/Tests/MockMethodTestFixture.cs | 40 --- .../Tests/MockProjectContentTestFixture.cs | 51 ---- .../Tests/MockTestFrameworkTestFixture.cs | 1 - .../Utils/Tests/TaskComparisonTestFixture.cs | 8 +- .../Analysis/UnitTesting/UnitTesting.csproj | 20 +- .../XmlEditor/Test/Utils/MockDocument.cs | 8 + .../Highlighting/HtmlClipboardTests.cs | 2 +- 111 files changed, 510 insertions(+), 3187 deletions(-) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/IRegisteredTestFrameworks.cs (100%) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/ITestFramework.cs (100%) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/ITestFrameworkFactory.cs (100%) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/ITestResultsMonitor.cs (100%) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/RegisteredTestFrameworks.cs (100%) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/TestFrameworkDescriptor.cs (100%) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/TestFrameworkDoozer.cs (100%) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/TestFrameworkFactory.cs (100%) rename src/AddIns/Analysis/UnitTesting/{TestFramework => Frameworks}/TestService.cs (100%) delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs create mode 100644 src/AddIns/Analysis/UnitTesting/Test/Project/ProjectTestFixtureBase.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestProjectTreeNode.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestingOptionsPanel.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockAmbience.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockAttribute.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockMember.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockMemberNode.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockParameter.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockClassTests.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMethodTestFixture.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectContentTestFixture.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/IRegisteredTestFrameworks.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/IRegisteredTestFrameworks.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/IRegisteredTestFrameworks.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/IRegisteredTestFrameworks.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/ITestFramework.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/ITestFramework.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/ITestFramework.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/ITestFramework.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/ITestFrameworkFactory.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/ITestFrameworkFactory.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/ITestFrameworkFactory.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/ITestFrameworkFactory.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/ITestResultsMonitor.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/ITestResultsMonitor.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/ITestResultsMonitor.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/ITestResultsMonitor.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/RegisteredTestFrameworks.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/RegisteredTestFrameworks.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/RegisteredTestFrameworks.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/RegisteredTestFrameworks.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkDescriptor.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkDescriptor.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkDescriptor.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkDescriptor.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkDoozer.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkDoozer.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkDoozer.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkDoozer.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkFactory.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkFactory.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkFactory.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkFactory.cs diff --git a/src/AddIns/Analysis/UnitTesting/TestFramework/TestService.cs b/src/AddIns/Analysis/UnitTesting/Frameworks/TestService.cs similarity index 100% rename from src/AddIns/Analysis/UnitTesting/TestFramework/TestService.cs rename to src/AddIns/Analysis/UnitTesting/Frameworks/TestService.cs diff --git a/src/AddIns/Analysis/UnitTesting/Model/TestClass.cs b/src/AddIns/Analysis/UnitTesting/Model/TestClass.cs index c313a13e7b..c9f0b1088d 100644 --- a/src/AddIns/Analysis/UnitTesting/Model/TestClass.cs +++ b/src/AddIns/Analysis/UnitTesting/Model/TestClass.cs @@ -63,7 +63,7 @@ namespace ICSharpCode.UnitTesting /// /// Gets the fully qualified name of the class. /// - public string ReflectionName { + public string QualifiedName { get { return parts[0].ReflectionName; } } @@ -190,7 +190,7 @@ namespace ICSharpCode.UnitTesting public override string ToString() { - return string.Format("[TestClass TestResult={0}, Name={1}]", testResult, this.ReflectionName); + return string.Format("[TestClass TestResult={0}, Name={1}]", testResult, this.QualifiedName); } } } \ No newline at end of file diff --git a/src/AddIns/Analysis/UnitTesting/Model/TestProject.cs b/src/AddIns/Analysis/UnitTesting/Model/TestProject.cs index 4ea90b511a..95fe9a078f 100644 --- a/src/AddIns/Analysis/UnitTesting/Model/TestProject.cs +++ b/src/AddIns/Analysis/UnitTesting/Model/TestProject.cs @@ -122,14 +122,9 @@ namespace ICSharpCode.UnitTesting public TestMember GetTestMember(string reflectionName) { - foreach (var tc in testClasses) { - var result = TreeTraversal.PostOrder(tc, c => c.NestedClasses) - .SelectMany(c => c.Members) - .SingleOrDefault(m => reflectionName.Equals(m.Member.ReflectionName, StringComparison.Ordinal)); - if (result != null) - return result; - } - return null; + return TreeTraversal.PostOrder(testClasses, c => c.NestedClasses) + .SelectMany(c => c.Members) + .FirstOrDefault(m => reflectionName.Equals(m.Member.ReflectionName, StringComparison.Ordinal)); } public TestClass GetTestClass(ITypeDefinition typeDefinition) @@ -142,11 +137,18 @@ namespace ICSharpCode.UnitTesting public TestClass GetTestClass(string reflectionName) { - foreach (var tc in testClasses) { - foreach (var c in TreeTraversal.PostOrder(tc, c => c.NestedClasses)) { - var method = c.Members.SingleOrDefault(m => reflectionName.Equals(m.Member.ReflectionName, StringComparison.Ordinal)); - if (method != null) - return c; + int pos = reflectionName.LastIndexOf('+'); + if (pos < 0) { + // top-level class + foreach (var tc in testClasses) { + if (tc.QualifiedName == reflectionName) + return tc; + } + } else { + // nested class + TestClass declaringClass = GetTestClass(reflectionName.Substring(0, pos)); + if (declaringClass != null) { + return declaringClass.NestedClasses.FirstOrDefault(t => t.QualifiedName == reflectionName); } } return null; diff --git a/src/AddIns/Analysis/UnitTesting/NUnit/NUnitConsoleApplication.cs b/src/AddIns/Analysis/UnitTesting/NUnit/NUnitConsoleApplication.cs index a7ca1d29ea..175e8f3135 100644 --- a/src/AddIns/Analysis/UnitTesting/NUnit/NUnitConsoleApplication.cs +++ b/src/AddIns/Analysis/UnitTesting/NUnit/NUnitConsoleApplication.cs @@ -36,7 +36,7 @@ namespace ICSharpCode.UnitTesting NamespaceFilter = selectedTests.NamespaceFilter; } if (selectedTests.Class != null) { - Fixture = selectedTests.Class.ReflectionName; + Fixture = selectedTests.Class.QualifiedName; if (selectedTests.Method != null) { Test = selectedTests.Method.Member.Name; } diff --git a/src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs b/src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs index e736420365..b411560f47 100644 --- a/src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs +++ b/src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs @@ -28,8 +28,9 @@ namespace ICSharpCode.UnitTesting return new NUnitTestDebugger(); } - static readonly ITypeReference testAttribute = new GetClassTypeReference("NUnit.Framework", "TestAttribute", 0); - static readonly ITypeReference testCaseAttribute = new GetClassTypeReference("NUnit.Framework", "TestCaseAttribute", 0); + static readonly ITypeReference testAttributeRef = new GetClassTypeReference("NUnit.Framework", "TestAttribute", 0); + static readonly ITypeReference testCaseAttributeRef = new GetClassTypeReference("NUnit.Framework", "TestCaseAttribute", 0); + static readonly ITypeReference testFixtureAttributeRef = new GetClassTypeReference("NUnit.Framework", "TestFixtureAttribute", 0); /// /// Determines whether the project is a test project. A project @@ -42,7 +43,7 @@ namespace ICSharpCode.UnitTesting throw new ArgumentNullException("project"); if (project.ProjectContent == null) return false; - return testAttribute.Resolve(SD.ParserService.GetCompilation(project).TypeResolveContext).Kind != TypeKind.Unknown; + return testAttributeRef.Resolve(SD.ParserService.GetCompilation(project).TypeResolveContext).Kind != TypeKind.Unknown; } public bool IsTestMember(IMember member) @@ -51,8 +52,8 @@ namespace ICSharpCode.UnitTesting throw new ArgumentNullException("member"); if (member.EntityType != EntityType.Method) return false; - var testAttribute = NUnitTestFramework.testAttribute.Resolve(member.Compilation); - var testCaseAttribute = NUnitTestFramework.testCaseAttribute.Resolve(member.Compilation); + var testAttribute = testAttributeRef.Resolve(member.Compilation); + var testCaseAttribute = testCaseAttributeRef.Resolve(member.Compilation); foreach (var attr in member.Attributes) { if (attr.AttributeType.Equals(testAttribute) || attr.AttributeType.Equals(testCaseAttribute)) return true; @@ -66,7 +67,11 @@ namespace ICSharpCode.UnitTesting throw new ArgumentNullException("type"); if (type.IsAbstract) return false; - return type.Methods.Any(IsTestMember); + var testFixtureAttribute = testFixtureAttributeRef.Resolve(type.Compilation); + if (type.Attributes.Any(attr => attr.AttributeType.Equals(testFixtureAttributeRef))) + return true; + else + return type.Methods.Any(IsTestMember); } public IEnumerable GetTestMembersFor(TestProject project, ITypeDefinition typeDefinition) diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs index 2bffc7fb53..531e85c2c0 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMemberTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMemberTests.cs index 1d439c6682..97b3d6c79f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMemberTests.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMemberTests.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs index 418488caa8..44f421a1a4 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs @@ -3,7 +3,6 @@ using System; using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs index 5a4caba6b2..925d89c3ce 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Gui.ClassBrowser; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -13,12 +11,12 @@ using UnitTesting.Tests.Utils; namespace UnitTesting.Tests.Frameworks { - [TestFixture] + [TestFixture, Ignore("Class browser is not implemented")] public class TestableConditionIsValidForClassNodeTestFixture { + /* TestableCondition testableCondition; MockClass classWithTestAttribute; - ClassNode classNodeForClassWithTestAttribute; MockRegisteredTestFrameworks testFrameworks; [TestFixtureSetUp] @@ -75,6 +73,6 @@ namespace UnitTesting.Tests.Frameworks { classWithTestAttribute.MockProjectContent.Project = null; Assert.IsFalse(testableCondition.IsValid(classNodeForClassWithTestAttribute, null)); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs index c1c39166ae..4645cc6b32 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs @@ -10,9 +10,10 @@ using UnitTesting.Tests.Utils; namespace UnitTesting.Tests.Frameworks { - [TestFixture] + [TestFixture, Ignore("Class browser is not implemented")] public class TestableConditionIsValidForMemberNodeTestFixture { + /* TestableCondition testableCondition; MockMethod methodWithTestAttribute; MockMemberNode memberNodeForMethodWithTestAttribute; @@ -58,6 +59,6 @@ namespace UnitTesting.Tests.Frameworks MockMemberNode memberNode = new MockMemberNode(method); testableCondition.IsValid(memberNode, null); Assert.AreEqual(method, testFrameworks.IsTestMemberParameterUsed); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs deleted file mode 100644 index b4cd1e2235..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs +++ /dev/null @@ -1,149 +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.Forms; - -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.UnitTesting; -using NUnit.Framework; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Frameworks -{ - /// - /// Tests the UnitTestingOptionsPanel. - /// - [TestFixture] - public class UnitTestingOptionsPanelTestFixture - { - DerivedUnitTestingOptionsPanel panel; - UnitTestingOptions options; - CheckBox labelsCheckBox; - CheckBox showLogoCheckBox; - CheckBox showProgressCheckBox; - CheckBox threadCheckBox; - CheckBox shadowCopyCheckBox; - CheckBox createXmlOutputFileCheckBox; - - [SetUp] - public void SetUp() - { - Properties p = new Properties(); - options = new UnitTestingOptions(p); - options.Labels = true; - options.NoDots = false; - options.NoShadow = false; - options.NoThread = false; - options.CreateXmlOutputFile = false; - - panel = new DerivedUnitTestingOptionsPanel(options); - panel.LoadPanelContents(); - - labelsCheckBox = (CheckBox)panel.ControlDictionary["labelsCheckBox"]; - showLogoCheckBox = (CheckBox)panel.ControlDictionary["showLogoCheckBox"]; - showProgressCheckBox = (CheckBox)panel.ControlDictionary["showProgressCheckBox"]; - threadCheckBox = (CheckBox)panel.ControlDictionary["threadCheckBox"]; - shadowCopyCheckBox = (CheckBox)panel.ControlDictionary["shadowCopyCheckBox"]; - createXmlOutputFileCheckBox = (CheckBox)panel.ControlDictionary["createXmlOutputFileCheckBox"]; - } - - [TearDown] - public void TearDown() - { - panel.Dispose(); - } - - [Test] - public void SetupFromManifestStreamResourceName() - { - Assert.AreEqual("ICSharpCode.UnitTesting.Resources.UnitTestingOptionsPanel.xfrm", panel.SetupFromManifestResourceName); - } - - [Test] - public void LabelsCheckBoxIsChecked() - { - Assert.IsTrue(labelsCheckBox.Checked); - } - - [Test] - public void LabelsSettingSaved() - { - labelsCheckBox.Checked = false; - panel.StorePanelContents(); - Assert.IsFalse(options.Labels); - } - - [Test] - public void ShowLogoCheckBoxIsChecked() - { - Assert.IsTrue(showLogoCheckBox.Checked); - } - - [Test] - public void ShowLogoSettingSaved() - { - showLogoCheckBox.Checked = false; - panel.StorePanelContents(); - Assert.IsTrue(options.NoLogo); - } - - [Test] - public void ShowProgressCheckBoxIsChecked() - { - Assert.IsTrue(showProgressCheckBox.Checked); - } - - [Test] - public void ShowProgressSettingSaved() - { - showProgressCheckBox.Checked = false; - panel.StorePanelContents(); - Assert.IsTrue(options.NoDots); - } - - [Test] - public void ShadowCopyCheckBoxIsChecked() - { - Assert.IsTrue(shadowCopyCheckBox.Checked); - } - - [Test] - public void ShadowCopySettingSaved() - { - shadowCopyCheckBox.Checked = false; - panel.StorePanelContents(); - Assert.IsTrue(options.NoShadow); - } - - [Test] - public void ThreadCheckBoxIsChecked() - { - Assert.IsTrue(threadCheckBox.Checked); - } - - [Test] - public void ThreadSettingSaved() - { - threadCheckBox.Checked = false; - panel.StorePanelContents(); - Assert.IsTrue(options.NoThread); - } - - [Test] - public void CreateXmlOutputFileCheckBoxIsChecked() - { - Assert.IsFalse(createXmlOutputFileCheckBox.Checked); - } - - [Test] - public void CreateXmlOutputFileSettingSaved() - { - options.CreateXmlOutputFile = false; - createXmlOutputFileCheckBox.Checked = true; - panel.StorePanelContents(); - Assert.IsTrue(options.CreateXmlOutputFile); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs index 526131c7eb..cbde04630e 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using NUnit.Framework; @@ -32,9 +31,10 @@ namespace UnitTesting.Tests.Project /// Namespace.CecilLayerTests.InheritanceTests but the unit tests window displays it with the /// base class name prefixed to it to be consistent with NUnit GUI. /// - [TestFixture] + [TestFixture, Ignore("Inherited test methods are not implemented")] public class AbstractBaseClassWithTestMethodsTestFixture { + /* TestClass testClass; MockClass c; @@ -103,6 +103,6 @@ namespace UnitTesting.Tests.Project testClasses.UpdateTestResult(testResult); Assert.AreEqual(TestResultType.Failure, testClass.Result); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs index be6702034a..c19751b50c 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs @@ -2,7 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -13,9 +13,10 @@ namespace UnitTesting.Tests.Project /// Tests that the BaseTestMethod populates the various /// properties of the DefaultMethod class in its constructor. /// - [TestFixture] + [TestFixture, Ignore("Base test members are not implemented")] public class BaseTestMethodTestFixture { + /* MockClass mockClass; MockMethod mockMethod; BaseTestMember baseTestMethod; @@ -82,6 +83,6 @@ namespace UnitTesting.Tests.Project public void ReturnType() { Assert.AreSame(returnType, baseTestMethod.ReturnType); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DoubleNestedTestClassWithBaseType.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DoubleNestedTestClassWithBaseType.cs index aa00e3737c..5581667373 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DoubleNestedTestClassWithBaseType.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DoubleNestedTestClassWithBaseType.cs @@ -38,9 +38,10 @@ namespace UnitTesting.Tests.Project /// } /// } /// - [TestFixture] - public class DoubleNestedTestClassWithBaseType : InnerClassTestFixtureBase + [TestFixture, Ignore("Inherited test methods are not implemented")] + public class DoubleNestedTestClassWithBaseType { + /* MockClass classNestedInInnerClass; MockClass baseClass; MockMethod testMethodInBaseClass; @@ -69,6 +70,6 @@ namespace UnitTesting.Tests.Project public void DoubleNestedClassShouldHaveTestMemberImportedFromBaseClass() { var nestedClass = testProject.TestClasses.Single(c => c.Class == classNestedInInnerClass); Assert.AreEqual("BaseClass.BaseFoo", nestedClass.TestMembers.Single().Name); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs index 444ccb6c75..ef69e1b8e7 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -19,17 +18,13 @@ namespace UnitTesting.Tests.Project /// test tree. /// [TestFixture] - public class DuplicateClassNameChangedTestFixture + public class DuplicateClassNameChangedTestFixture : ProjectTestFixtureBase { - TestProject testProject; - IProject project; - MockProjectContent projectContent; - MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; - [SetUp] public void Init() { // Create a project to display. + CreateNUnitProject(); project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); @@ -56,7 +51,7 @@ namespace UnitTesting.Tests.Project // Make sure test methods are created, otherwise // the Test2 method will never be looked at due to lazy evaluation // of test method. - int count = testProject.TestClasses[0].TestMembers.Count; + int count = testProject.TestClasses[0].Members.Count; // Change the name of the second test class. DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); @@ -99,13 +94,13 @@ namespace UnitTesting.Tests.Project [Test] public void OldTestClassHasOneMethod() { - Assert.AreEqual(1, GetTestClass("RootNamespace.MyTestFixture").TestMembers.Count); + Assert.AreEqual(1, GetTestClass("RootNamespace.MyTestFixture").Members.Count); } [Test] public void OldTestClassHasOneMethodCalledTest1() { - Assert.AreEqual("Test1", GetTestClass("RootNamespace.MyTestFixture").TestMembers[0].Name); + Assert.AreEqual("Test1", GetTestClass("RootNamespace.MyTestFixture").Members[0].Name); } void AssertTestClassFound(string name) diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs index 9ca7208de3..b187bdc3a9 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -17,43 +16,21 @@ namespace UnitTesting.Tests.Project /// fully qualified name. /// [TestFixture] - public class DuplicateClassNameTestFixture + public class DuplicateClassNameTestFixture : ProjectTestFixtureBase { - TestProject testProject; - IProject project; - MockProjectContent projectContent; - MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; - [SetUp] public void Init() { - // Create a project to display. - project = new MockCSharpProject(); - project.Name = "TestProject"; - ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); - nunitFrameworkReferenceItem.Include = "NUnit.Framework"; - ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); - - // Add a test class. - projectContent = new MockProjectContent(); - projectContent.Language = LanguageProperties.None; - MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); - c.Attributes.Add(new MockAttribute("TestFixture")); - projectContent.Classes.Add(c); - - // Add a second class with the same name. - MockClass secondTestClass = new MockClass(projectContent, "RootNamespace.MyTestFixture"); - secondTestClass.Attributes.Add(new MockAttribute("TestFixture")); - projectContent.Classes.Add(secondTestClass); - - testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); - testProject = new TestProject(project, projectContent, testFrameworks); + CreateNUnitProject( + "TestProject", + Parse("namespace RootNamespace { [NUnit.Framework.TestFixture] class MyTextFixture {} }", "file1.cs"), + Parse("namespace RootNamespace { [NUnit.Framework.TestFixture] class MyTextFixture {} }", "file2.cs")); } /// /// If one or more classes exist with the same fully qualified /// name only one should be added to the test project. The - /// project will not compile anyway due to the duplicate class + /// project will not compile anyway due to the duplicate class /// name so only having one test class is probably an OK /// workaround. /// diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs index cfad7a37c4..8c60f21719 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -61,19 +60,19 @@ namespace UnitTesting.Tests.Project [Test] public void TwoTestMethods() { - Assert.AreEqual(2, testClass.TestMembers.Count); + Assert.AreEqual(2, testClass.Members.Count); } [Test] public void TestMethodName() { - Assert.AreEqual("MyTest", testClass.TestMembers[0].Name); + Assert.AreEqual("MyTest", testClass.Members[0].Name); } [Test] public void BaseClassTestMethodName() { - Assert.AreEqual("MyTestFixtureBase.MyTest", testClass.TestMembers[1].Name); + Assert.AreEqual("MyTestFixtureBase.MyTest", testClass.Members[1].Name); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs index c4810a005f..ead9d49210 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs index a30357c013..7bbf4a6ead 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs @@ -1,7 +1,7 @@ // 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 System.Linq; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -14,105 +14,61 @@ namespace UnitTesting.Tests.Project /// Creates a TestProject object with no test classes. /// [TestFixture] - public class EmptyProjectTestFixture + public class EmptyProjectTestFixture : ProjectTestFixtureBase { - TestProject testProject; - MockProjectContent projectContent; - MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; - - [SetUp] - public void Init() - { - // Create a project to display. - IProject project = new MockCSharpProject(); - project.Name = "TestProject"; - ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); - nunitFrameworkReferenceItem.Include = "NUnit.Framework"; - ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); - - projectContent = new MockProjectContent(); - projectContent.Language = LanguageProperties.None; - - testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); - testProject = new TestProject(project, projectContent, testFrameworks); - } - /// /// Tests that a new class is added to the TestProject /// from the parse info when the old compilation unit is null. /// [Test] - public void NewClassInParserInfo() + public void AddClassWithTestFixtureAttribute() { - // Create new compilation unit with extra class. - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); - newClass.Attributes.Add(new MockAttribute("TestFixture")); - newUnit.Classes.Add(newClass); + // Create an empty project + CreateNUnitProject(); + // Add new compilation unit with extra class. + UpdateCodeFile("namespace RootNamespace { [NUnit.Framework.TestFixture] class MyTextFixture {} }"); - // Update TestProject's parse info. - testProject.UpdateParseInfo(null, newUnit); - - Assert.IsTrue(testProject.TestClasses.Contains("RootNamespace.MyNewTestFixture")); + Assert.IsTrue(testProject.TestClasses.Any(c => c.QualifiedName == "RootNamespace.MyNewTestFixture")); } /// /// The class exists in both the old compilation unit and the - /// new compilation unit, but in the new compilation unit + /// new compilation unit, but in the new compilation unit /// it has an added [TestFixture] attribute. /// [Test] - public void TestFixtureAttributeAdded() + public void AddTestFixtureAttributeToExistingClass() { + CreateNUnitProject("TestProject"); // Create an old compilation unit with the test class // but without a [TestFixture] attribute. - DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); - MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); - oldUnit.Classes.Add(newClass); + UpdateCodeFile("namespace RootNamespace { class MyTextFixture {} }"); // Create a new compilation unit with the test class // having a [TestFixture] attribute. - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); - newClass.Attributes.Add(new MockAttribute("TestFixture")); - newUnit.Classes.Add(newClass); - - // Update TestProject's parse info. - testProject.UpdateParseInfo(oldUnit, newUnit); + UpdateCodeFile("namespace RootNamespace { [NUnit.Framework.TestFixture] class MyTextFixture {} }"); - Assert.IsTrue(testProject.TestClasses.Contains("RootNamespace.MyNewTestFixture"), - "New class should have been added to the set of TestClasses."); + Assert.IsTrue(testProject.TestClasses.Any(c => c.QualifiedName == "RootNamespace.MyNewTestFixture"), + "New class should have been added to the set of TestClasses."); } /// /// The class exists in both the old compilation unit and the - /// new compilation unit, but in the new compilation unit + /// new compilation unit, but in the new compilation unit /// the [TestFixture] attribute has been removed. /// [Test] public void TestFixtureAttributeRemoved() { // Add the test class first. - TestFixtureAttributeAdded(); + AddClassWithTestFixtureAttribute(); // Create an old compilation unit with the test class // having a [TestFixture] attribute. - DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); - MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); - newClass.Attributes.Add(new MockAttribute("TestFixture")); - oldUnit.Classes.Add(newClass); - - // Create a new compilation unit with the test class - // but without a [TestFixture] attribute. - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); - newUnit.Classes.Add(newClass); - - // Update TestProject's parse info. - testProject.UpdateParseInfo(oldUnit, newUnit); + UpdateCodeFile("namespace RootNamespace { class MyTextFixture {} }"); - Assert.IsFalse(testProject.TestClasses.Contains("RootNamespace.MyNewTestFixture"), - "Class should have been removed."); + Assert.IsFalse(testProject.TestClasses.Any(c => c.QualifiedName == "RootNamespace.MyNewTestFixture"), + "Class should have been removed."); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs index f5149bb932..e29a499cc6 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassInTestFixtureTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassInTestFixtureTests.cs index fdc370fbef..5705044af2 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassInTestFixtureTests.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassInTestFixtureTests.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -11,51 +10,44 @@ using System.Linq; namespace UnitTesting.Tests.Project { /// - /// Tests that a class nested inside test fixture is recognized, e.g. - /// - /// [TestFixture] - /// public class A - /// { - /// public class InnerATest - /// { - /// [Test] - /// public void FooBar() - /// { - /// } - /// - /// [TestFixture] - /// public class InnerTestLevel2 { - /// } - /// } - /// - /// public class InnerBClass() {} - /// } - /// + /// Tests that a class nested inside test fixture is recognized /// [TestFixture] - public class InnerClassInTestFixtureTests : InnerClassTestFixtureBase + public class InnerClassInTestFixtureTests : ProjectTestFixtureBase { - MockClass classNestedInInnerClass; - + TestClass outerTestClass; + [SetUp] public void Init() { - base.InitBase(); - - //Add TestFixture attribute to outer class - outerClass.Attributes.Add(new MockAttribute("TestFixture")); - testProject = new TestProject(null, projectContent, testFrameworks); - - //Add inner class nested in test class - classNestedInInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest.InnerTestLevel2", "MyTests.A+InnerATest+InnerTestLevel2", innerClass); - classNestedInInnerClass.Attributes.Add(new MockAttribute("TestFixture")); - innerClass.InnerClasses.Add(classNestedInInnerClass); + CreateNUnitProject( + Parse(@"using NUnit.Framework; +namespace MyTests { + [TestFixture] + public class A + { + public class InnerATest + { + [Test] + public void FooBar() + { + } + + [TestFixture] + public class InnerTestLevel2 { + } + } + + public class InnerBClass() {} + } +} +")); } [Test] public void OuterTestClassFound() { - AssertTestResultContainsClass(outerClass); + Assert.IsNotNull(testProject.GetTestClass("A")); } [Test] @@ -67,44 +59,25 @@ namespace UnitTesting.Tests.Project [Test] public void InnerNonTestClassWithoutWasNotMarkedAsTestClass() { - AssertTestResultDoesNotContainClass(nonTestInnerClass); + Assert.IsNull(testProject.GetTestClass("A+InnerBClass")); } [Test] public void InnerClassInInnerClassFound() { - AssertTestResultContainsClass(classNestedInInnerClass); + Assert.IsNotNull(testProject.GetTestClass("A+InnerATest+InnerTestLevel2")); } - + [Test] public void TestClassNameShouldBeDotNetNameOfTheDoubleNestedClass() { - Assert.AreEqual("A+InnerATest+InnerTestLevel2", TestClassRelatedTo(classNestedInInnerClass).Name); + Assert.AreEqual("MyTests.A+InnerATest+InnerTestLevel2", testProject.GetTestClass("A+InnerATest+InnerTestLevel2").QualifiedName); } - + [Test] public void TestClassNamespaceShouldBeValid() { - Assert.AreEqual("MyTests", TestClassRelatedTo(classNestedInInnerClass).Namespace); - } - - void AssertTestResultContainsClass(IClass clazz) - { - var testClazz = TestClassRelatedTo(clazz); - if (testClazz == null) - throw new AssertionException(string.Format("Test result should contain class {0}.", clazz.FullyQualifiedName)); - } - - void AssertTestResultDoesNotContainClass(MockClass clazz) - { - var testClazz = TestClassRelatedTo(clazz); - if (testClazz != null) - throw new AssertionException(string.Format("Test result should not contain class {0}.", clazz.FullyQualifiedName)); - } - - TestClass TestClassRelatedTo(IClass clazz) - { - return testProject.TestClasses.SingleOrDefault(c => c.Class == clazz); + Assert.AreEqual("MyTests", testProject.GetTestClass("A+InnerATest+InnerTestLevel2").Namespace); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs index f916c63799..c22b0bdd2c 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -14,62 +13,62 @@ namespace UnitTesting.Tests.Project /// Tests what happens when a test method is renamed inside an inner class. /// [TestFixture] - public class InnerClassMethodRemovedTestFixture : InnerClassTestFixtureBase + public class InnerClassMethodRemovedTestFixture : ProjectTestFixtureBase { TestClass innerTestClass; [SetUp] public void Init() { - base.InitBase(); + CreateNUnitProject(Parse(@" +using NUnit.Framework; +namespace MyTests { + class A { + class InnerATest { + [Test] + public void FooBar() {} + } + } +} +")); - DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); - oldUnit.Classes.Add(outerClass); - - // Create new compilation unit with inner class that has its method renamed. - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - MockClass newOuterClass = new MockClass(projectContent, "MyTests.A"); - projectContent.Classes.Add(newOuterClass); - newUnit.Classes.Add(newOuterClass); - - // Create the inner test class. - MockClass newInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", outerClass); - newInnerClass.SetDotNetName("MyTests.A+InnerATest"); - newInnerClass.Attributes.Add(new MockAttribute("TestFixture")); - newOuterClass.InnerClasses.Add(newInnerClass); - - MockMethod method = new MockMethod(newInnerClass, "FooBarRenamed"); - method.Attributes.Add(new MockAttribute("Test")); - newInnerClass.Methods.Add(method); - outerClass.InnerClasses.Add(newInnerClass); + // The members should be changed on the existing TestClass instance, + // so grab the reference in before updating. + innerTestClass = testProject.GetTestClass("MyTests.A+InnerATest"); - MockClass innerClassInInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest.InnerInnerTest", innerClass); - innerClassInInnerClass.SetDotNetName("MyTests.A+InnerATest+InnerInnerTest"); - innerClassInInnerClass.Attributes.Add(new MockAttribute("TestFixture")); - newInnerClass.InnerClasses.Add(innerClassInInnerClass); - - // Update TestProject's parse info. - testProject.UpdateParseInfo(oldUnit, newUnit); + UpdateCodeFile(@" +using NUnit.Framework; +namespace MyTests { + class A { + class InnerATest { + [Test] + public void FooBarRenamed() {} - innerTestClass = testProject.TestClasses["MyTests.A+InnerATest"]; + [TestFixture] + class InnerInnerTest {} + } + } +} +"); } [Test] public void NewTestMethodExists() { - TestMember method = innerTestClass.TestMembers[0]; + TestMember method = innerTestClass.Members[0]; Assert.AreEqual("FooBarRenamed", method.Name); } [Test] public void OldTestMethodRemoved() { - Assert.AreEqual(1, innerTestClass.TestMembers.Count); + Assert.AreEqual(1, innerTestClass.Members.Count); } [Test] - public void NewTestClassExists() { - CollectionAssert.Contains(testProject.TestClasses.Select(x => x.QualifiedName).ToList(), "MyTests.A+InnerATest+InnerInnerTest"); + public void NewTestClassExists() + { + CollectionAssert.Contains(innerTestClass.NestedClasses.Select(x => x.QualifiedName).ToList(), "MyTests.A+InnerATest+InnerInnerTest"); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs index 09fb9958ee..ba3e4dcae9 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs @@ -2,7 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; +using System.Linq; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -14,13 +14,40 @@ namespace UnitTesting.Tests.Project /// Tests that the TestProject is correctly updated after the inner class name changes. /// [TestFixture] - public class InnerClassNameChangesTestFixture : InnerClassTestFixtureBase + public class InnerClassNameChangesTestFixture : ProjectTestFixtureBase { + TestClass originalA; + [SetUp] public void Init() { - base.InitBase(); - + CreateNUnitProject(Parse(@" +using NUnit.Framework; +namespace MyTests { + class A { + class InnerTest { + [Test] + public void M() {} + } + } +} +")); + + originalA = testProject.GetTestClass("MyTests.A"); + + UpdateCodeFile(@" +using NUnit.Framework; +namespace MyTests { + class A { + class InnerTestMod { + [Test] + public void M() {} + } + } +} +"); + + DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); oldUnit.Classes.Add(outerClass); @@ -39,23 +66,18 @@ namespace UnitTesting.Tests.Project // Update TestProject's parse info. testProject.UpdateParseInfo(oldUnit, newUnit); } - - [Test] - public void NewInnerClassAdded() - { - Assert.IsTrue(testProject.TestClasses.Contains("MyTests.A+InnerATestMod")); - } [Test] - public void OldInnerClassRemoved() + public void OuterClassNotChanged() { - Assert.IsFalse(testProject.TestClasses.Contains("MyTests.A+InnerATest")); + Assert.IsNotNull(originalA); + Assert.AreSame(originalA, testProject.GetTestClass("MyTests.A")); } [Test] - public void OneTestClassRemain() + public void InnerClassRenamed() { - Assert.AreEqual(1, testProject.TestClasses.Count); + Assert.AreEqual("InnerTestMod", originalA.NestedClasses.Single().Name); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixture.cs index d166cd902a..d3bda2daad 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixture.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -28,12 +27,30 @@ namespace UnitTesting.Tests.Project /// In this case the FooBar test is identified via: "A+InnerATest.FooBar". /// [TestFixture] - public class InnerClassTestFixture : InnerClassTestFixtureBase + public class InnerClassTestFixture : ProjectTestFixtureBase { + TestClass outerClass; + TestClass innerClass; + [SetUp] public void Init() { - base.InitBase(); + CreateNUnitProject(Parse(@" +using NUnit.Framework; +namespace MyTests { + public class A + { + public class InnerATest + { + [Test] + public void FooBar() + { + } + } + } +}")); + outerClass = testProject.GetTestClass("A"); + innerClass = testProject.GetTestClass("A+InnerATest"); } [Test] @@ -45,31 +62,19 @@ namespace UnitTesting.Tests.Project [Test] public void TestClassQualifiedName() { - Assert.AreEqual("MyTests.A+InnerATest", testClass.QualifiedName); + Assert.AreEqual("MyTests.A+InnerATest", innerClass.QualifiedName); } [Test] public void TestClassName() { - Assert.AreEqual("A+InnerATest", testClass.Name); - } - - [Test] - public void NoTestClassesForNamespaceMyTestsA() - { - Assert.AreEqual(0, testProject.GetTestClasses("MyTests.A").Length); - } - - [Test] - public void OneTestClassForNamespaceMyTests() - { - Assert.AreEqual(1, testProject.GetTestClasses("MyTests").Length); + Assert.AreEqual("InnerATest", innerClass.Name); } [Test] public void NamespaceForInnerClassIsDeclaringTypesNamespace() { - Assert.AreEqual("MyTests", testClass.Namespace); - } + Assert.AreEqual("MyTests", innerClass.Namespace); + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs index 5b024c31d0..0ff247440d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs @@ -2,7 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; +using System.Linq; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -13,40 +13,46 @@ namespace UnitTesting.Tests.Project /// Tests that the inner test class is removed when its TestFixture attribute is removed. /// [TestFixture] - public class InnerClassTestFixtureAttributeRemovedTestFixture : InnerClassTestFixtureBase + public class InnerClassTestFixtureAttributeRemovedTestFixture : ProjectTestFixtureBase { [SetUp] public void Init() { - base.InitBase(); - - DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); - oldUnit.Classes.Add(outerClass); - - // Create new compilation unit with inner class that no longer has the TestFixture attribute. - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - MockClass newOuterClass = new MockClass(projectContent, "MyTests.A"); - projectContent.Classes.Add(newOuterClass); - newUnit.Classes.Add(newOuterClass); - - // Create the inner test class. - MockClass newInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); - newOuterClass.InnerClasses.Add(newInnerClass); - - // Update TestProject's parse info. - testProject.UpdateParseInfo(oldUnit, newUnit); + CreateNUnitProject(Parse(@" +using NUnit.Framework; +namespace MyTests { + class A { + [TestFixture] + class Inner {} + } +}")); } [Test] - public void NoTestClasses() + public void RemoveAttribute_Leaves_No_TestClasses() { + UpdateCodeFile(@" +using NUnit.Framework; +namespace MyTests { + class A { + class Inner {} + } +}"); Assert.AreEqual(0, testProject.TestClasses.Count); } [Test] - public void InnerTestClassRemoved() + public void MoveAttributeToOuterClass() { - Assert.IsFalse(testProject.TestClasses.Contains("MyTests.A+InnerATest")); + UpdateCodeFile(@" +using NUnit.Framework; +namespace MyTests { + [TestFixture] + class A { + class Inner {} + } +}"); + Assert.IsEmpty(testProject.TestClasses.Single().NestedClasses); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs deleted file mode 100644 index b053a8f423..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Project; -using ICSharpCode.UnitTesting; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Project -{ - /// - /// Base class for testing inner classes with TestFixture information. - /// - public class InnerClassTestFixtureBase - { - protected TestClass testClass; - protected MockClass innerClass; - protected MockClass nonTestInnerClass; - protected TestProject testProject; - protected MockProjectContent projectContent; - protected MockClass outerClass; - protected MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; - - protected void InitBase() - { - projectContent = new MockProjectContent(); - projectContent.Language = LanguageProperties.None; - - // Create the base test class. - outerClass = new MockClass(projectContent, "MyTests.A"); - projectContent.Classes.Add(outerClass); - - // Create the inner test class. - // Note the use of the DotNetName "MyTests.A+InnerTest". - innerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); - innerClass.Attributes.Add(new MockAttribute("TestFixture")); - - MockMethod method = new MockMethod(innerClass, "FooBar"); - method.Attributes.Add(new MockAttribute("Test")); - innerClass.Methods.Add(method); - outerClass.InnerClasses.Add(innerClass); - - // Add another inner class that is not a test class. - nonTestInnerClass = new MockClass(projectContent, "MyTests.A.InnerBClass", outerClass); - outerClass.InnerClasses.Add(nonTestInnerClass); - - // Add another inner class with the same name as the InnerATest. - // This makes sure duplicate classes are not added. - MockClass duplicateInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); - duplicateInnerClass.Attributes.Add(new MockAttribute("TestFixture")); - outerClass.InnerClasses.Add(duplicateInnerClass); - - testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); - testProject = new TestProject(null, projectContent, testFrameworks); - if (testProject.TestClasses.Count > 0) { - testClass = testProject.TestClasses[0]; - } - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs index 876eca9b0a..9695de7dc4 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs @@ -2,16 +2,16 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; namespace UnitTesting.Tests.Project { - [TestFixture] + [TestFixture, Ignore("Test inheritance not yet implemented")] public class OverriddenBaseTestMethodTestFixture { + /* TestClass testClass; MockClass c; MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; @@ -72,6 +72,6 @@ namespace UnitTesting.Tests.Project public void DerivedClassTestMethodExists() { Assert.IsTrue(testClass.TestMembers.Contains("VirtualTestMethod")); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/ProjectTestFixtureBase.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/ProjectTestFixtureBase.cs new file mode 100644 index 0000000000..4239bac63d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/ProjectTestFixtureBase.cs @@ -0,0 +1,70 @@ +// 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.CSharp; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Parser; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using Rhino.Mocks; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Project +{ + /// + /// Base class that helps setting up a unit test project. + /// + public class ProjectTestFixtureBase + { + public static readonly IUnresolvedAssembly Corlib = new CecilLoader().LoadAssemblyFile(typeof(object).Assembly.Location); + public static readonly IUnresolvedAssembly NUnitFramework = new CecilLoader().LoadAssemblyFile(typeof(TestAttribute).Assembly.Location); + + protected IProject project; + protected TestProject testProject; + protected IProjectContent projectContent; + + protected void CreateProject(ITestFramework framework, params IUnresolvedFile[] codeFiles) + { + SD.InitializeForUnitTests(); + var parserService = MockRepository.GenerateStrictMock(); + parserService.Expect(p => p.GetCompilation(project)).WhenCalled(m => m.ReturnValue = projectContent.CreateCompilation()); + + project = MockRepository.GenerateStrictMock(); + project.Expect(p => p.Name).Return(projectName); + + projectContent = new CSharpProjectContent().SetAssemblyName(projectName); + projectContent = projectContent.AddAssemblyReferences(Corlib, NUnitFramework); + projectContent = projectContent.AddOrUpdateFiles(codeFiles); + + testProject = new TestProject(project, framework); + } + + protected void CreateNUnitProject(params IUnresolvedFile[] codeFiles) + { + CreateProject(new NUnitTestFramework(), codeFiles); + } + + protected IUnresolvedFile Parse(string code, string fileName = "test.cs") + { + return new CSharpParser().Parse(code, fileName).ToTypeSystem(); + } + + protected void UpdateCodeFile(string code, string fileName = "test.cs") + { + var oldFile = projectContent.GetFile(fileName); + var newFile = Parse(code, fileName); + projectContent = projectContent.AddOrUpdateFiles(newFile); + testProject.NotifyParseInformationChanged(oldFile, newFile); + } + + protected void RemoveCodeFile(string fileName) + { + var oldFile = projectContent.GetFile(fileName); + projectContent = projectContent.RemoveFiles(fileName); + testProject.NotifyParseInformationChanged(oldFile, null); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs deleted file mode 100644 index 014e6f4800..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs +++ /dev/null @@ -1,107 +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.Collections.Generic; -using System.Text; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.UnitTesting; -using NUnit.Framework; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Project -{ - [TestFixture] - public class RemovedClassesTestFixture - { - RemovedClasses removedClasses; - MockClass myClass; - MockClass anotherClass; - MockClass innerClass; - - [SetUp] - public void Init() - { - myClass = new MockClass("MyTests.MyClass"); - innerClass = new MockClass("MyTests.MyClass.InnerClass", "MyTests.MyClass+InnerClass"); - myClass.InnerClasses.Add(innerClass); - - anotherClass = new MockClass("MyTests.AnotherClass"); - - List classes = new List(); - classes.Add(myClass); - classes.Add(anotherClass); - - removedClasses = new RemovedClasses(); - removedClasses.Add(classes); - } - - [Test] - public void InnerClassesIncludedInMissingClasses() - { - List expectedClasses = new List(); - expectedClasses.Add(myClass); - expectedClasses.Add(innerClass); - expectedClasses.Add(anotherClass); - - AssertContains(expectedClasses, removedClasses.GetMissingClasses()); - } - - /// - /// Should remove inner class too. - /// - [Test] - public void RemoveMyClass() - { - removedClasses.Remove(myClass); - - List expectedClasses = new List(); - expectedClasses.Add(anotherClass); - - AssertContains(expectedClasses, removedClasses.GetMissingClasses()); - } - - [Test] - public void RemoveInnerClass() - { - removedClasses.Remove(innerClass); - - List expectedClasses = new List(); - expectedClasses.Add(myClass); - expectedClasses.Add(anotherClass); - - AssertContains(expectedClasses, removedClasses.GetMissingClasses()); - } - - [Test] - public void DotNetNameUsedWhenAddingClasses() - { - MockClass c = new MockClass("MyTests.MyClass.InnerClass", "MyTests.MyClass+InnerClass"); - List classes = new List(); - classes.Add(c); - - RemovedClasses removedClasses = new RemovedClasses(); - removedClasses.Add(classes); - removedClasses.Remove(c); - - Assert.AreEqual(0, removedClasses.GetMissingClasses().Count); - } - - void AssertContains(IList expectedClasses, IList actualClasses) - { - foreach (IClass c in expectedClasses) { - Assert.IsTrue(actualClasses.Contains(c), "Class missing: " + c.FullyQualifiedName + " Actual:\r\n" + GetClassNames(actualClasses)); - } - Assert.AreEqual(expectedClasses.Count, actualClasses.Count, "Actual:\r\n" + GetClassNames(actualClasses)); - } - - string GetClassNames(IList classes) - { - StringBuilder names = new StringBuilder(); - foreach (IClass c in classes) { - names.AppendLine(c.FullyQualifiedName); - } - return names.ToString(); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs deleted file mode 100644 index 1e8c40afda..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.UnitTesting; -using NUnit.Framework; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Project -{ - [TestFixture] - public class TestClassIsTestMethodUsesTestFrameworksTestFixture - { - TestClass testClass; - MockClass mockTestClass; - MockMethod testMethod; - MockRegisteredTestFrameworks testFrameworks; - MockClass mockBaseTestClass; - MockMethod baseClassTestMethod; - - [SetUp] - public void Init() - { - mockTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); - mockTestClass.FullyQualifiedName = "DerivedClass"; - testMethod = new MockMethod(mockTestClass, "myTestMethod"); - mockTestClass.Methods.Add(testMethod); - - mockBaseTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); - mockBaseTestClass.FullyQualifiedName = "BaseClass"; - mockBaseTestClass.Methods.Add(baseClassTestMethod); - baseClassTestMethod = new MockMethod(mockBaseTestClass, "myBaseTestMethod"); - - testFrameworks = new MockRegisteredTestFrameworks(); - testFrameworks.AddTestMember(testMethod); - testFrameworks.AddTestMember(baseClassTestMethod); - - mockTestClass.AddBaseClass(mockBaseTestClass); - - testClass = new TestClass(mockTestClass, testFrameworks); - } - - [Test] - public void TestClassHasTestMethod() - { - Assert.AreEqual(testMethod, testClass.TestMembers[0].Member); - } - - [Test] - public void TestClassHasBaseClassTestMethod() - { - BaseTestMember baseTestMethod = testClass.TestMembers[1].Member as BaseTestMember; - Assert.AreEqual(baseClassTestMethod, baseTestMethod.Member); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests.cs index 4d353a6ebd..b1af598231 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests.cs @@ -2,7 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; +using System.Linq; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -10,42 +10,19 @@ using UnitTesting.Tests.Utils; namespace UnitTesting.Tests.Project { [TestFixture] - public class TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests + public class TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests : ProjectTestFixtureBase { - TestClass testClass; - MockClass fakeClass; - MockTestFramework fakeTestFramework; - MockRegisteredTestFrameworks fakeRegisteredTestFrameworks; - - void CreateTestClass() - { - fakeClass = MockClass.CreateMockClassWithoutAnyAttributes(); - fakeTestFramework = new MockTestFramework(); - fakeRegisteredTestFrameworks = new MockRegisteredTestFrameworks(); - fakeRegisteredTestFrameworks.AddTestFrameworkForProject(fakeClass.Project, fakeTestFramework); - - testClass = new TestClass(fakeClass, fakeRegisteredTestFrameworks); - } - - DefaultField AddTestFieldDefinedAsTestMemberToClass(string name) - { - var field = new DefaultField(fakeClass, name); - fakeClass.Fields.Add(field); - fakeRegisteredTestFrameworks.AddTestMember(field); - - return field; - } - [Test] public void TestMembers_ClassHasOneFieldDefinedAsTestMemberByTestFramework_FirstItemHasSameNameAsField() { - CreateTestClass(); - AddTestFieldDefinedAsTestMemberToClass("MyField"); + var fakeTestFramework = new MockTestFramework(); + fakeTestFramework.AddTestClass("MyClass"); + fakeTestFramework.AddTestMember("MyClass.MyField"); - TestMember testField = testClass.TestMembers[0]; - string testFieldName = testField.Name; + CreateProject(fakeTestFramework, Parse("class MyClass { int MyField; }")); - Assert.AreEqual("MyField", testFieldName); + TestMember testField = testProject.TestClasses.Single().Members.Single(); + Assert.AreEqual("MyField", testField.Name); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs index f77b31496b..d28cf3c48f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs @@ -3,8 +3,9 @@ using System; using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -13,47 +14,28 @@ using UnitTesting.Tests.Utils; namespace UnitTesting.Tests.Project { [TestFixture] - public class TestClassWithOneMethodTestFixture + public class TestClassWithOneMethodTestFixture : ProjectTestFixtureBase { - TestProject testProject; TestClass testClass; TestMember testMethod; bool resultChangedCalled; - MockProjectContent projectContent; MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() { resultChangedCalled = false; - IProject project = new MockCSharpProject(); - project.Name = "TestProject"; - ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); - nunitFrameworkReferenceItem.Include = "NUnit.Framework"; - ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); - - projectContent = new MockProjectContent(); - projectContent.Language = LanguageProperties.None; - - MockClass mockClass = new MockClass(projectContent, "RootNamespace.Tests.MyTestFixture"); - mockClass.Attributes.Add(new MockAttribute("TestFixture")); - projectContent.Classes.Add(mockClass); - - // Add a method to the test class - MockMethod mockMethod = new MockMethod(mockClass, "TestMethod"); - mockMethod.Attributes.Add(new MockAttribute("Test")); - mockClass.Methods.Add(mockMethod); - - testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); - testProject = new TestProject(project, projectContent, testFrameworks); - testClass = testProject.TestClasses[0]; - testMethod = testClass.TestMembers[0]; - } - + CreateNUnitProject(Parse(@" +using NUnit.Framework; +namespace RootNamespace.Tests { + [TestFixture] + class MyTestFixture { [Test] - public void OneMethod() - { - Assert.AreEqual(1, testClass.TestMembers.Count); + public void TestMethod() { } + } +}")); + testClass = testProject.TestClasses.Single(); + testMethod = testClass.Members.Single(); } [Test] @@ -151,7 +133,7 @@ namespace UnitTesting.Tests.Project [Test] public void FindTestMethod() { - Assert.AreSame(testMethod, testClass.TestMembers["TestMethod"]); + Assert.AreSame(testMethod, testClass.Members["TestMethod"]); } [Test] @@ -172,39 +154,23 @@ namespace UnitTesting.Tests.Project /// /// Tests that a method is removed from the TestClass - /// based on the parse info. Also checks that the test methods are - /// checked based on the CompoundClass via IClass.GetCompoundClass. + /// based on the parse info. /// [Test] public void MethodRemovedInParserInfo() { - // Create old compilation unit. - DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); - oldUnit.Classes.Add(testClass.Class); - - // Create new compilation unit. - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - newUnit.Classes.Add(testClass.Class); - - // Add a new method to a new compound class. - MockClass compoundClass = new MockClass(projectContent, "RootNamespace.MyTestFixture"); - compoundClass.Attributes.Add(new MockAttribute("TestFixture")); - MockClass mockClass = (MockClass)testClass.Class; - mockClass.SetCompoundClass(compoundClass); - - // Monitor test methods removed. - List methodsRemoved = new List(); - testClass.TestMembers.TestMemberRemoved += delegate(Object source, TestMemberEventArgs e) - { methodsRemoved.Add(e.TestMember); }; - - // Update TestProject's parse info. - testProject.UpdateParseInfo(oldUnit, newUnit); + UpdateCodeFile(@" +using NUnit.Framework; +namespace RootNamespace.Tests { + [TestFixture] + class MyTestFixture { + public void TestMethod() { } + } +}"); - Assert.IsFalse(testClass.TestMembers.Contains("TestMethod")); - Assert.AreEqual(1, methodsRemoved.Count); - Assert.AreSame(testMethod.Member, methodsRemoved[0].Member); + Assert.AreEqual(0, testClass.Members.Count); } - + void ResultChanged(object source, EventArgs e) { resultChangedCalled = true; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs index aa6d5b8f01..906eab1d2e 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs @@ -3,7 +3,6 @@ using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -18,8 +17,6 @@ namespace UnitTesting.Tests.Project TestClass testClass; TestMember testMethod1; TestMember testMethod2; - MockClass mockClass; - MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() @@ -49,14 +46,14 @@ namespace UnitTesting.Tests.Project testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testProject = new TestProject(project, projectContent, testFrameworks); testClass = testProject.TestClasses[0]; - testMethod1 = testClass.TestMembers[0]; - testMethod2 = testClass.TestMembers[1]; + testMethod1 = testClass.Members[0]; + testMethod2 = testClass.Members[1]; } [Test] public void TwoMethods() { - Assert.AreEqual(2, testClass.TestMembers.Count); + Assert.AreEqual(2, testClass.Members.Count); } [Test] diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs index 67b90b64ba..6a6bd79252 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using NUnit.Framework; @@ -30,9 +29,10 @@ namespace UnitTesting.Tests.Project /// /// RootNamespace.DerivedClass.BaseClassMethod /// - [TestFixture] + [TestFixture, Ignore("Inherited tests not implemented")] public class TestMethodsInBaseClassTestFixture { + /* TestClass testClass; MockClass c; MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; @@ -68,19 +68,19 @@ namespace UnitTesting.Tests.Project [Test] public void TwoTestMethods() { - Assert.AreEqual(2, testClass.TestMembers.Count); + Assert.AreEqual(2, testClass.Members.Count); } [Test] public void DerivedMethod() { - Assert.IsTrue(testClass.TestMembers.Contains("DerivedMethod")); + Assert.IsTrue(testClass.Members.Contains("DerivedMethod")); } [Test] public void BaseMethod() { - Assert.IsTrue(testClass.TestMembers.Contains("TestFixtureBase.BaseMethod")); + Assert.IsTrue(testClass.Members.Contains("TestFixtureBase.BaseMethod")); } /// @@ -92,7 +92,7 @@ namespace UnitTesting.Tests.Project [Test] public void BaseMethodDeclaringTypeIsDerivedClass() { - TestMember method = testClass.TestMembers["TestFixtureBase.BaseMethod"]; + TestMember method = testClass.Members["TestFixtureBase.BaseMethod"]; Assert.AreEqual(c, method.Member.DeclaringType); } @@ -120,6 +120,6 @@ namespace UnitTesting.Tests.Project testClasses.UpdateTestResult(testResult); Assert.AreEqual(TestResultType.Failure, testClass.Result); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs deleted file mode 100644 index 75e91655d7..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Project; -using ICSharpCode.UnitTesting; -using NUnit.Framework; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Project -{ - [TestFixture] - public class TestProjectUsesTestFrameworksTestFixture - { - MockRegisteredTestFrameworks testFrameworks; - TestProject testProject; - MockClass myTestClass; - DefaultCompilationUnit oldUnit; - - [SetUp] - public void Init() - { - testFrameworks = new MockRegisteredTestFrameworks(); - myTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); - myTestClass.SetDotNetName("MyTests"); - testFrameworks.AddTestClass(myTestClass); - - oldUnit = new DefaultCompilationUnit(myTestClass.ProjectContent); - oldUnit.Classes.Add(myTestClass); - - testProject = new TestProject(myTestClass.Project, myTestClass.ProjectContent, testFrameworks); - } - - [Test] - public void TestProjectHasTestClassCalledMyTests() - { - Assert.AreEqual(myTestClass, testProject.TestClasses[0].Class); - } - - [Test] - public void NewTestClassInNewCompilationUnitAddedToTestProjectTestClasses() - { - MockClass myNewTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); - myNewTestClass.SetDotNetName("MyNewTests"); - testFrameworks.AddTestClass(myNewTestClass); - - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(myTestClass.ProjectContent); - newUnit.Classes.Add(myTestClass); - newUnit.Classes.Add(myNewTestClass); - - testProject.UpdateParseInfo(oldUnit, newUnit); - - Assert.AreEqual(myNewTestClass, testProject.TestClasses[1].Class); - } - - [Test] - public void NewInnerTestClassInNewCompilationUnitAddedToTestProjectTestClasses() - { - MockClass myNewInnerTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); - myNewInnerTestClass.SetDotNetName("MyNewInnerTests"); - testFrameworks.AddTestClass(myNewInnerTestClass); - myTestClass.InnerClasses.Add(myNewInnerTestClass); - - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(myTestClass.ProjectContent); - newUnit.Classes.Add(myTestClass); - - testProject.UpdateParseInfo(oldUnit, newUnit); - - Assert.AreEqual(myNewInnerTestClass, testProject.TestClasses[1].Class); - } - - [Test] - public void TestProjectRemovesTestClassWhenItIsNoLongerATestClass() - { - testFrameworks.RemoveTestClass(myTestClass); - - DefaultCompilationUnit newUnit = new DefaultCompilationUnit(myTestClass.ProjectContent); - newUnit.Classes.Add(myTestClass); - - testProject.UpdateParseInfo(oldUnit, newUnit); - - Assert.AreEqual(0, testProject.TestClasses.Count); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs index b0b532070e..f9f6336cc9 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs @@ -3,7 +3,8 @@ using System; using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; +using System.Collections.Specialized; +using System.Linq; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -21,7 +22,6 @@ namespace UnitTesting.Tests.Project TestClass testClass; MSBuildBasedProject project; bool resultChangedCalled; - MockProjectContent projectContent; List classesAdded; List classesRemoved; MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; @@ -275,13 +275,13 @@ namespace UnitTesting.Tests.Project // Monitor test methods added. List methodsAdded = new List(); - testClass.TestMembers.TestMemberAdded += delegate(Object source, TestMemberEventArgs e) + testClass.Members.TestMemberAdded += delegate(Object source, TestMemberEventArgs e) { methodsAdded.Add(e.TestMember); }; // Update TestProject's parse info. testProject.UpdateParseInfo(oldUnit, newUnit); - Assert.IsTrue(testClass.TestMembers.Contains("NewMethod")); + Assert.IsTrue(testClass.Members.Contains("NewMethod")); Assert.AreEqual(1, methodsAdded.Count); Assert.AreSame(method, methodsAdded[0].Member); } @@ -335,14 +335,12 @@ namespace UnitTesting.Tests.Project resultChangedCalled = true; } - void TestClassAdded(object source, TestClassEventArgs e) + void TestClassesChanged(object source, NotifyCollectionChangedEventArgs e) { - classesAdded.Add(e.TestClass); - } - - void TestClassRemoved(object source, TestClassEventArgs e) - { - classesRemoved.Add(e.TestClass); + if (e.Action == NotifyCollectionChangedAction.Add) + classesAdded.AddRange(e.NewItems.Cast()); + else if (e.Action == NotifyCollectionChangedAction.Remove) + classesRemoved.AddRange(e.OldItems.Cast()); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs index 2f112133de..604f22dc74 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs @@ -17,7 +17,6 @@ namespace UnitTesting.Tests.Project TestClass testClass1; TestClass testClass2; TestClass testClass3; - TestClassCollection testClasses; bool testClassesResultChanged; MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs index 67da77d81b..cf88ac0f6e 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs @@ -17,7 +17,6 @@ namespace UnitTesting.Tests.Project TestMember testMethod1; TestMember testMethod2; TestMember testMethod3; - TestMemberCollection testMethods; bool testMethodsResultChanged; [SetUp] diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs index 3a73b90c90..0156497fa9 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using NUnit.Framework; @@ -21,7 +20,6 @@ namespace UnitTesting.Tests.Project public class TwoBaseClassesWithTestMethodsTestFixture { TestClass testClass; - MockClass c; MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] @@ -59,13 +57,13 @@ namespace UnitTesting.Tests.Project [Test] public void BaseBaseTestMethodExists() { - Assert.IsTrue(testClass.TestMembers.Contains("BaseBaseTestFixture.BaseBaseTest")); + Assert.IsTrue(testClass.Members.Contains("BaseBaseTestFixture.BaseBaseTest")); } [Test] public void BaseMethodExists() { - Assert.IsTrue(testClass.TestMembers.Contains("BaseTestFixture.BaseTest")); + Assert.IsTrue(testClass.Members.Contains("BaseTestFixture.BaseTest")); } /// @@ -77,7 +75,7 @@ namespace UnitTesting.Tests.Project [Test] public void BaseBaseMethodDeclaringTypeIsDerivedClass() { - TestMember method = testClass.TestMembers["BaseBaseTestFixture.BaseBaseTest"]; + TestMember method = testClass.Members["BaseBaseTestFixture.BaseBaseTest"]; Assert.AreEqual(c, method.Member.DeclaringType); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs index 061dfcb34d..5d1ce38f12 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using NUnit.Framework; @@ -14,7 +13,6 @@ namespace UnitTesting.Tests.Project public class TwoRootNamespacesTestFixture { TestProject testProject; - MockProjectContent projectContent; MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs index f164251010..31f3038585 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs @@ -18,7 +18,6 @@ namespace UnitTesting.Tests.Tree SelectedTests selectedTests; List projects; MockCSharpProject project; - MockClass c; [SetUp] public void Init() diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs index b1c8e1b017..ef7248423f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs @@ -195,7 +195,7 @@ namespace UnitTesting.Tests.Tree MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); MockMethod mockMethod = new MockMethod(c, "Method"); TestMember testMethod = new TestMember(mockMethod); - testClass.TestMembers.Add(testMethod); + testClass.Members.Add(testMethod); Assert.AreEqual(0, testClassNode.Nodes.Count); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs index 10e07a891d..de4273a460 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -15,7 +14,6 @@ namespace UnitTesting.Tests.Tree MockTestTreeView treeView; GotoDefinitionCommand gotoDefinitionCommand; MockFileService fileService; - MockMethod baseClassMethod; [SetUp] public void Init() diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs index d7f56948ec..3814af9508 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Windows.Forms; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; @@ -374,7 +373,7 @@ namespace UnitTesting.Tests.Tree MockMethod method = new MockMethod(testClass.Class, "NewMethod"); method.Attributes.Add(new MockAttribute("Test")); - testClass.TestMembers.Add(new TestMember(method)); + testClass.Members.Add(new TestMember(method)); ExtTreeNode newMethodNode = null; foreach (ExtTreeNode node in testFixtureNode.Nodes) { @@ -400,8 +399,8 @@ namespace UnitTesting.Tests.Tree TestClass testClass = projectNode.TestProject.TestClasses["RootNamespace.Tests.MyTestFixture"]; TestMemberTreeNode methodNode = (TestMemberTreeNode)testFixtureNode.Nodes[0]; - TestMember testMethod = testClass.TestMembers[0]; - testClass.TestMembers.Remove(testMethod); + TestMember testMethod = testClass.Members[0]; + testClass.Members.Remove(testMethod); Assert.AreEqual(0, testFixtureNode.Nodes.Count); Assert.IsTrue(methodNode.IsDisposed); @@ -445,7 +444,7 @@ namespace UnitTesting.Tests.Tree // Make sure the TestClass.Dispose call removes all // event handlers. - testClass.TestMembers.RemoveAt(0); + testClass.Members.RemoveAt(0); Assert.AreEqual(1, testFixtureNode.Nodes.Count, "Should still have one child node."); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/OpenUnitTestsPadWithSolutionOpenTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/OpenUnitTestsPadWithSolutionOpenTestFixture.cs index 83e30381dd..10239e1e7f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/OpenUnitTestsPadWithSolutionOpenTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/OpenUnitTestsPadWithSolutionOpenTestFixture.cs @@ -3,7 +3,6 @@ using System; using System.Windows.Forms; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs index ac76b19c4f..320a06635d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs @@ -4,7 +4,6 @@ using System; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; @@ -43,9 +42,9 @@ namespace UnitTesting.Tests.Tree methodNames); TestClass testClass = testProject.TestClasses[0]; - firstTestMethod = testClass.TestMembers[0]; - secondTestMethod = testClass.TestMembers[1]; - thirdTestMethod = testClass.TestMembers[2]; + firstTestMethod = testClass.Members[0]; + secondTestMethod = testClass.Members[1]; + thirdTestMethod = testClass.Members[2]; context.MockUnitTestsPad.AddTestProject(testProject); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs index daa2a2cf50..6b4ff43bd9 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs @@ -3,7 +3,6 @@ using System; using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -12,7 +11,7 @@ namespace UnitTesting.Tests.Tree [TestFixture] public class TestResultFailureTaskTestFixture { - Task task; + SDTask task; [SetUp] public void Init() diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs index 50d58a7020..9962f9c46e 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs @@ -3,7 +3,6 @@ using System; using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -13,7 +12,7 @@ namespace UnitTesting.Tests.Tree [TestFixture] public class TestResultFailureTaskWithNoMessageTestFixture { - Task task; + SDTask task; [TestFixtureSetUp] public void SetUpFixture() diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs index 7efefc8c17..237a802cda 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs @@ -3,7 +3,6 @@ using System; using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -13,7 +12,7 @@ namespace UnitTesting.Tests.Tree [TestFixture] public class TestResultIgnoreTaskTestFixture { - Task task; + SDTask task; [SetUp] public void Init() diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs index 49642e6fce..d581d7d70a 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs @@ -13,7 +13,7 @@ namespace UnitTesting.Tests.Tree [TestFixture] public class TestResultIgnoreTaskWithNoMessageTestFixture { - Task task; + SDTask task; [TestFixtureSetUp] public void SetUpFixture() diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs index 1487de22b0..30de30a256 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs @@ -3,7 +3,6 @@ using System; using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -13,7 +12,7 @@ namespace UnitTesting.Tests.Tree [TestFixture] public class TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture { - Task task; + SDTask task; [SetUp] public void Init() diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs index b789c74193..08ebbc0a81 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs @@ -2,8 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using ICSharpCode.SharpDevelop.Bookmarks; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Gui.ClassBrowser; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -13,9 +11,10 @@ using UnitTesting.Tests.Utils; namespace UnitTesting.Tests.Tree { - [TestFixture] + [TestFixture, Ignore("Class Browser")] public class TestableConditionTests { + /*( TestableCondition testableCondition; MockRegisteredTestFrameworks testFrameworks; @@ -177,6 +176,6 @@ namespace UnitTesting.Tests.Tree ClassNode classNode = new ClassNode(null, mockClass); Assert.IsNull(TestableCondition.GetProject(classNode)); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs index bae0314187..dc947e3309 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Windows.Forms; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; @@ -20,9 +19,10 @@ namespace UnitTesting.Tests.Tree /// correctly afterwards. We also test that the order of the /// tree nodes is correct after adding new methods. /// - [TestFixture] + [TestFixture, Ignore("Tree tests")] public class TreeNodeSortingTestFixture { + /* DummyParserServiceTestTreeView treeView; TestProjectTreeNode projectNode; TestNamespaceTreeNode myTestsNamespaceNode; @@ -245,6 +245,6 @@ namespace UnitTesting.Tests.Tree MockClass c = new MockClass(projectContent, name); c.Attributes.Add(new MockAttribute("TestFixture")); return new TestClass(c, testFrameworks); - } + }*/ } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs index 5af4036fb0..a9a3fba820 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Windows.Forms; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; diff --git a/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj b/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj index e27bffa216..d2a3b0d48f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj +++ b/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj @@ -16,7 +16,8 @@ 4096 4 false - v4.0 + v4.5 + obj\Debug\ @@ -54,6 +55,9 @@ ..\..\..\..\Tools\NUnit\nunit.framework.dll False + + ..\..\..\..\Libraries\RhinoMocks\Rhino.Mocks.dll + 3.5 @@ -77,7 +81,6 @@ - @@ -88,70 +91,13 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Component - - - UserControl - - @@ -160,7 +106,6 @@ - @@ -176,22 +121,11 @@ - - - - - - - - - - - @@ -199,15 +133,11 @@ - - - - @@ -227,29 +157,18 @@ Always - - - - - Component - - - - - - @@ -257,6 +176,19 @@ + + {53DCA265-3C3C-42F9-B647-F72BA678122B} + ICSharpCode.NRefactory.CSharp + + + {3B2A5653-EC97-4001-BB9B-D90F1AF2C371} + ICSharpCode.NRefactory + + + {8035765F-D51F-4A0C-A746-2FD100E19419} + ICSharpCode.SharpDevelop.Widgets + True + {1F261725-6318-4434-A1B1-6C70CE4CD324} UnitTesting @@ -269,14 +201,6 @@ {2748AD25-9C63-4E12-877B-4DCE96FBED54} ICSharpCode.SharpDevelop - - {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} - ICSharpCode.SharpDevelop.Dom - - - {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} - NRefactory - \ No newline at end of file diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestProjectTreeNode.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestProjectTreeNode.cs deleted file mode 100644 index ccdaf27d18..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestProjectTreeNode.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.UnitTesting; - -namespace UnitTesting.Tests.Utils -{ - /// - /// Derived version of the TestProjectTreeNode class that - /// allows us to call the UpdateImageListIndex method directly. - /// - public class DerivedTestProjectTreeNode : TestProjectTreeNode - { - public DerivedTestProjectTreeNode(TestProject testProject) - : base(testProject) - { - } - - /// - /// Calls the base class's UpdateImageListIndex method. - /// - public void CallUpdateImageListIndex(TestResultType result) - { - base.UpdateImageListIndex(result); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs deleted file mode 100644 index 2f0c4d8204..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs +++ /dev/null @@ -1,29 +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.Forms; -using ICSharpCode.UnitTesting; - -namespace UnitTesting.Tests.Utils -{ - /// - /// Derives from the TestTreeView class and allows us to directly - /// call the OnBeforeSelect method. - /// - public class DerivedTestTreeView : TestTreeView - { - public DerivedTestTreeView() - : base(new MockTestFrameworksWithNUnitFrameworkSupport()) - { - } - - /// - /// Calls the base class's OnBeforeSelect method. - /// - public void CallOnBeforeSelect(TreeViewCancelEventArgs e) - { - base.OnBeforeSelect(e); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestingOptionsPanel.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestingOptionsPanel.cs deleted file mode 100644 index 59a6b6e647..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestingOptionsPanel.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.UnitTesting; - -namespace UnitTesting.Tests.Utils -{ - /// - /// Utility class used to test the UnitTestingOptionsPanel class. - /// - public class DerivedUnitTestingOptionsPanel : UnitTestingOptionsPanel - { - string setupFromManifestResourceName = String.Empty; - - public DerivedUnitTestingOptionsPanel(UnitTestingOptions options) : base(options) - { - } - - /// - /// Returns the resource name used to create the stream when - /// initialising the XmlUserControl. - /// - public string SetupFromManifestResourceName { - get { return setupFromManifestResourceName; } - } - - /// - /// Called in CompilingOptionsPanel.LoadPanelContents when - /// initialising the XmlUserControl. - /// - protected override void SetupFromManifestResource(string resource) - { - setupFromManifestResourceName = resource; - base.SetupFromManifestResource(resource); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs deleted file mode 100644 index 3992cb9aba..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs +++ /dev/null @@ -1,150 +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.Forms; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Project; -using ICSharpCode.UnitTesting; - -namespace UnitTesting.Tests.Utils -{ - /// - /// Class that derives from UnitTestsPad so we can access protected - /// methods and test it. - /// - public class DerivedUnitTestsPad : UnitTestsPad - { - bool getOpenSolutionCalled; - bool isParserLoadingSolutionCalled; - MockProjectContent projectContent = new MockProjectContent(); - Solution openSolution; - bool loadSolutionProjectsThreadEndedHandled; - bool addedLoadSolutionProjectsThreadEndedHandler; - DummyParserServiceTestTreeView treeView = new DummyParserServiceTestTreeView(); - - public DerivedUnitTestsPad(Solution openSolution) - : base(new MockTestFrameworksWithNUnitFrameworkSupport()) - { - this.openSolution = openSolution; - } - - public DerivedUnitTestsPad() - : this(null) - { - } - - /// - /// Gets the project content to be used when creating the - /// derived test tree view. - /// - public MockProjectContent ProjectContent { - get { return projectContent; } - set { - projectContent = value; - treeView.ProjectContentForProject = projectContent; - } - } - - public bool GetOpenSolutionCalled { - get { return getOpenSolutionCalled; } - } - - public bool IsParserLoadingSolutionCalled { - get { return isParserLoadingSolutionCalled; } - } - - /// - /// Checks whether the ParserService's LoadSolutionProjectsThreadEnded event - /// is mapped to an event handler before IsParserLoadingSolution is - /// called. This ensures we do not miss this event. - /// - public bool LoadSolutionProjectsThreadEndedHandled { - get { return loadSolutionProjectsThreadEndedHandled; } - } - - public void CallSolutionLoaded(Solution solution) - { - base.SolutionLoaded(solution); - } - - public void CallSolutionClosed() - { - base.SolutionClosed(); - } - - public void CallProjectItemRemoved(ProjectItem item) - { - base.ProjectItemRemoved(item); - } - - public void CallProjectItemAdded(ProjectItem item) - { - base.ProjectItemAdded(item); - } - - public void CallProjectAdded(IProject project) - { - base.ProjectAdded(project); - } - - public void CallSolutionFolderRemoved(ISolutionFolder folder) - { - base.SolutionFolderRemoved(folder); - } - - public void CallUpdateParseInfo(ICompilationUnit oldUnit, ICompilationUnit newUnit) - { - base.UpdateParseInfo(oldUnit, newUnit); - } - - /// - /// Returns a dummy toolstrip so the UnitTestsPad can be - /// tested. If the default method is called the AddInTree - /// is referenced which is not available during testing. - /// - protected override ToolStrip CreateToolStrip(string name) - { - return new ToolStrip(); - } - - /// - /// Returns a dummy ContextMenuStrip so the UnitTestsPad can be - /// tested. If the default method is called the AddInTree - /// is referenced which is not available during testing. - /// - protected override ContextMenuStrip CreateContextMenu(string name) - { - return new ContextMenuStrip(); - } - - /// - /// Returns a dummy tree view where we can mock the - /// IProjectContent that will be used by the TestTreeView. - /// - protected override TestTreeView CreateTestTreeView(IRegisteredTestFrameworks testFrameworks) - { - return treeView; - } - - protected override Solution GetOpenSolution() - { - getOpenSolutionCalled = true; - return openSolution; - } - - protected override bool IsParserLoadingSolution { - get { - loadSolutionProjectsThreadEndedHandled = addedLoadSolutionProjectsThreadEndedHandler; - isParserLoadingSolutionCalled = true; - return false; - } - } - - protected override void OnAddedLoadSolutionProjectsThreadEndedHandler() - { - addedLoadSolutionProjectsThreadEndedHandler = true; - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs deleted file mode 100644 index e1fb556559..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs +++ /dev/null @@ -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 ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Project; -using ICSharpCode.UnitTesting; -using System; - -namespace UnitTesting.Tests.Utils -{ - /// - /// Provides a way to return dummy data for IProjectContents - /// without having to use the ParserService. - /// - public class DummyParserServiceTestTreeView : TestTreeView - { - IProjectContent projectContent; - - public DummyParserServiceTestTreeView(IRegisteredTestFrameworks testFrameworks) - : base(testFrameworks) - { - } - - public DummyParserServiceTestTreeView() - : this(new MockTestFrameworksWithNUnitFrameworkSupport()) - { - } - - /// - /// Gets or sets the project content that will be returned from the - /// GetProjectContent method. - /// - public IProjectContent ProjectContentForProject { - get { return projectContent; } - set { projectContent = value; } - } - - public override IProjectContent GetProjectContent(IProject project) - { - return projectContent; - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs index 00b3ded769..501ba35564 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs @@ -16,7 +16,7 @@ namespace UnitTesting.Tests.Utils { } - public List BuildItems(string path, object caller) + public IReadOnlyList BuildItems(string path, object caller, bool throwOnNotFound) { object obj; if (treeItems.TryGetValue(path, out obj)) { @@ -29,5 +29,38 @@ namespace UnitTesting.Tests.Utils { treeItems.Add(path, items); } + + public IReadOnlyList AddIns { + get { + throw new NotImplementedException(); + } + } + + public System.Collections.Concurrent.ConcurrentDictionary Doozers { + get { + throw new NotImplementedException(); + } + } + + public System.Collections.Concurrent.ConcurrentDictionary ConditionEvaluators { + get { + throw new NotImplementedException(); + } + } + + public object BuildItem(string path, object caller) + { + throw new NotImplementedException(); + } + + public object BuildItem(string path, object caller, IEnumerable additionalConditions) + { + throw new NotImplementedException(); + } + + public AddInTreeNode GetTreeNode(string path, bool throwOnNotFound) + { + throw new NotImplementedException(); + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAmbience.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAmbience.cs deleted file mode 100644 index 558f4c5723..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAmbience.cs +++ /dev/null @@ -1,98 +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 ICSharpCode.SharpDevelop.Dom; -using System; - -namespace UnitTesting.Tests.Utils -{ - public class MockAmbience : IAmbience - { - public MockAmbience() - { - } - - public ConversionFlags ConversionFlags { - get { - return ConversionFlags.None; - } - set { - } - } - - public string Convert(ModifierEnum modifier) - { - return String.Empty; - } - - public string Convert(IClass c) - { - return String.Empty; - } - - public string ConvertEnd(IClass c) - { - return String.Empty; - } - - public string Convert(IEntity entity) - { - return String.Empty; - } - - public string Convert(IField field) - { - return String.Empty; - } - - public string Convert(IProperty property) - { - return String.Empty; - } - - public string Convert(IEvent e) - { - return String.Empty; - } - - public string Convert(IMethod m) - { - return String.Empty; - } - - public string ConvertEnd(IMethod m) - { - return String.Empty; - } - - public string Convert(IParameter param) - { - return String.Empty; - } - - public string Convert(IReturnType returnType) - { - return String.Empty; - } - - public string WrapAttribute(string attribute) - { - return String.Empty; - } - - public string WrapComment(string comment) - { - return String.Empty; - } - - public string GetIntrinsicTypeName(string dotNetTypeName) - { - return String.Empty; - } - - public string ConvertAccessibility(ModifierEnum accessibility) - { - return String.Empty; - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAttribute.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAttribute.cs deleted file mode 100644 index 2e0a139c04..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAttribute.cs +++ /dev/null @@ -1,65 +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 ICSharpCode.SharpDevelop.Dom; -using System; - -namespace UnitTesting.Tests.Utils -{ - public class MockAttribute : IAttribute - { - IReturnType type; - - public MockAttribute(string name) - { - type = new DefaultReturnType(new MockClass(name)); - } - - public IReturnType AttributeType { - get { - return type; - } - } - - public ICompilationUnit CompilationUnit { - get { - throw new NotImplementedException(); - } - } - - public DomRegion Region { - get { - throw new NotImplementedException(); - } - } - - public AttributeTarget AttributeTarget { - get { - throw new NotImplementedException(); - } - } - - public System.Collections.Generic.IList PositionalArguments { - get { - throw new NotImplementedException(); - } - } - - public System.Collections.Generic.IDictionary NamedArguments { - get { - throw new NotImplementedException(); - } - } - - public bool IsFrozen { - get { - throw new NotImplementedException(); - } - } - - public void Freeze() - { - throw new NotImplementedException(); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs index a0dac8a7cd..318d3114c5 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; @@ -33,10 +32,10 @@ namespace UnitTesting.Tests.Utils get { return "C#"; } } - public override LanguageProperties LanguageProperties { - get { return LanguageProperties.CSharp; } - } - +// public override LanguageProperties LanguageProperties { +// get { return LanguageProperties.CSharp; } +// } +// public bool IsSaved { get { return saved; } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs deleted file mode 100644 index 3f1bcb7598..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs +++ /dev/null @@ -1,166 +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 ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Project; -using System; -using System.Collections.Generic; - -namespace UnitTesting.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 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 attributes = new List(); - 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; - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs index dd99f8d047..9b573d5589 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs @@ -149,11 +149,6 @@ namespace UnitTesting.Tests.Utils 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(); @@ -166,5 +161,10 @@ namespace UnitTesting.Tests.Utils public bool BreakAtBeginning { get; set; } public bool IsAttached { get; set; } + + public void HandleToolTipRequest(ICSharpCode.SharpDevelop.Editor.ToolTipRequestEventArgs e) + { + throw new NotImplementedException(); + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs index aa9f6bd1d7..7dd73adf16 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs @@ -2,37 +2,15 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; namespace UnitTesting.Tests.Utils { - public class MockFileService : IUnitTestFileService + public class MockFileService : IFileSystem { public string FileNamePassedToFileExists; public bool FileExistsReturnValue = true; - string fileOpened; - FilePosition? filePositionJumpedTo; - - public string FileOpened { - get { return fileOpened; } - } - - public FilePosition? FilePositionJumpedTo { - get { return filePositionJumpedTo; } - } - - public void OpenFile(string fileName) - { - fileOpened = fileName; - } - - public void JumpToFilePosition(string fileName, int line, int column) - { - filePositionJumpedTo = new FilePosition(fileName, line, column); - } - public bool FileExists(string fileName) { FileNamePassedToFileExists = fileName; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMember.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMember.cs deleted file mode 100644 index 1d93be47cb..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMember.cs +++ /dev/null @@ -1,272 +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 ICSharpCode.SharpDevelop.Dom; -using System; -using System.Collections.Generic; - -namespace UnitTesting.Tests.Utils -{ - public class MockMember : IMember - { - public MockMember() - { - } - - public string FullyQualifiedName { - get { - return String.Empty; - } - } - - public DomRegion Region { - get { - return DomRegion.Empty; - } - } - - public string Name { - get { - return String.Empty; - } - } - - public string Namespace { - get { - return String.Empty; - } - } - - public string DotNetName { - get { - return String.Empty; - } - } - - public IReturnType ReturnType { - get { - return null; - } - set { - } - } - - public IClass DeclaringType { - get { - return null; - } - } - - public ModifierEnum Modifiers { - get { - return ModifierEnum.None; - } - set { - } - } - - public IList Attributes { - get { - return null; - } - } - - public string Documentation { - get { - return String.Empty; - } - } - - public bool IsAbstract { - get { - return false; - } - } - - public bool IsSealed { - get { - return false; - } - } - - public bool IsStatic { - get { - return false; - } - } - - public bool IsConst { - get { - return false; - } - } - - public bool IsVirtual { - get { - return false; - } - } - - public bool IsPublic { - get { - return true; - } - } - - public bool IsProtected { - get { - return false; - } - } - - public bool IsPrivate { - get { - return false; - } - } - - public bool IsInternal { - get { - return false; - } - } - - public bool IsPartial { - get { - return false; - } - } - - public bool IsReadonly { - get { - return false; - } - } - - public bool IsProtectedAndInternal { - get { - return false; - } - } - - public bool IsProtectedOrInternal { - get { - return false; - } - } - - public bool IsOverride { - get { - return false; - } - } - - public bool IsOverridable { - get { - return false; - } - } - - public bool IsNew { - get { - return false; - } - } - - public bool IsSynthetic { - get { - return false; - } - } - - public object UserData { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree) - { - throw new NotImplementedException(); - } - - public bool MustBeShown(IClass callingClass, bool showStatic, bool isClassInInheritanceTree) - { - throw new NotImplementedException(); - } - - public int CompareTo(object obj) - { - throw new NotImplementedException(); - } - - public object Clone() - { - throw new NotImplementedException(); - } - - public IReturnType DeclaringTypeReference { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public DomRegion BodyRegion { - get { - throw new NotImplementedException(); - } - } - - public IList InterfaceImplementations { - get { - throw new NotImplementedException(); - } - } - - public IMember GenericMember { - get { - throw new NotImplementedException(); - } - } - - public IMember CreateSpecializedMember() - { - throw new NotImplementedException(); - } - - public bool IsFrozen { - get { - return false; - } - } - - public void Freeze() - { - throw new NotImplementedException(); - } - - public ICompilationUnit CompilationUnit { - get { - throw new NotImplementedException(); - } - } - - public IProjectContent ProjectContent { - get { - throw new NotImplementedException(); - } - } - - public EntityType EntityType { - get { - throw new NotImplementedException(); - } - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMemberNode.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMemberNode.cs deleted file mode 100644 index 41b4612e47..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMemberNode.cs +++ /dev/null @@ -1,21 +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 ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Gui.ClassBrowser; -using System; - -namespace UnitTesting.Tests.Utils -{ - public class MockMemberNode : MemberNode - { - public MockMemberNode(IMethod method) : base(method) - { - } - - protected override IAmbience GetAmbience() - { - return new MockAmbience(); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs deleted file mode 100644 index 3e7273ece9..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.UnitTesting; - -namespace UnitTesting.Tests.Utils -{ - public class MockMessageService : IUnitTestMessageService - { - public string QuestionPassedToAskQuestion; - public string CaptionPassedToAskQuestion; - public bool AskQuestionReturnValue; - public string FormatPassedToShowFormattedErrorMessage; - public string ItemPassedToShowFormattedErrorMessage; - - public bool AskQuestion(string question, string caption) - { - QuestionPassedToAskQuestion = question; - CaptionPassedToAskQuestion = caption; - return AskQuestionReturnValue; - } - - public void ShowFormattedErrorMessage(string format, string item) - { - FormatPassedToShowFormattedErrorMessage = format; - ItemPassedToShowFormattedErrorMessage = item; - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs deleted file mode 100644 index 87d8273c19..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs +++ /dev/null @@ -1,62 +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.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Project; - -namespace UnitTesting.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 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 attributes = new List(); - attributes.Add(attribute); - - return CreateMockMethodWithAttributes(attributes); - } - - public MockClass MockDeclaringType { - get { return DeclaringType as MockClass; } - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs index d7d5f61d86..114daf41e5 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; @@ -18,8 +18,8 @@ namespace UnitTesting.Tests.Utils ITestResultsMonitor testResultsMonitor; UnitTestingOptions options; IUnitTestDebuggerService debuggerService; - IUnitTestMessageService messageService; - IUnitTestFileService fileService = new MockFileService(); + IMessageService messageService; + IFileSystem fileService = new MockFileService(); public MockNUnitTestFramework(IUnitTestProcessRunner processRunner, ITestResultsMonitor testResultsMonitor, @@ -31,7 +31,7 @@ namespace UnitTesting.Tests.Utils public MockNUnitTestFramework(IUnitTestDebuggerService debuggerService, ITestResultsMonitor testResultsMonitor, UnitTestingOptions options, - IUnitTestMessageService messageService) + IMessageService messageService) : this(debuggerService, null, testResultsMonitor, options, messageService) { } @@ -40,7 +40,7 @@ namespace UnitTesting.Tests.Utils IUnitTestProcessRunner processRunner, ITestResultsMonitor testResultsMonitor, UnitTestingOptions options, - IUnitTestMessageService messageService) + IMessageService messageService) { this.debuggerService = debuggerService; this.processRunner = processRunner; @@ -54,11 +54,11 @@ namespace UnitTesting.Tests.Utils throw new NotImplementedException(); } - public IEnumerable GetTestMembersFor(IClass @class) { + public IEnumerable GetTestMembersFor(TestProject project, ITypeDefinition @class) { throw new NotImplementedException(); } - public bool IsTestClass(IClass c) + public bool IsTestClass(ITypeDefinition c) { throw new NotImplementedException(); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs index 40547e79ee..7cef307079 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs @@ -23,10 +23,6 @@ namespace UnitTesting.Tests.Utils get { return base.FileSystem as MockFileService; } } - public MockMessageService MockMessageService { - get { return base.MessageService as MockMessageService; } - } - public MockNUnitTestRunnerContext() : base(new MockProcessRunner(), new MockTestResultsMonitor(), diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockParameter.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockParameter.cs deleted file mode 100644 index b2c17542cf..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockParameter.cs +++ /dev/null @@ -1,94 +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.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; - -namespace UnitTesting.Tests.Utils -{ - public class MockParameter : IParameter - { - public MockParameter() - { - } - - public string Name { - get { - throw new NotImplementedException(); - } - } - - public IReturnType ReturnType { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IList Attributes { - get { - throw new NotImplementedException(); - } - } - - public ParameterModifiers Modifiers { - get { - throw new NotImplementedException(); - } - } - - public DomRegion Region { - get { - throw new NotImplementedException(); - } - } - - public string Documentation { - get { - throw new NotImplementedException(); - } - } - - public bool IsOut { - get { - throw new NotImplementedException(); - } - } - - public bool IsRef { - get { - throw new NotImplementedException(); - } - } - - public bool IsParams { - get { - throw new NotImplementedException(); - } - } - - public bool IsOptional { - get { - throw new NotImplementedException(); - } - } - - public int CompareTo(object obj) - { - throw new NotImplementedException(); - } - - public bool IsFrozen { - get { - throw new NotImplementedException(); - } - } - - public void Freeze() - { - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs deleted file mode 100644 index 641f67ff1f..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs +++ /dev/null @@ -1,190 +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.Collections; -using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Editor.CodeCompletion; -using ICSharpCode.SharpDevelop.Project; - -namespace UnitTesting.Tests.Utils -{ - public class MockProjectContent : IProjectContent - { - LanguageProperties language = LanguageProperties.CSharp; - List classes = new List(); - object project; - - public MockProjectContent() - { - } - - public event EventHandler ReferencedContentsChanged; - - public XmlDoc XmlDoc { - get { - throw new NotImplementedException(); - } - } - - public ICollection Classes { - get { return classes; } - } - - public ICollection NamespaceNames { - get { - throw new NotImplementedException(); - } - } - - public ICollection ReferencedContents { - get { - throw new NotImplementedException(); - } - } - - public LanguageProperties Language { - get { return language; } - set { language = value; } - } - - public IUsing DefaultImports { - get { - throw new NotImplementedException(); - } - } - - public object Project { - get { return project; } - set { project = value; } - } - - public IProject ProjectAsIProject { - get { return project as IProject; } - } - - public SystemTypes SystemTypes { - get { return new SystemTypes(this); } - } - - public string GetXmlDocumentation(string memberTag) - { - return string.Empty; - } - - 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) - { - throw new NotImplementedException(); - } - - public IClass GetClass(string typeName, int typeParameterCount) - { - MockClass c = new MockClass(this); - c.FullyQualifiedName = typeName; - return c; - } - - public bool NamespaceExists(string name) - { - throw new NotImplementedException(); - } - - public List GetNamespaceContents(string nameSpace) - { - throw new NotImplementedException(); - } - - public IClass GetClass(string typeName, int typeParameterCount, LanguageProperties language, GetClassOptions options) - { - throw new NotImplementedException(); - } - - public bool NamespaceExists(string name, LanguageProperties language, bool lookInReferences) - { - throw new NotImplementedException(); - } - - public void AddNamespaceContents(List list, string subNameSpace, LanguageProperties language, bool lookInReferences) - { - throw new NotImplementedException(); - } - - public string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn) - { - throw new NotImplementedException(); - } - - public SearchTypeResult SearchType(SearchTypeRequest request) - { - throw new NotImplementedException(); - } - - public IClass GetClassByReflectionName(string fullMemberName, bool lookInReferences) - { - throw new NotImplementedException(); - } - - public FilePosition GetPosition(IEntity entity) - { - throw new NotImplementedException(); - } - - public void Dispose() - { - throw new NotImplementedException(); - } - - void OnReferencedContentsChanged() - { - if (ReferencedContentsChanged != null) { - ReferencedContentsChanged(this, new EventArgs()); - } - } - - public bool IsUpToDate { - get { - throw new NotImplementedException(); - } - } - - public IList GetAssemblyAttributes() - { - throw new NotImplementedException(); - } - - public bool InternalsVisibleTo(IProjectContent otherProjectContent) - { - throw new NotImplementedException(); - } - - public string AssemblyName { - get { return String.Empty; } - } - - public void AddAllContents(List list, LanguageProperties language, bool lookInReferences) - { - throw new NotImplementedException(); - } - - public List GetAllContents() - { - throw new NotImplementedException(); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs index b9d4e446af..be37f8a271 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs index a4d15efd64..f8aac8bad3 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs @@ -3,7 +3,6 @@ using System; using ICSharpCode.Core; -using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; @@ -20,7 +19,6 @@ namespace UnitTesting.Tests.Utils public MockBuildProjectFactory MockBuildProjectFactory = new MockBuildProjectFactory(); public MockBuildOptions MockBuildOptions = new MockBuildOptions(); public MockUnitTestsPad MockUnitTestsPad = new MockUnitTestsPad(); - public MockMessageService MockMessageService = new MockMessageService(); public MockSaveAllFilesCommand MockSaveAllFilesCommand = new MockSaveAllFilesCommand(); public MockStatusBarService MockStatusBarService = new MockStatusBarService(); public MessageViewCategory UnitTestMessageViewCategory = new MessageViewCategory("Unit Tests"); @@ -54,7 +52,7 @@ namespace UnitTesting.Tests.Utils get { return MockUnitTestsPad; } } - public IUnitTestMessageService MessageService { + public IMessageService MessageService { get { return MockMessageService; } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs index 7afb47de79..9f6620e509 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs @@ -13,7 +13,7 @@ namespace UnitTesting.Tests.Utils { public bool IsClearExceptCommentTasksMethodCalled; public bool IsInUpdateWhilstClearExceptCommentTasksMethodCalled; - public List Tasks = new List(); + public List Tasks = new List(); public bool HasCriticalErrorsReturnValue; public bool TreatWarningsAsErrorsParameterPassedToHasCriticalErrors; @@ -41,7 +41,7 @@ namespace UnitTesting.Tests.Utils IsInUpdateWhilstClearExceptCommentTasksMethodCalled = inUpdate; } - public void Add(Task task) + public void Add(SDTask task) { if ((task.TaskType == TaskType.Error) || (task.TaskType == TaskType.Warning)) { SomethingWentWrong = true; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs index 672127300f..d84697c9f9 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs @@ -2,9 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Linq; using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; +using System.Linq; + +using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; @@ -13,9 +14,9 @@ namespace UnitTesting.Tests.Utils public class MockTestFramework : ITestFramework { IMember isTestMemberParameterUsed; - List testMembers = new List(); - IClass isTestClassParameterUsed; - List testClasses = new List(); + List testMembers = new List(); + ITypeDefinition isTestClassParameterUsed; + List testClasses = new List(); IProject isTestProjectParameterUsed; List testProjects = new List(); List testRunnersCreated = new List(); @@ -32,35 +33,35 @@ namespace UnitTesting.Tests.Utils return testMembers.Contains(member); } - public IEnumerable GetTestMembersFor(IClass @class) { - return testMembers.Where(member => member.DeclaringType == @class).Select(member => new TestMember(member)); + public IEnumerable GetTestMembersFor(TestProject testProject, ITypeDefinition @class) { + return testMembers.Where(member => member.DeclaringType == @class).Select(member => new TestMember(testProject, member)); } public IMember IsTestMemberParameterUsed { get { return isTestMemberParameterUsed; } } - public void AddTestMember(IMember member) + public void AddTestMember(string reflectionName) { - testMembers.Add(member); + testMembers.Add(reflectionName); } - public bool IsTestClass(IClass c) + public bool IsTestClass(ITypeDefinition c) { isTestClassParameterUsed = c; - return testClasses.Contains(c); + return testClasses.Contains(c.ReflectionName); } - public IClass IsTestClassParameterUsed { + public ITypeDefinition IsTestClassParameterUsed { get { return isTestClassParameterUsed; } } - public void AddTestClass(IClass c) + public void AddTestClass(string reflectionName) { - testClasses.Add(c); + testClasses.Add(reflectionName); } - public void RemoveTestClass(IClass c) + public void RemoveTestClass(ITypeDefinition c) { testClasses.Remove(c); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs index 090b79ec2d..cf4fb4d43e 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs @@ -19,7 +19,7 @@ namespace UnitTesting.Tests.Utils { } - public event TestFinishedEventHandler TestFinished; + public event EventHandler TestFinished; public long InitialFilePosition { get { return filePosition; } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs index 4f8e7b3f86..b8e8b80002 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs @@ -14,9 +14,9 @@ namespace UnitTesting.Tests.Utils bool started = false; SelectedTests selectedTests; - public event TestFinishedEventHandler TestFinished; + public event EventHandler TestFinished; public event EventHandler AllTestsFinished; - public event MessageReceivedEventHandler MessageReceived; + public event EventHandler MessageReceived; public void Dispose() { diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs index a8117fbebc..e00d6b0af2 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs @@ -1,7 +1,6 @@ // 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 ICSharpCode.UnitTesting; using System; @@ -10,17 +9,17 @@ namespace UnitTesting.Tests.Utils { public class MockTestTreeView : ITestTreeView { - IMember selectedMember; - IClass selectedClass; + TestMember selectedMember; + TestClass selectedClass; IProject selectedProject; string selectedNamespace; - public IMember SelectedMember { + public TestMember SelectedMember { get { return selectedMember; } set { selectedMember = value; } } - public IClass SelectedClass { + public TestClass SelectedClass { get { return selectedClass; } set { selectedClass = value; } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs index 0d8db664ac..4329a9e8d0 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs @@ -10,12 +10,12 @@ namespace UnitTesting.Tests.Utils public class TaskComparison { bool match; - Task lhs; - Task rhs; + SDTask lhs; + SDTask rhs; string shortMismatchReason = String.Empty; StringBuilder mismatchReason = new StringBuilder(); - public TaskComparison(Task lhs, Task rhs) + public TaskComparison(SDTask lhs, SDTask rhs) { this.lhs = lhs; this.rhs = rhs; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs index 4e7821b718..a14a900a5e 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; @@ -45,7 +44,7 @@ namespace UnitTesting.Tests.Utils c.Methods.Add(method); TestMember testMember = new TestMember(method); - testClass.TestMembers.Add(testMember); + testClass.Members.Add(testMember); } c.Project.Name = "TestProject"; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs deleted file mode 100644 index 095e4e9cf4..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs +++ /dev/null @@ -1,91 +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.Collections.Generic; -using ICSharpCode.UnitTesting; -using ICSharpCode.SharpDevelop.Dom; -using NUnit.Framework; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class CreateMockClassWithAttributesTestFixture - { - MockClass mockClass; - MockAttribute firstAttribute; - MockAttribute secondAttribute; - - [SetUp] - public void Init() - { - firstAttribute = new MockAttribute("first"); - secondAttribute = new MockAttribute("second"); - List attributes = new List(); - attributes.Add(firstAttribute); - attributes.Add(secondAttribute); - - mockClass = MockClass.CreateMockClassWithAttributes(attributes); - } - - [Test] - public void ProjectContentLanguageIsCSharp() - { - Assert.AreEqual(LanguageProperties.CSharp, mockClass.ProjectContent.Language); - } - - [Test] - public void ProjectContentProjectIsMockCSharpProject() - { - Assert.IsNotNull(mockClass.ProjectContent.Project as MockCSharpProject); - } - - [Test] - public void ClassHasTwoAttributes() - { - Assert.AreEqual(2, mockClass.Attributes.Count); - } - - [Test] - public void FirstClassAttributeHasAttributeTypeWithFullyQualifiedNameOfFirst() - { - Assert.AreEqual("first", mockClass.Attributes[0].AttributeType.FullyQualifiedName); - } - - [Test] - public void SecondClassAttributeHasAttributeTypeWithFullyQualifiedNameOfSeocnd() - { - Assert.AreEqual("second", mockClass.Attributes[1].AttributeType.FullyQualifiedName); - } - - [Test] - public void ProjectContentContainsMockClass() - { - Assert.IsTrue(mockClass.ProjectContent.Classes.Contains(mockClass)); - } - - [Test] - public void CompoundClassIsSameAsMockClass() - { - Assert.AreEqual(mockClass, mockClass.GetCompoundClass()); - } - - [Test] - public void MockClassHasDefaultReturnType() - { - Assert.AreEqual(mockClass, mockClass.DefaultReturnType.GetUnderlyingClass()); - } - - [Test] - public void ClassHasCompilationUnit() - { - Assert.IsNotNull(mockClass.CompilationUnit); - } - - [Test] - public void ClassCompilationUnitHasSameProjectContentAsClass() - { - Assert.AreEqual(mockClass.ProjectContent, mockClass.CompilationUnit.ProjectContent); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs deleted file mode 100644 index 0d65e4b617..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs +++ /dev/null @@ -1,49 +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.Collections.Generic; -using ICSharpCode.UnitTesting; -using ICSharpCode.SharpDevelop.Dom; -using NUnit.Framework; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class CreateMockClassWithSingleAttributeTestFixture - { - MockClass mockClass; - MockAttribute firstAttribute; - - [SetUp] - public void Init() - { - firstAttribute = new MockAttribute("first"); - mockClass = MockClass.CreateMockClassWithAttribute(firstAttribute); - } - - [Test] - public void ProjectContentLanguageIsCSharp() - { - Assert.AreEqual(LanguageProperties.CSharp, mockClass.ProjectContent.Language); - } - - [Test] - public void ProjectContentProjectIsMockCSharpProject() - { - Assert.IsNotNull(mockClass.ProjectContent.Project as MockCSharpProject); - } - - [Test] - public void ClassHasOneAttribute() - { - Assert.AreEqual(1, mockClass.Attributes.Count); - } - - [Test] - public void FirstClassAttributeHasAttributeTypeWithFullyQualifiedNameOfFirst() - { - Assert.AreEqual("first", mockClass.Attributes[0].AttributeType.FullyQualifiedName); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs deleted file mode 100644 index 974bb465c7..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.UnitTesting; -using ICSharpCode.SharpDevelop.Dom; -using NUnit.Framework; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class CreateMockClassWithoutAnyAttributesTestFixture - { - MockClass mockClass; - - [SetUp] - public void Init() - { - mockClass = MockClass.CreateMockClassWithoutAnyAttributes(); - } - - [Test] - public void ProjectContentLanguageIsCSharp() - { - Assert.AreEqual(LanguageProperties.CSharp, mockClass.ProjectContent.Language); - } - - [Test] - public void ProjectContentProjectIsMockCSharpProject() - { - Assert.IsNotNull(mockClass.ProjectContent.Project as MockCSharpProject); - } - - [Test] - public void ClassHasNoAttributes() - { - Assert.AreEqual(0, mockClass.Attributes.Count); - } - - [Test] - public void ProjectIsMockCSharpProject() - { - Assert.IsNotNull(mockClass.Project); - } - - [Test] - public void ProjectContentContainsMockClass() - { - Assert.IsTrue(mockClass.ProjectContent.Classes.Contains(mockClass)); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs deleted file mode 100644 index 5c3c2aaa7d..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs +++ /dev/null @@ -1,67 +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.Collections.Generic; -using ICSharpCode.UnitTesting; -using ICSharpCode.SharpDevelop.Dom; -using NUnit.Framework; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class CreateMockMethodWithAttributesTestFixture - { - MockMethod mockMethod; - MockAttribute firstAttribute; - MockAttribute secondAttribute; - - [SetUp] - public void Init() - { - firstAttribute = new MockAttribute("first"); - secondAttribute = new MockAttribute("second"); - List attributes = new List(); - attributes.Add(firstAttribute); - attributes.Add(secondAttribute); - - mockMethod = MockMethod.CreateMockMethodWithAttributes(attributes); - } - - [Test] - public void DeclaringTypeProjectContentLanguageIsCSharp() - { - Assert.AreEqual(LanguageProperties.CSharp, mockMethod.DeclaringType.ProjectContent.Language); - } - - [Test] - public void ProjectContentProjectIsMockCSharpProject() - { - Assert.IsNotNull(mockMethod.DeclaringType.ProjectContent.Project as MockCSharpProject); - } - - [Test] - public void MethodHasTwoAttributes() - { - Assert.AreEqual(2, mockMethod.Attributes.Count); - } - - [Test] - public void FirstClassAttributeHasAttributeTypeWithFullyQualifiedNameOfFirst() - { - Assert.AreEqual("first", mockMethod.Attributes[0].AttributeType.FullyQualifiedName); - } - - [Test] - public void SecondClassAttributeHasAttributeTypeWithFullyQualifiedNameOfSeocnd() - { - Assert.AreEqual("second", mockMethod.Attributes[1].AttributeType.FullyQualifiedName); - } - - [Test] - public void MethodDeclaringTypeHasCompilationUnit() - { - Assert.IsNotNull(mockMethod.DeclaringType.CompilationUnit); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs deleted file mode 100644 index 54bd33e97c..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs +++ /dev/null @@ -1,49 +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.Collections.Generic; -using ICSharpCode.UnitTesting; -using ICSharpCode.SharpDevelop.Dom; -using NUnit.Framework; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class CreateMockMethodWithSingleAttributeTestFixture - { - MockMethod mockMethod; - MockAttribute firstAttribute; - - [SetUp] - public void Init() - { - firstAttribute = new MockAttribute("first"); - mockMethod = MockMethod.CreateMockMethodWithAttribute(firstAttribute); - } - - [Test] - public void DeclaringTypeProjectContentLanguageIsCSharp() - { - Assert.AreEqual(LanguageProperties.CSharp, mockMethod.DeclaringType.ProjectContent.Language); - } - - [Test] - public void ProjectContentProjectIsMockCSharpProject() - { - Assert.IsNotNull(mockMethod.DeclaringType.ProjectContent.Project as MockCSharpProject); - } - - [Test] - public void MethodHasOneAttribute() - { - Assert.AreEqual(1, mockMethod.Attributes.Count); - } - - [Test] - public void FirstClassAttributeHasAttributeTypeWithFullyQualifiedNameOfFirst() - { - Assert.AreEqual("first", mockMethod.Attributes[0].AttributeType.FullyQualifiedName); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs deleted file mode 100644 index 82fc80ebac..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.UnitTesting; -using ICSharpCode.SharpDevelop.Dom; -using NUnit.Framework; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class CreateMockMethodWithoutAnyAttributesTestFixture - { - MockMethod mockMethod; - - [SetUp] - public void Init() - { - mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes(); - } - - [Test] - public void DeclaringTypeProjectContentLanguageIsCSharp() - { - Assert.AreEqual(LanguageProperties.CSharp, mockMethod.DeclaringType.ProjectContent.Language); - } - - [Test] - public void ProjectContentProjectIsMockCSharpProject() - { - Assert.IsNotNull(mockMethod.DeclaringType.ProjectContent.Project as MockCSharpProject); - } - - [Test] - public void MethodHasNoAttributes() - { - Assert.AreEqual(0, mockMethod.Attributes.Count); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs index e703991c97..3c889da002 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs index 9cb42e9585..9b61d4ec75 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; @@ -24,8 +23,8 @@ namespace UnitTesting.Tests.Utils.Tests if (testProject.TestClasses.Count > 0) { testClass = testProject.TestClasses[0]; - if (testClass.TestMembers.Count > 0) { - testMethod = testClass.TestMembers[0]; + if (testClass.Members.Count > 0) { + testMethod = testClass.Members[0]; } } } @@ -66,7 +65,7 @@ namespace UnitTesting.Tests.Utils.Tests [Test] public void TestClassHasOneTestMethod() { - Assert.AreEqual(1, testClass.TestMembers.Count); + Assert.AreEqual(1, testClass.Members.Count); } [Test] diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithTwoTestMethodsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithTwoTestMethodsTestFixture.cs index 3e2647c449..4748bf8b94 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithTwoTestMethodsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithTwoTestMethodsTestFixture.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; @@ -28,19 +27,19 @@ namespace UnitTesting.Tests.Utils.Tests [Test] public void TestProjectWithTwoTestMethodsHasTwoMethods() { - Assert.AreEqual(2, testClass.TestMembers.Count); + Assert.AreEqual(2, testClass.Members.Count); } [Test] public void FirstTestMethodNameIsFoo() { - Assert.AreEqual("Foo", testClass.TestMembers[0].Name); + Assert.AreEqual("Foo", testClass.Members[0].Name); } [Test] public void SecondTestMethodNameIsBar() { - Assert.AreEqual("Bar", testClass.TestMembers[1].Name); + Assert.AreEqual("Bar", testClass.Members[1].Name); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockClassTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockClassTests.cs deleted file mode 100644 index 2fac8a5d02..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockClassTests.cs +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Project; -using NUnit.Framework; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class MockClassTests - { - MockClass outerClass; - MockClass innerClass; - - [Test] - public void FullyQualifiedName_NewInstanceCreatedWithFullyQualifiedName_ReturnsFullyQualifiedName() - { - string expectedFullyQualifiedName = "MyNamespace.MyClass"; - MockClass c = new MockClass(expectedFullyQualifiedName); - string fullyQualifiedName = c.FullyQualifiedName; - Assert.AreEqual(expectedFullyQualifiedName, fullyQualifiedName); - } - - [Test] - public void DotNetName_NewInstanceCreatedWithFullyQualifiedName_ReturnsDotNetNameThatMatchesFullyQualifiedName() - { - string fullyQualifiedName = "MyNamespace.MyClass"; - MockClass c = new MockClass(fullyQualifiedName); - string dotNetName = c.DotNetName; - Assert.AreEqual(fullyQualifiedName, dotNetName); - } - - [Test] - public void DotNetName_NewInstanceCreatedWithFullyQualifiedNameAndDotNetName_ReturnsExpectedDotNetName() - { - string fullyQualifiedName = "MyNamespace.MyClass.InnerClass"; - string expectedDotNetName = "MyNamespace.MyClass+InnerClass"; - MockClass c = new MockClass(fullyQualifiedName, expectedDotNetName); - string dotNetName = c.DotNetName; - Assert.AreEqual(expectedDotNetName, dotNetName); - } - - [Test] - public void Namespace_NewInstanceCreatedWithFullyQualifiedName_ReturnsNamespaceTakenFromFullyQualifiedName() - { - string fullyQualifiedName = "MyNamespace.MySubNamespace.MyClass"; - MockClass c = new MockClass(fullyQualifiedName); - string expectedNamespace = "MyNamespace.MySubNamespace"; - string actualNamespace = c.Namespace; - Assert.AreEqual(expectedNamespace, actualNamespace); - } - - [Test] - public void Name_NewInstanceCreatedWithFullyQualifiedName_ReturnsNameTakenFromFullyQualifiedName() - { - string fullyQualifiedName = "MyNamespace.MySubNamespace.MyClass"; - MockClass c = new MockClass(fullyQualifiedName); - string expectedName = "MyClass"; - string name = c.Name; - Assert.AreEqual(expectedName, name); - } - - [Test] - public void Namesapce_NewInstanceCreatedWithFullyQualifiedNameWithNoNamespace_ReturnsEmptyStringAsNamespace() - { - string fullyQualifiedName = "MyClass"; - MockClass c = new MockClass(fullyQualifiedName); - string expectedNamespace = String.Empty; - string actualNamespace = c.Namespace; - Assert.AreEqual(expectedNamespace, actualNamespace); - } - - [Test] - public void CompilationUnit_NewInstanceCreated_ReturnsNonNullCompilationUnit() - { - MockClass c = new MockClass(); - ICompilationUnit unit = c.CompilationUnit; - Assert.IsNotNull(unit); - } - - [Test] - public void ProjectContent_NewInstanceCreated_ReturnsMockProjectContent() - { - MockClass c = new MockClass(); - MockProjectContent projectContent = c.ProjectContent as MockProjectContent; - Assert.IsNotNull(projectContent); - } - - [Test] - public void CompoundClass_NewInstance_ReturnsClassItself() - { - MockClass c = new MockClass(); - IClass compoundClass = c.GetCompoundClass(); - Assert.AreEqual(c, compoundClass); - } - - [Test] - public void DefaultReturnTypeGetUnderlyClass_NewInstance_ReturnsOriginalMockClass() - { - MockClass c = new MockClass(); - IReturnType returnType = c.DefaultReturnType; - IClass underlyingClass = returnType.GetUnderlyingClass(); - Assert.AreEqual(c, underlyingClass); - } - - [Test] - public void DeclaringType_NewInstanceWithInnerClass_InnerClassHasOuterClassAsDeclaringType() - { - CreateClassWithInnerClass(); - IClass declaringType = innerClass.DeclaringType; - Assert.AreEqual(outerClass, declaringType); - } - - void CreateClassWithInnerClass() - { - outerClass = new MockClass("MyTests.A"); - innerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); - } - - [Test] - public void GetCompoundClass_NewInstanceWithInnerClass_InnerClassReturnsInnerClassAsCompoundClass() - { - CreateClassWithInnerClass(); - IClass compoundClass = innerClass.GetCompoundClass(); - Assert.AreEqual(innerClass, compoundClass); - } - - [Test] - public void InnerClasses_NewInstanceCreatedWithInnerClass_FirstClassInCollectionIsInnerClass() - { - CreateClassWithInnerClass(); - IClass firstInnerClass = outerClass.InnerClasses[0]; - Assert.AreEqual(innerClass, firstInnerClass); - } - - [Test] - public void BaseClass_ClassAddedToBaseTypes_ClassAddedToBaseTypesBecomesBaseClass() - { - MockClass c = new MockClass(); - MockClass baseClass = new MockClass(); - DefaultReturnType returnType = new DefaultReturnType(baseClass); - c.BaseTypes.Add(returnType); - IClass actualBaseClass = c.BaseClass; - Assert.AreEqual(baseClass, actualBaseClass); - } - - [Test] - public void BaseClass_AddBaseClassMethodCalled_ReturnsClassAddedUsingAddBaseClassMethod() - { - MockClass c = new MockClass(); - MockClass baseClass = new MockClass(); - c.AddBaseClass(baseClass); - IClass actualBaseClass = c.BaseClass; - Assert.AreEqual(baseClass, actualBaseClass); - } - - [Test] - public void DotNetName_NewInstanceCreatedWithProjectContent_ReturnsFullyQualifiedNameAsDotNetName() - { - MockProjectContent projectContent = new MockProjectContent(); - string expectedName = "MyNamespace.MyTests"; - MockClass c = new MockClass(projectContent, expectedName); - string dotNetName = c.DotNetName; - Assert.AreEqual(expectedName, dotNetName); - } - - [Test] - public void GetCompoundClass_SetCompoundClassMethodCalled_ReturnsClassPassedToSetCompoundClass() - { - MockClass c = new MockClass(); - MockClass compoundClass = new MockClass(); - c.SetCompoundClass(compoundClass); - IClass actualCompoundClass = c.GetCompoundClass(); - Assert.AreEqual(compoundClass, actualCompoundClass); - } - - [Test] - public void AddProperty_PassedPropertyName_AddsPropertyToClass() - { - MockClass c = new MockClass(); - c.AddProperty("MyProperty"); - - IProperty property = c.Properties[0]; - string name = property.Name; - - Assert.AreEqual("MyProperty", name); - } - - [Test] - public void InsertPropertyAtStart_PassedPropertyName_AddsPropertyAsFirstProperty() - { - MockClass c = new MockClass(); - c.AddProperty("SecondProperty"); - c.InsertPropertyAtStart("FirstProperty"); - - IProperty property = c.Properties[0]; - string name = property.Name; - - Assert.AreEqual("FirstProperty", name); - } - - [Test] - public void AddProperty_PassedPropertyName_ReturnsPropertyWithExpectedName() - { - MockClass c = new MockClass(); - IProperty property = c.AddProperty("MyProperty"); - string name = property.Name; - - Assert.AreEqual("MyProperty", name); - } - - [Test] - public void AddEvent_PassedEventName_AddsEventToClass() - { - MockClass c = new MockClass(); - c.AddEvent("MyEvent"); - - IEvent myEvent = c.Events[0]; - string name = myEvent.Name; - - Assert.AreEqual("MyEvent", name); - } - - [Test] - public void AddEvent_PassedEventName_ReturnsEventWithExpectedName() - { - MockClass c = new MockClass(); - IEvent myEvent = c.AddEvent("MyEvent"); - string name = myEvent.Name; - - Assert.AreEqual("MyEvent", name); - } - - [Test] - public void AddField_PassedFieldName_AddsFieldToClass() - { - MockClass c = new MockClass(); - c.AddField("MyField"); - - IField myField = c.Fields[0]; - string name = myField.Name; - - Assert.AreEqual("MyField", name); - } - - [Test] - public void AddField_PassedFieldName_ReturnsFieldWithExpectedName() - { - MockClass c = new MockClass(); - IField myField = c.AddField("MyField"); - string name = myField.Name; - - Assert.AreEqual("MyField", name); - } - - [Test] - public void AddMethod_PassedName_AddsMethodToClass() - { - MockClass c = new MockClass(); - c.AddMethod("MyMethod"); - - IMethod myMethod = c.Methods[0]; - string name = myMethod.Name; - - Assert.AreEqual("MyMethod", name); - } - - [Test] - public void AddMethod_PassedMethodName_ReturnsMethodWithExpectedName() - { - MockClass c = new MockClass(); - IMethod myMethod = c.AddMethod("MyMethod"); - string name = myMethod.Name; - - Assert.AreEqual("MyMethod", name); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockFileServiceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockFileServiceTestFixture.cs index 4900acfb00..6a8c0e4c75 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockFileServiceTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockFileServiceTestFixture.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs deleted file mode 100644 index 2deb932415..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.UnitTesting; -using NUnit.Framework; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class MockMessageServiceTestFixture - { - MockMessageService messageService; - - [SetUp] - public void Init() - { - messageService = new MockMessageService(); - } - - [Test] - public void CaptionIsNullByDefault() - { - Assert.IsNull(messageService.CaptionPassedToAskQuestion); - } - - [Test] - public void QuestionIsNullByDefault() - { - Assert.IsNull(messageService.QuestionPassedToAskQuestion); - } - - [Test] - public void QuestionIsSavedAfterAskQuestionMethodIsCalled() - { - string expectedQuestion = "question"; - messageService.AskQuestion(expectedQuestion, null); - - Assert.AreEqual(expectedQuestion, messageService.QuestionPassedToAskQuestion); - } - - [Test] - public void CaptionIsSavedAfterAskQuestionMethodIsCalled() - { - string expectedCaption = "caption"; - messageService.AskQuestion(null, expectedCaption); - - Assert.AreEqual(expectedCaption, messageService.CaptionPassedToAskQuestion); - } - - [Test] - public void AskQuestionMethodReturnsFalseByDefault() - { - Assert.IsFalse(messageService.AskQuestion(null, null)); - } - - [Test] - public void AskQuestionMethodReturnsTrueWhenConfigured() - { - messageService.AskQuestionReturnValue = true; - Assert.IsTrue(messageService.AskQuestion(null, null)); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMethodTestFixture.cs deleted file mode 100644 index 0c25fc60d9..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMethodTestFixture.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.UnitTesting; -using NUnit.Framework; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class MockMethodTestFixture - { - [Test] - public void DeclaringTypeReturnsExpectedClassWhenMethodCreated() - { - MockClass declaringType = new MockClass(); - MockMethod method = new MockMethod(declaringType); - Assert.AreEqual(declaringType, method.DeclaringType); - } - - [Test] - public void NameReturnsExpectedMethodNameWhenMethodCreated() - { - MockClass declaringType = new MockClass(); - MockMethod method = new MockMethod(declaringType, "MyMethod"); - Assert.AreEqual("MyMethod", method.Name); - } - - [Test] - public void FullyQualifiedNameReturnsFullyQualifiedMethodName() - { - MockClass declaringType = new MockClass("MyNamespace.MyClass"); - MockMethod method = new MockMethod(declaringType, "MyMethod"); - string expectedName = "MyNamespace.MyClass.MyMethod"; - Assert.AreEqual(expectedName, method.FullyQualifiedName); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectContentTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectContentTestFixture.cs deleted file mode 100644 index b343f3d64c..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectContentTestFixture.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.UnitTesting; -using NUnit.Framework; -using UnitTesting.Tests.Utils; - -namespace UnitTesting.Tests.Utils.Tests -{ - [TestFixture] - public class MockProjectContentTestFixture - { - MockProjectContent projectContent; - - [SetUp] - public void Init() - { - projectContent = new MockProjectContent(); - } - - [Test] - public void LanguageIsCSharpLanguage() - { - Assert.AreEqual(LanguageProperties.CSharp, projectContent.Language); - } - - [Test] - public void SystemTypesIsNotNull() - { - Assert.IsNotNull(projectContent.SystemTypes); - } - - [Test] - public void SystemObjectReturnTypeReturnedFromSystemTypesHasSystemObjectFullyQualifiedName() - { - string expectedName = "System.Object"; - IReturnType returnType = projectContent.SystemTypes.Object; - Assert.AreEqual(expectedName, returnType.FullyQualifiedName); - } - - [Test] - public void GetClassWithTypeParameterCountReturnsMockClassWithSpecifiedName() - { - string expectedName = "MyNamespace.MyTestClass"; - MockClass c = projectContent.GetClass(expectedName, 0) as MockClass; - Assert.AreEqual(expectedName, c.FullyQualifiedName); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkTestFixture.cs index 6265b901b9..9de0398f44 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkTestFixture.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.UnitTesting; using NUnit.Framework; using UnitTesting.Tests.Utils; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/TaskComparisonTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/TaskComparisonTestFixture.cs index 1628c14751..0a8edb8970 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/TaskComparisonTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/TaskComparisonTestFixture.cs @@ -13,8 +13,8 @@ namespace UnitTesting.Tests.Utils.Tests public class TaskComparisonTestFixture { TaskComparison taskComparison; - Task lhs; - Task rhs; + SDTask lhs; + SDTask rhs; int column = 20; int line = 5; string myTestFileName = @"c:\projects\tests\mytest.cs"; @@ -24,8 +24,8 @@ namespace UnitTesting.Tests.Utils.Tests public void Init() { FileName fileName = new FileName(myTestFileName); - lhs = new Task(fileName, description, column, line, TaskType.Error); - rhs = new Task(fileName, description, column, line, TaskType.Error); + lhs = new SDTask(fileName, description, column, line, TaskType.Error); + rhs = new SDTask(fileName, description, column, line, TaskType.Error); } [Test] diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj index c6faf5ad78..62e267adb5 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj @@ -83,9 +83,9 @@ - - - + + + @@ -108,12 +108,12 @@ - - - - - - + + + + + + @@ -191,7 +191,7 @@ - + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs index 9d5cc4a1df..5b47cd9bdc 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs @@ -248,5 +248,13 @@ namespace XmlEditor.Tests.Utils { throw new NotImplementedException(); } + + public event EventHandler FileNameChanged { add {} remove {} } + + public string FileName { + get { + throw new NotImplementedException(); + } + } } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Highlighting/HtmlClipboardTests.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Highlighting/HtmlClipboardTests.cs index 29d0473b12..e0c4566bc2 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Highlighting/HtmlClipboardTests.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Highlighting/HtmlClipboardTests.cs @@ -17,7 +17,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting public HtmlClipboardTests() { document = new TextDocument("using System.Text;\n\tstring text = SomeMethod();"); - highlighter = new DocumentHighlighter(document, HighlightingManager.Instance.GetDefinition("C#").MainRuleSet); + highlighter = new DocumentHighlighter(document, HighlightingManager.Instance.GetDefinition("C#")); } [Test]