Browse Source

Started porting UnitTesting.Tests to the new architecture.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
42ae86a467
  1. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/IRegisteredTestFrameworks.cs
  2. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/ITestFramework.cs
  3. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/ITestFrameworkFactory.cs
  4. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/ITestResultsMonitor.cs
  5. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/RegisteredTestFrameworks.cs
  6. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkDescriptor.cs
  7. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkDoozer.cs
  8. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkFactory.cs
  9. 0
      src/AddIns/Analysis/UnitTesting/Frameworks/TestService.cs
  10. 4
      src/AddIns/Analysis/UnitTesting/Model/TestClass.cs
  11. 28
      src/AddIns/Analysis/UnitTesting/Model/TestProject.cs
  12. 2
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitConsoleApplication.cs
  13. 17
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs
  14. 1
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs
  15. 1
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMemberTests.cs
  16. 1
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs
  17. 8
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs
  18. 5
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs
  19. 149
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs
  20. 6
      src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs
  21. 7
      src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs
  22. 7
      src/AddIns/Analysis/UnitTesting/Test/Project/DoubleNestedTestClassWithBaseType.cs
  23. 15
      src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs
  24. 35
      src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs
  25. 7
      src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs
  26. 1
      src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs
  27. 84
      src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs
  28. 1
      src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs
  29. 93
      src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassInTestFixtureTests.cs
  30. 67
      src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs
  31. 50
      src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs
  32. 43
      src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixture.cs
  33. 50
      src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs
  34. 61
      src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs
  35. 6
      src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs
  36. 70
      src/AddIns/Analysis/UnitTesting/Test/Project/ProjectTestFixtureBase.cs
  37. 107
      src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs
  38. 57
      src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs
  39. 39
      src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests.cs
  40. 84
      src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs
  41. 9
      src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs
  42. 14
      src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs
  43. 86
      src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs
  44. 20
      src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs
  45. 1
      src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs
  46. 1
      src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs
  47. 8
      src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs
  48. 2
      src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs
  49. 1
      src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs
  50. 2
      src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs
  51. 2
      src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs
  52. 9
      src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs
  53. 1
      src/AddIns/Analysis/UnitTesting/Test/Tree/OpenUnitTestsPadWithSolutionOpenTestFixture.cs
  54. 7
      src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs
  55. 3
      src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs
  56. 3
      src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs
  57. 3
      src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs
  58. 2
      src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs
  59. 3
      src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs
  60. 7
      src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs
  61. 6
      src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs
  62. 1
      src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs
  63. 114
      src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj
  64. 28
      src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestProjectTreeNode.cs
  65. 29
      src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs
  66. 38
      src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestingOptionsPanel.cs
  67. 150
      src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs
  68. 43
      src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs
  69. 35
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs
  70. 98
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockAmbience.cs
  71. 65
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockAttribute.cs
  72. 9
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs
  73. 166
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs
  74. 10
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs
  75. 24
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs
  76. 272
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockMember.cs
  77. 21
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockMemberNode.cs
  78. 30
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs
  79. 62
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs
  80. 14
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs
  81. 4
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs
  82. 94
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockParameter.cs
  83. 190
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs
  84. 1
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs
  85. 4
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs
  86. 4
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs
  87. 31
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs
  88. 2
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs
  89. 4
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs
  90. 9
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs
  91. 6
      src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs
  92. 3
      src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs
  93. 91
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs
  94. 49
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs
  95. 52
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs
  96. 67
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs
  97. 49
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs
  98. 40
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs
  99. 1
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs
  100. 7
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs
  101. Some files were not shown because too many files have changed in this diff Show More

0
src/AddIns/Analysis/UnitTesting/TestFramework/IRegisteredTestFrameworks.cs → src/AddIns/Analysis/UnitTesting/Frameworks/IRegisteredTestFrameworks.cs

0
src/AddIns/Analysis/UnitTesting/TestFramework/ITestFramework.cs → src/AddIns/Analysis/UnitTesting/Frameworks/ITestFramework.cs

0
src/AddIns/Analysis/UnitTesting/TestFramework/ITestFrameworkFactory.cs → src/AddIns/Analysis/UnitTesting/Frameworks/ITestFrameworkFactory.cs

0
src/AddIns/Analysis/UnitTesting/TestFramework/ITestResultsMonitor.cs → src/AddIns/Analysis/UnitTesting/Frameworks/ITestResultsMonitor.cs

0
src/AddIns/Analysis/UnitTesting/TestFramework/RegisteredTestFrameworks.cs → src/AddIns/Analysis/UnitTesting/Frameworks/RegisteredTestFrameworks.cs

0
src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkDescriptor.cs → src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkDescriptor.cs

0
src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkDoozer.cs → src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkDoozer.cs

0
src/AddIns/Analysis/UnitTesting/TestFramework/TestFrameworkFactory.cs → src/AddIns/Analysis/UnitTesting/Frameworks/TestFrameworkFactory.cs

0
src/AddIns/Analysis/UnitTesting/TestFramework/TestService.cs → src/AddIns/Analysis/UnitTesting/Frameworks/TestService.cs

4
src/AddIns/Analysis/UnitTesting/Model/TestClass.cs

@ -63,7 +63,7 @@ namespace ICSharpCode.UnitTesting @@ -63,7 +63,7 @@ namespace ICSharpCode.UnitTesting
/// <summary>
/// Gets the fully qualified name of the class.
/// </summary>
public string ReflectionName {
public string QualifiedName {
get { return parts[0].ReflectionName; }
}
@ -190,7 +190,7 @@ namespace ICSharpCode.UnitTesting @@ -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);
}
}
}

28
src/AddIns/Analysis/UnitTesting/Model/TestProject.cs

@ -122,14 +122,9 @@ namespace ICSharpCode.UnitTesting @@ -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 @@ -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;

2
src/AddIns/Analysis/UnitTesting/NUnit/NUnitConsoleApplication.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.UnitTesting @@ -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;
}

17
src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs

@ -28,8 +28,9 @@ namespace ICSharpCode.UnitTesting @@ -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);
/// <summary>
/// Determines whether the project is a test project. A project
@ -42,7 +43,7 @@ namespace ICSharpCode.UnitTesting @@ -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 @@ -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 @@ -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<TestMember> GetTestMembersFor(TestProject project, ITypeDefinition typeDefinition)

1
src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs

@ -1,7 +1,6 @@ @@ -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;

1
src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMemberTests.cs

@ -1,7 +1,6 @@ @@ -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;

1
src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.UnitTesting;
using NUnit.Framework;

8
src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs

@ -4,8 +4,6 @@ @@ -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; @@ -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 @@ -75,6 +73,6 @@ namespace UnitTesting.Tests.Frameworks
{
classWithTestAttribute.MockProjectContent.Project = null;
Assert.IsFalse(testableCondition.IsValid(classNodeForClassWithTestAttribute, null));
}
}*/
}
}

5
src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs

@ -10,9 +10,10 @@ using UnitTesting.Tests.Utils; @@ -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 @@ -58,6 +59,6 @@ namespace UnitTesting.Tests.Frameworks
MockMemberNode memberNode = new MockMemberNode(method);
testableCondition.IsValid(memberNode, null);
Assert.AreEqual(method, testFrameworks.IsTestMemberParameterUsed);
}
}*/
}
}

149
src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs

@ -1,149 +0,0 @@ @@ -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
{
/// <summary>
/// Tests the UnitTestingOptionsPanel.
/// </summary>
[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);
}
}
}

6
src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs

@ -1,7 +1,6 @@ @@ -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 @@ -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.
/// </summary>
[TestFixture]
[TestFixture, Ignore("Inherited test methods are not implemented")]
public class AbstractBaseClassWithTestMethodsTestFixture
{
/*
TestClass testClass;
MockClass c;
@ -103,6 +103,6 @@ namespace UnitTesting.Tests.Project @@ -103,6 +103,6 @@ namespace UnitTesting.Tests.Project
testClasses.UpdateTestResult(testResult);
Assert.AreEqual(TestResultType.Failure, testClass.Result);
}
}*/
}
}

7
src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs

@ -2,7 +2,7 @@ @@ -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 @@ -13,9 +13,10 @@ namespace UnitTesting.Tests.Project
/// Tests that the BaseTestMethod populates the various
/// properties of the DefaultMethod class in its constructor.
/// </summary>
[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 @@ -82,6 +83,6 @@ namespace UnitTesting.Tests.Project
public void ReturnType()
{
Assert.AreSame(returnType, baseTestMethod.ReturnType);
}
}*/
}
}

7
src/AddIns/Analysis/UnitTesting/Test/Project/DoubleNestedTestClassWithBaseType.cs

@ -38,9 +38,10 @@ namespace UnitTesting.Tests.Project @@ -38,9 +38,10 @@ namespace UnitTesting.Tests.Project
/// }
/// }
/// </summary>
[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 @@ -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);
}
}*/
}
}

15
src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -19,17 +18,13 @@ namespace UnitTesting.Tests.Project
/// test tree.
/// </summary>
[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 @@ -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 @@ -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)

35
src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -17,43 +16,21 @@ namespace UnitTesting.Tests.Project
/// fully qualified name.
/// </summary>
[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"));
}
/// <summary>
/// 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.
/// </summary>

7
src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -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);
}
}
}

1
src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs

@ -1,7 +1,6 @@ @@ -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;

84
src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs

@ -1,7 +1,7 @@ @@ -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 @@ -14,105 +14,61 @@ namespace UnitTesting.Tests.Project
/// Creates a TestProject object with no test classes.
/// </summary>
[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);
}
/// <summary>
/// Tests that a new class is added to the TestProject
/// from the parse info when the old compilation unit is null.
/// </summary>
[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"));
}
/// <summary>
/// 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.
/// </summary>
[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.");
}
/// <summary>
/// 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.
/// </summary>
[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.");
}
}
}

1
src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs

@ -1,7 +1,6 @@ @@ -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;

93
src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassInTestFixtureTests.cs

@ -2,7 +2,6 @@ @@ -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; @@ -11,51 +10,44 @@ using System.Linq;
namespace UnitTesting.Tests.Project
{
/// <summary>
/// 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
/// </summary>
[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 @@ -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);
}
}
}

67
src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -14,62 +13,62 @@ namespace UnitTesting.Tests.Project
/// Tests what happens when a test method is renamed inside an inner class.
/// </summary>
[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");
}
}
}

50
src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs

@ -2,7 +2,7 @@ @@ -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 @@ -14,13 +14,40 @@ namespace UnitTesting.Tests.Project
/// Tests that the TestProject is correctly updated after the inner class name changes.
/// </summary>
[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 @@ -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);
}
}
}

43
src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixture.cs

@ -2,7 +2,6 @@ @@ -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 @@ -28,12 +27,30 @@ namespace UnitTesting.Tests.Project
/// In this case the FooBar test is identified via: "A+InnerATest.FooBar".
/// </summary>
[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 @@ -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);
}
}
}

50
src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs

@ -2,7 +2,7 @@ @@ -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 @@ -13,40 +13,46 @@ namespace UnitTesting.Tests.Project
/// Tests that the inner test class is removed when its TestFixture attribute is removed.
/// </summary>
[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);
}
}
}

61
src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs

@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests.Project
{
/// <summary>
/// Base class for testing inner classes with TestFixture information.
/// </summary>
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];
}
}
}
}

6
src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs

@ -2,16 +2,16 @@ @@ -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 @@ -72,6 +72,6 @@ namespace UnitTesting.Tests.Project
public void DerivedClassTestMethodExists()
{
Assert.IsTrue(testClass.TestMembers.Contains("VirtualTestMethod"));
}
}*/
}
}

70
src/AddIns/Analysis/UnitTesting/Test/Project/ProjectTestFixtureBase.cs

@ -0,0 +1,70 @@ @@ -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
{
/// <summary>
/// Base class that helps setting up a unit test project.
/// </summary>
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<IParserService>();
parserService.Expect(p => p.GetCompilation(project)).WhenCalled(m => m.ReturnValue = projectContent.CreateCompilation());
project = MockRepository.GenerateStrictMock<IProject>();
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);
}
}
}

107
src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs

@ -1,107 +0,0 @@ @@ -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<IClass> classes = new List<IClass>();
classes.Add(myClass);
classes.Add(anotherClass);
removedClasses = new RemovedClasses();
removedClasses.Add(classes);
}
[Test]
public void InnerClassesIncludedInMissingClasses()
{
List<IClass> expectedClasses = new List<IClass>();
expectedClasses.Add(myClass);
expectedClasses.Add(innerClass);
expectedClasses.Add(anotherClass);
AssertContains(expectedClasses, removedClasses.GetMissingClasses());
}
/// <summary>
/// Should remove inner class too.
/// </summary>
[Test]
public void RemoveMyClass()
{
removedClasses.Remove(myClass);
List<IClass> expectedClasses = new List<IClass>();
expectedClasses.Add(anotherClass);
AssertContains(expectedClasses, removedClasses.GetMissingClasses());
}
[Test]
public void RemoveInnerClass()
{
removedClasses.Remove(innerClass);
List<IClass> expectedClasses = new List<IClass>();
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<IClass> classes = new List<IClass>();
classes.Add(c);
RemovedClasses removedClasses = new RemovedClasses();
removedClasses.Add(classes);
removedClasses.Remove(c);
Assert.AreEqual(0, removedClasses.GetMissingClasses().Count);
}
void AssertContains(IList<IClass> expectedClasses, IList<IClass> 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<IClass> classes)
{
StringBuilder names = new StringBuilder();
foreach (IClass c in classes) {
names.AppendLine(c.FullyQualifiedName);
}
return names.ToString();
}
}
}

57
src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs

@ -1,57 +0,0 @@ @@ -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);
}
}
}

39
src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests.cs

@ -2,7 +2,7 @@ @@ -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; @@ -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);
}
}
}

84
src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs

@ -3,8 +3,9 @@ @@ -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; @@ -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 @@ -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 @@ -172,39 +154,23 @@ namespace UnitTesting.Tests.Project
/// <summary>
/// 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.
/// </summary>
[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<TestMember> methodsRemoved = new List<TestMember>();
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;

9
src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -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 @@ -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]

14
src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs

@ -1,7 +1,6 @@ @@ -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 @@ -30,9 +29,10 @@ namespace UnitTesting.Tests.Project
///
/// RootNamespace.DerivedClass.BaseClassMethod
/// </summary>
[TestFixture]
[TestFixture, Ignore("Inherited tests not implemented")]
public class TestMethodsInBaseClassTestFixture
{
/*
TestClass testClass;
MockClass c;
MockTestFrameworksWithNUnitFrameworkSupport testFrameworks;
@ -68,19 +68,19 @@ namespace UnitTesting.Tests.Project @@ -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"));
}
/// <summary>
@ -92,7 +92,7 @@ namespace UnitTesting.Tests.Project @@ -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 @@ -120,6 +120,6 @@ namespace UnitTesting.Tests.Project
testClasses.UpdateTestResult(testResult);
Assert.AreEqual(TestResultType.Failure, testClass.Result);
}
}*/
}
}

86
src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs

@ -1,86 +0,0 @@ @@ -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);
}
}
}

20
src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs

@ -3,7 +3,8 @@ @@ -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 @@ -21,7 +22,6 @@ namespace UnitTesting.Tests.Project
TestClass testClass;
MSBuildBasedProject project;
bool resultChangedCalled;
MockProjectContent projectContent;
List<TestClass> classesAdded;
List<TestClass> classesRemoved;
MockTestFrameworksWithNUnitFrameworkSupport testFrameworks;
@ -275,13 +275,13 @@ namespace UnitTesting.Tests.Project @@ -275,13 +275,13 @@ namespace UnitTesting.Tests.Project
// Monitor test methods added.
List<TestMember> methodsAdded = new List<TestMember>();
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 @@ -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<TestClass>());
else if (e.Action == NotifyCollectionChangedAction.Remove)
classesRemoved.AddRange(e.OldItems.Cast<TestClass>());
}
}
}

1
src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs

@ -17,7 +17,6 @@ namespace UnitTesting.Tests.Project @@ -17,7 +17,6 @@ namespace UnitTesting.Tests.Project
TestClass testClass1;
TestClass testClass2;
TestClass testClass3;
TestClassCollection testClasses;
bool testClassesResultChanged;
MockTestFrameworksWithNUnitFrameworkSupport testFrameworks;

1
src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs

@ -17,7 +17,6 @@ namespace UnitTesting.Tests.Project @@ -17,7 +17,6 @@ namespace UnitTesting.Tests.Project
TestMember testMethod1;
TestMember testMethod2;
TestMember testMethod3;
TestMemberCollection testMethods;
bool testMethodsResultChanged;
[SetUp]

8
src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs

@ -1,7 +1,6 @@ @@ -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 @@ -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 @@ -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"));
}
/// <summary>
@ -77,7 +75,7 @@ namespace UnitTesting.Tests.Project @@ -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);
}

2
src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs

@ -1,7 +1,6 @@ @@ -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 @@ -14,7 +13,6 @@ namespace UnitTesting.Tests.Project
public class TwoRootNamespacesTestFixture
{
TestProject testProject;
MockProjectContent projectContent;
MockTestFrameworksWithNUnitFrameworkSupport testFrameworks;
[SetUp]

1
src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs

@ -18,7 +18,6 @@ namespace UnitTesting.Tests.Tree @@ -18,7 +18,6 @@ namespace UnitTesting.Tests.Tree
SelectedTests selectedTests;
List<IProject> projects;
MockCSharpProject project;
MockClass c;
[SetUp]
public void Init()

2
src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs

@ -195,7 +195,7 @@ namespace UnitTesting.Tests.Tree @@ -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);
}

2
src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs

@ -2,7 +2,6 @@ @@ -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 @@ -15,7 +14,6 @@ namespace UnitTesting.Tests.Tree
MockTestTreeView treeView;
GotoDefinitionCommand gotoDefinitionCommand;
MockFileService fileService;
MockMethod baseClassMethod;
[SetUp]
public void Init()

9
src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs

@ -5,7 +5,6 @@ using System; @@ -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 @@ -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 @@ -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 @@ -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.");

1
src/AddIns/Analysis/UnitTesting/Test/Tree/OpenUnitTestsPadWithSolutionOpenTestFixture.cs

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
using System;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using NUnit.Framework;

7
src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs

@ -4,7 +4,6 @@ @@ -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 @@ -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);

3
src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -12,7 +11,7 @@ namespace UnitTesting.Tests.Tree
[TestFixture]
public class TestResultFailureTaskTestFixture
{
Task task;
SDTask task;
[SetUp]
public void Init()

3
src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -13,7 +12,7 @@ namespace UnitTesting.Tests.Tree
[TestFixture]
public class TestResultFailureTaskWithNoMessageTestFixture
{
Task task;
SDTask task;
[TestFixtureSetUp]
public void SetUpFixture()

3
src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -13,7 +12,7 @@ namespace UnitTesting.Tests.Tree
[TestFixture]
public class TestResultIgnoreTaskTestFixture
{
Task task;
SDTask task;
[SetUp]
public void Init()

2
src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs

@ -13,7 +13,7 @@ namespace UnitTesting.Tests.Tree @@ -13,7 +13,7 @@ namespace UnitTesting.Tests.Tree
[TestFixture]
public class TestResultIgnoreTaskWithNoMessageTestFixture
{
Task task;
SDTask task;
[TestFixtureSetUp]
public void SetUpFixture()

3
src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs

@ -3,7 +3,6 @@ @@ -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 @@ -13,7 +12,7 @@ namespace UnitTesting.Tests.Tree
[TestFixture]
public class TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture
{
Task task;
SDTask task;
[SetUp]
public void Init()

7
src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs

@ -2,8 +2,6 @@ @@ -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; @@ -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 @@ -177,6 +176,6 @@ namespace UnitTesting.Tests.Tree
ClassNode classNode = new ClassNode(null, mockClass);
Assert.IsNull(TestableCondition.GetProject(classNode));
}
}*/
}
}

6
src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs

@ -5,7 +5,6 @@ using System; @@ -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 @@ -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.
/// </summary>
[TestFixture]
[TestFixture, Ignore("Tree tests")]
public class TreeNodeSortingTestFixture
{
/*
DummyParserServiceTestTreeView treeView;
TestProjectTreeNode projectNode;
TestNamespaceTreeNode myTestsNamespaceNode;
@ -245,6 +245,6 @@ namespace UnitTesting.Tests.Tree @@ -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);
}
}*/
}
}

1
src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs

@ -5,7 +5,6 @@ using System; @@ -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;

114
src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj

@ -16,7 +16,8 @@ @@ -16,7 +16,8 @@
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
@ -54,6 +55,9 @@ @@ -54,6 +55,9 @@
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Rhino.Mocks">
<HintPath>..\..\..\..\Libraries\RhinoMocks\Rhino.Mocks.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@ -77,7 +81,6 @@ @@ -77,7 +81,6 @@
<Compile Include="Frameworks\TestFrameworkDoozerTests.cs" />
<Compile Include="Frameworks\TestResultsReaderTests.cs" />
<Compile Include="Frameworks\NUnitConsoleCommandLineTests.cs" />
<Compile Include="Frameworks\UnitTestingOptionsPanelTestFixture.cs" />
<Compile Include="Frameworks\UnitTestingOptionsTestFixture.cs" />
<Compile Include="Project\AbstractBaseClassWithTestMethodsTestFixture.cs" />
<Compile Include="Project\BaseTestMethodTestFixture.cs" />
@ -88,70 +91,13 @@ @@ -88,70 +91,13 @@
<Compile Include="Project\InnerClassNameChangesTestFixture.cs" />
<Compile Include="Project\InnerClassTestFixture.cs" />
<Compile Include="Project\InnerClassTestFixtureAttributeRemovedTestFixture.cs" />
<Compile Include="Project\InnerClassTestFixtureBase.cs" />
<Compile Include="Project\OverriddenBaseTestMethodTestFixture.cs" />
<Compile Include="Project\RemovedClassesTestFixture.cs" />
<Compile Include="Project\TestClassIsTestMethodUsesTestFrameworksTestFixture.cs" />
<Compile Include="Project\ProjectTestFixtureBase.cs" />
<Compile Include="Project\TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests.cs" />
<Compile Include="Project\TestProjectUsesTestFrameworksTestFixture.cs" />
<Compile Include="Project\TwoBaseClassesWithTestMethodsTestFixture.cs" />
<Compile Include="Tree\AbstractRunTestCommandTests.cs" />
<Compile Include="Tree\AddNUnitReferenceToProjectTestFixture.cs" />
<Compile Include="Tree\BuildErrorWhenRunningTestsTestFixture.cs" />
<Compile Include="Tree\ClassTestFixtureSelectedTestFixture.cs" />
<Compile Include="Tree\EmptyUnitTestsPadTests.cs" />
<Compile Include="Tree\GoToSelectedBaseClassMethodTestFixture.cs" />
<Compile Include="Tree\GoToSelectedClassTestFixture.cs" />
<Compile Include="Tree\GoToSelectedClassWithNoLocationTestFixture.cs" />
<Compile Include="Tree\GoToSelectedMethodTestFixture.cs" />
<Compile Include="Tree\GoToSelectedMethodWithNoLocationTestFixture.cs" />
<Compile Include="Tree\MethodTestSelectedTestFixture.cs" />
<Compile Include="Tree\MultipleTestProjectsTestFixture.cs" />
<Compile Include="Tree\NonTestProjectNotAddedToTestTreeTestFixture.cs" />
<Compile Include="Tree\NoOwnerForSelectedTestsTestFixture.cs" />
<Compile Include="Tree\NoTestsRunWhenNoTestsSelectedTestFixture.cs" />
<Compile Include="Tree\RemoveSolutionFolderTestFixture.cs" />
<Compile Include="Tree\RunAllTestsInPadTestFixture.cs" />
<Compile Include="Tree\RunNUnitTestsForMethodTestFixture.cs" />
<Compile Include="Tree\RunNUnitTestsWithDebuggerTestFixture.cs" />
<Compile Include="Tree\RunProjectTestsInPadTestFixture.cs" />
<Compile Include="Tree\RunProjectTestsTestFixture.cs" />
<Compile Include="Tree\RunTestCommandBeforeRunTestFixture.cs" />
<Compile Include="Tree\RunTestCommandTestFixtureBase.cs" />
<Compile Include="Tree\RunTestInPadCommandTestFixture.cs" />
<Compile Include="Tree\RunTestsForClassTestFixture.cs" />
<Compile Include="Tree\RunTestsForMethodTestFixture.cs" />
<Compile Include="Tree\RunTestsForNamespaceTestFixture.cs" />
<Compile Include="Tree\RunTestsWithoutBuildingProjectTestFixture.cs" />
<Compile Include="Tree\RunTestsWithoutUnitTestsPadTestFixture.cs" />
<Compile Include="Tree\RunTestWhenDebuggerRunningTestFixture.cs" />
<Compile Include="Tree\RunTestWithDebuggerCommandTestFixture.cs" />
<Compile Include="Tree\RunTestWithDebuggerCommandTestFixtureBase.cs" />
<Compile Include="Tree\RunTwoProjectsTestsTestFixture.cs" />
<Compile Include="Tree\SelectedTestsTestFixture.cs" />
<Compile Include="Tree\SolutionLoadedAfterUnitTestsTreeDisposedTestFixture.cs" />
<Compile Include="Tree\StartingDebuggerThrowsExceptionWhenStartingTestsTestFixture.cs" />
<Compile Include="Tree\StopRunningTestsTestFixture.cs" />
<Compile Include="Tree\TestableConditionTests.cs" />
<Compile Include="Tree\TestResultFailureTaskTestFixture.cs" />
<Compile Include="Tree\TestResultFailureTaskWithNoMessageTestFixture.cs" />
<Compile Include="Tree\TestResultIgnoreTaskTestFixture.cs" />
<Compile Include="Tree\TestResultIgnoreTaskWithNoMessageTestFixture.cs" />
<Compile Include="Tree\TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs" />
<Compile Include="Tree\TreeNodeContextMenuTestFixture.cs" />
<Compile Include="Tree\TreeNodeSortingTestFixture.cs" />
<Compile Include="Tree\OpenUnitTestsPadWithSolutionOpenTestFixture.cs" />
<Compile Include="Utils\DerivedRunTestCommand.cs" />
<Compile Include="Utils\DerivedRunTestInPadCommand.cs" />
<Compile Include="Utils\DerivedRunTestWithDebuggerCommand.cs" />
<Compile Include="Utils\DerivedTestProjectTreeNode.cs" />
<Compile Include="Utils\DerivedTestTreeView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Utils\DerivedUnitTestingOptionsPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Utils\DerivedUnitTestsPad.cs" />
<Compile Include="Utils\JumpedToFile.cs" />
<Compile Include="Utils\MockAddInTree.cs" />
<Compile Include="Utils\MockBuildOptions.cs" />
@ -160,7 +106,6 @@ @@ -160,7 +106,6 @@
<Compile Include="Utils\MockDebugger.cs" />
<Compile Include="Utils\MockDebuggerService.cs" />
<Compile Include="Utils\MockFileService.cs" />
<Compile Include="Utils\MockMessageService.cs" />
<Compile Include="Utils\MockNUnitTestFramework.cs" />
<Compile Include="Utils\MockNUnitTestRunnerContext.cs" />
<Compile Include="Utils\MockProcessRunner.cs" />
@ -176,22 +121,11 @@ @@ -176,22 +121,11 @@
<Compile Include="Utils\MockTestResultsMonitor.cs" />
<Compile Include="Utils\MockTestRunner.cs" />
<Compile Include="Utils\MockTestTreeView.cs" />
<Compile Include="Utils\MockMember.cs" />
<Compile Include="Utils\MockClass.cs" />
<Compile Include="Utils\MockMethod.cs" />
<Compile Include="Utils\MockMemberNode.cs" />
<Compile Include="Utils\MockAmbience.cs" />
<Compile Include="Utils\MockUnitTestsPad.cs" />
<Compile Include="Utils\MockUnitTestWorkbench.cs" />
<Compile Include="Utils\SelectedTestsHelper.cs" />
<Compile Include="Utils\TaskComparison.cs" />
<Compile Include="Utils\TestProjectHelper.cs" />
<Compile Include="Utils\Tests\CreateMockClassWithAttributesTestFixture.cs" />
<Compile Include="Utils\Tests\CreateMockClassWithoutAnyAttributesTestFixture.cs" />
<Compile Include="Utils\Tests\CreateMockClassWithSingleAttributeTestFixture.cs" />
<Compile Include="Utils\Tests\CreateMockMethodWithAttributesTestFixture.cs" />
<Compile Include="Utils\Tests\CreateMockMethodWithoutAnyAttributesTestFixture.cs" />
<Compile Include="Utils\Tests\CreateMockMethodWithSingleAttributeTestFixture.cs" />
<Compile Include="Utils\Tests\CreateProjectWithOutputPathTestFixture.cs" />
<Compile Include="Utils\Tests\CreateTestProjectWithOneTestMethodTestFixture.cs" />
<Compile Include="Utils\Tests\CreateTestProjectWithTwoTestMethodsTestFixture.cs" />
@ -199,15 +133,11 @@ @@ -199,15 +133,11 @@
<Compile Include="Utils\Tests\MockAddInTreeTestFixture.cs" />
<Compile Include="Utils\Tests\MockBuildOptionsTestFixture.cs" />
<Compile Include="Utils\Tests\MockBuildProjectBeforeTestRunTestFixture.cs" />
<Compile Include="Utils\Tests\MockClassTests.cs" />
<Compile Include="Utils\Tests\MockDebuggerServiceTestFixture.cs" />
<Compile Include="Utils\Tests\MockFileServiceTestFixture.cs" />
<Compile Include="Utils\Tests\MockMessageServiceTestFixture.cs" />
<Compile Include="Utils\Tests\MockMethodTestFixture.cs" />
<Compile Include="Utils\Tests\MockNUnitTestFrameworkTestFixture.cs" />
<Compile Include="Utils\Tests\MockNUnitTestRunnerContextTestFixture.cs" />
<Compile Include="Utils\Tests\MockProcessRunnerTestFixture.cs" />
<Compile Include="Utils\Tests\MockProjectContentTestFixture.cs" />
<Compile Include="Utils\Tests\MockProjectSaveTestFixture.cs" />
<Compile Include="Utils\Tests\MockRegisteredTestFrameworksTestFixture.cs" />
<Compile Include="Utils\Tests\MockRunTestCommandContextTestFixture.cs" />
@ -227,29 +157,18 @@ @@ -227,29 +157,18 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="Utils\ResourceManager.cs" />
<Compile Include="Utils\MockProjectContent.cs" />
<Compile Include="Utils\MockAttribute.cs" />
<Compile Include="Tree\OneTestClassTestFixture.cs" />
<Compile Include="Utils\DummyParserServiceTestTreeView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Project\TestProjectWithOneClassTestFixture.cs" />
<Compile Include="Project\ClassRootNamespaceTests.cs" />
<Compile Include="Project\TwoProjectRootNamespacesTestFixture.cs" />
<Compile Include="Project\DuplicateProjectRootNamespaceTestFixture.cs" />
<Compile Include="Project\EmptyRootNamespaceTestFixture.cs" />
<Compile Include="Project\ClassWithTwoChildNamespacesTestFixture.cs" />
<Compile Include="Tree\ClassWithNoRootNamespaceTestFixture.cs" />
<Compile Include="Project\TestClassWithOneMethodTestFixture.cs" />
<Compile Include="Tree\SolutionOpenedTestFixture.cs" />
<Compile Include="Tree\GetProjectsTestFixture.cs" />
<Compile Include="Project\TestMemberGetMethodNameTests.cs" />
<Compile Include="Project\GetQualifiedClassNameTests.cs" />
<Compile Include="Project\TestClassWithTwoMethodsTestFixture.cs" />
<Compile Include="Project\ThreeTestMethodsTestResultsTestFixture.cs" />
<Compile Include="Project\ThreeTestClassesTestResultsTestFixture.cs" />
<Compile Include="Utils\MockParameter.cs" />
<Compile Include="Tree\TwoTestClassesInDifferentNamespacesTestFixture.cs" />
<Compile Include="Project\EmptyProjectTestFixture.cs" />
<Compile Include="Project\TestMethodsInBaseClassTestFixture.cs" />
<Compile Include="Project\DuplicateClassNameTestFixture.cs" />
@ -257,6 +176,19 @@ @@ -257,6 +176,19 @@
<Compile Include="Utils\MockCSharpProject.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
<Name>ICSharpCode.NRefactory.CSharp</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj">
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project>
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\UnitTesting.csproj">
<Project>{1F261725-6318-4434-A1B1-6C70CE4CD324}</Project>
<Name>UnitTesting</Name>
@ -269,14 +201,6 @@ @@ -269,14 +201,6 @@
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

28
src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestProjectTreeNode.cs

@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.UnitTesting;
namespace UnitTesting.Tests.Utils
{
/// <summary>
/// Derived version of the TestProjectTreeNode class that
/// allows us to call the UpdateImageListIndex method directly.
/// </summary>
public class DerivedTestProjectTreeNode : TestProjectTreeNode
{
public DerivedTestProjectTreeNode(TestProject testProject)
: base(testProject)
{
}
/// <summary>
/// Calls the base class's UpdateImageListIndex method.
/// </summary>
public void CallUpdateImageListIndex(TestResultType result)
{
base.UpdateImageListIndex(result);
}
}
}

29
src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs

@ -1,29 +0,0 @@ @@ -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
{
/// <summary>
/// Derives from the TestTreeView class and allows us to directly
/// call the OnBeforeSelect method.
/// </summary>
public class DerivedTestTreeView : TestTreeView
{
public DerivedTestTreeView()
: base(new MockTestFrameworksWithNUnitFrameworkSupport())
{
}
/// <summary>
/// Calls the base class's OnBeforeSelect method.
/// </summary>
public void CallOnBeforeSelect(TreeViewCancelEventArgs e)
{
base.OnBeforeSelect(e);
}
}
}

38
src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestingOptionsPanel.cs

@ -1,38 +0,0 @@ @@ -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
{
/// <summary>
/// Utility class used to test the UnitTestingOptionsPanel class.
/// </summary>
public class DerivedUnitTestingOptionsPanel : UnitTestingOptionsPanel
{
string setupFromManifestResourceName = String.Empty;
public DerivedUnitTestingOptionsPanel(UnitTestingOptions options) : base(options)
{
}
/// <summary>
/// Returns the resource name used to create the stream when
/// initialising the XmlUserControl.
/// </summary>
public string SetupFromManifestResourceName {
get { return setupFromManifestResourceName; }
}
/// <summary>
/// Called in CompilingOptionsPanel.LoadPanelContents when
/// initialising the XmlUserControl.
/// </summary>
protected override void SetupFromManifestResource(string resource)
{
setupFromManifestResourceName = resource;
base.SetupFromManifestResource(resource);
}
}
}

150
src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs

@ -1,150 +0,0 @@ @@ -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
{
/// <summary>
/// Class that derives from UnitTestsPad so we can access protected
/// methods and test it.
/// </summary>
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)
{
}
/// <summary>
/// Gets the project content to be used when creating the
/// derived test tree view.
/// </summary>
public MockProjectContent ProjectContent {
get { return projectContent; }
set {
projectContent = value;
treeView.ProjectContentForProject = projectContent;
}
}
public bool GetOpenSolutionCalled {
get { return getOpenSolutionCalled; }
}
public bool IsParserLoadingSolutionCalled {
get { return isParserLoadingSolutionCalled; }
}
/// <summary>
/// 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.
/// </summary>
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);
}
/// <summary>
/// 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.
/// </summary>
protected override ToolStrip CreateToolStrip(string name)
{
return new ToolStrip();
}
/// <summary>
/// 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.
/// </summary>
protected override ContextMenuStrip CreateContextMenu(string name)
{
return new ContextMenuStrip();
}
/// <summary>
/// Returns a dummy tree view where we can mock the
/// IProjectContent that will be used by the TestTreeView.
/// </summary>
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;
}
}
}

43
src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using System;
namespace UnitTesting.Tests.Utils
{
/// <summary>
/// Provides a way to return dummy data for IProjectContents
/// without having to use the ParserService.
/// </summary>
public class DummyParserServiceTestTreeView : TestTreeView
{
IProjectContent projectContent;
public DummyParserServiceTestTreeView(IRegisteredTestFrameworks testFrameworks)
: base(testFrameworks)
{
}
public DummyParserServiceTestTreeView()
: this(new MockTestFrameworksWithNUnitFrameworkSupport())
{
}
/// <summary>
/// Gets or sets the project content that will be returned from the
/// GetProjectContent method.
/// </summary>
public IProjectContent ProjectContentForProject {
get { return projectContent; }
set { projectContent = value; }
}
public override IProjectContent GetProjectContent(IProject project)
{
return projectContent;
}
}
}

35
src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs

@ -16,7 +16,7 @@ namespace UnitTesting.Tests.Utils @@ -16,7 +16,7 @@ namespace UnitTesting.Tests.Utils
{
}
public List<T> BuildItems<T>(string path, object caller)
public IReadOnlyList<T> BuildItems<T>(string path, object caller, bool throwOnNotFound)
{
object obj;
if (treeItems.TryGetValue(path, out obj)) {
@ -29,5 +29,38 @@ namespace UnitTesting.Tests.Utils @@ -29,5 +29,38 @@ namespace UnitTesting.Tests.Utils
{
treeItems.Add(path, items);
}
public IReadOnlyList<AddIn> AddIns {
get {
throw new NotImplementedException();
}
}
public System.Collections.Concurrent.ConcurrentDictionary<string, IDoozer> Doozers {
get {
throw new NotImplementedException();
}
}
public System.Collections.Concurrent.ConcurrentDictionary<string, IConditionEvaluator> ConditionEvaluators {
get {
throw new NotImplementedException();
}
}
public object BuildItem(string path, object caller)
{
throw new NotImplementedException();
}
public object BuildItem(string path, object caller, IEnumerable<ICondition> additionalConditions)
{
throw new NotImplementedException();
}
public AddInTreeNode GetTreeNode(string path, bool throwOnNotFound)
{
throw new NotImplementedException();
}
}
}

98
src/AddIns/Analysis/UnitTesting/Test/Utils/MockAmbience.cs

@ -1,98 +0,0 @@ @@ -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;
}
}
}

65
src/AddIns/Analysis/UnitTesting/Test/Utils/MockAttribute.cs

@ -1,65 +0,0 @@ @@ -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<object> PositionalArguments {
get {
throw new NotImplementedException();
}
}
public System.Collections.Generic.IDictionary<string, object> NamedArguments {
get {
throw new NotImplementedException();
}
}
public bool IsFrozen {
get {
throw new NotImplementedException();
}
}
public void Freeze()
{
throw new NotImplementedException();
}
}
}

9
src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs

@ -2,7 +2,6 @@ @@ -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 @@ -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; }
}

166
src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs

@ -1,166 +0,0 @@ @@ -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<MockAttribute> attributes)
{
MockClass mockClass = new MockClass();
mockClass.MockProjectContent.Project = new MockCSharpProject();
mockClass.MockProjectContent.Classes.Add(mockClass);
foreach (MockAttribute attribute in attributes) {
mockClass.Attributes.Add(attribute);
}
return mockClass;
}
public static MockClass CreateMockClassWithAttribute(MockAttribute attribute)
{
List<MockAttribute> attributes = new List<MockAttribute>();
attributes.Add(attribute);
return CreateMockClassWithAttributes(attributes);
}
public static MockClass CreateClassWithBaseType(string baseTypeName)
{
MockClass baseType = MockClass.CreateMockClassWithoutAnyAttributes();
baseType.FullyQualifiedName = baseTypeName;
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
c.BaseTypes.Add(new DefaultReturnType(baseType));
return c;
}
public void SetCompoundClass(IClass c)
{
this.compoundClass = c;
}
protected override IReturnType CreateDefaultReturnType()
{
if (compoundClass != null) {
return new DefaultReturnType(compoundClass);
}
return base.CreateDefaultReturnType();
}
public void AddBaseClass(IClass baseClass)
{
DefaultReturnType returnType = new DefaultReturnType(baseClass);
BaseTypes.Add(returnType);
}
public DefaultProperty AddProperty(string name)
{
DefaultProperty property = new DefaultProperty(this, name);
Properties.Add(property);
return property;
}
public void InsertPropertyAtStart(string name)
{
DefaultProperty property = new DefaultProperty(this, name);
Properties.Insert(0, property);
}
public DefaultEvent AddEvent(string name)
{
DefaultEvent classEvent = new DefaultEvent(this, name);
Events.Add(classEvent);
return classEvent;
}
public DefaultField AddField(string name)
{
DefaultField field = new DefaultField(this, name);
Fields.Add(field);
return field;
}
public DefaultMethod AddMethod(string name)
{
DefaultMethod method = new DefaultMethod(this, name);
Methods.Add(method);
return method;
}
}
}

10
src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs

@ -149,11 +149,6 @@ namespace UnitTesting.Tests.Utils @@ -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 @@ -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();
}
}
}

24
src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs

@ -2,37 +2,15 @@ @@ -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;

272
src/AddIns/Analysis/UnitTesting/Test/Utils/MockMember.cs

@ -1,272 +0,0 @@ @@ -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<IAttribute> 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<ExplicitInterfaceImplementation> 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();
}
}
}
}

21
src/AddIns/Analysis/UnitTesting/Test/Utils/MockMemberNode.cs

@ -1,21 +0,0 @@ @@ -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();
}
}
}

30
src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs

@ -1,30 +0,0 @@ @@ -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;
}
}
}

62
src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs

@ -1,62 +0,0 @@ @@ -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<MockAttribute> attributes)
{
MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes();
MockMethod mockMethod = new MockMethod(mockClass);
foreach (MockAttribute attribute in attributes) {
mockMethod.Attributes.Add(attribute);
}
return mockMethod;
}
public static MockMethod CreateMockMethodWithAttribute(MockAttribute attribute)
{
List<MockAttribute> attributes = new List<MockAttribute>();
attributes.Add(attribute);
return CreateMockMethodWithAttributes(attributes);
}
public MockClass MockDeclaringType {
get { return DeclaringType as MockClass; }
}
}
}

14
src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs

@ -4,7 +4,7 @@ @@ -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 @@ -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 @@ -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 @@ -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 @@ -54,11 +54,11 @@ namespace UnitTesting.Tests.Utils
throw new NotImplementedException();
}
public IEnumerable<TestMember> GetTestMembersFor(IClass @class) {
public IEnumerable<TestMember> GetTestMembersFor(TestProject project, ITypeDefinition @class) {
throw new NotImplementedException();
}
public bool IsTestClass(IClass c)
public bool IsTestClass(ITypeDefinition c)
{
throw new NotImplementedException();
}

4
src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs

@ -23,10 +23,6 @@ namespace UnitTesting.Tests.Utils @@ -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(),

94
src/AddIns/Analysis/UnitTesting/Test/Utils/MockParameter.cs

@ -1,94 +0,0 @@ @@ -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<IAttribute> 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()
{
}
}
}

190
src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs

@ -1,190 +0,0 @@ @@ -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<IClass> classes = new List<IClass>();
object project;
public MockProjectContent()
{
}
public event EventHandler ReferencedContentsChanged;
public XmlDoc XmlDoc {
get {
throw new NotImplementedException();
}
}
public ICollection<IClass> Classes {
get { return classes; }
}
public ICollection<string> NamespaceNames {
get {
throw new NotImplementedException();
}
}
public ICollection<IProjectContent> 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<ICompletionEntry> 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<ICompletionEntry> 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<IAttribute> GetAssemblyAttributes()
{
throw new NotImplementedException();
}
public bool InternalsVisibleTo(IProjectContent otherProjectContent)
{
throw new NotImplementedException();
}
public string AssemblyName {
get { return String.Empty; }
}
public void AddAllContents(List<ICompletionEntry> list, LanguageProperties language, bool lookInReferences)
{
throw new NotImplementedException();
}
public List<ICompletionEntry> GetAllContents()
{
throw new NotImplementedException();
}
}
}

1
src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;

4
src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs

@ -3,7 +3,6 @@ @@ -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 @@ -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 @@ -54,7 +52,7 @@ namespace UnitTesting.Tests.Utils
get { return MockUnitTestsPad; }
}
public IUnitTestMessageService MessageService {
public IMessageService MessageService {
get { return MockMessageService; }
}

4
src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs

@ -13,7 +13,7 @@ namespace UnitTesting.Tests.Utils @@ -13,7 +13,7 @@ namespace UnitTesting.Tests.Utils
{
public bool IsClearExceptCommentTasksMethodCalled;
public bool IsInUpdateWhilstClearExceptCommentTasksMethodCalled;
public List<Task> Tasks = new List<Task>();
public List<SDTask> Tasks = new List<SDTask>();
public bool HasCriticalErrorsReturnValue;
public bool TreatWarningsAsErrorsParameterPassedToHasCriticalErrors;
@ -41,7 +41,7 @@ namespace UnitTesting.Tests.Utils @@ -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;

31
src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs

@ -2,9 +2,10 @@ @@ -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 @@ -13,9 +14,9 @@ namespace UnitTesting.Tests.Utils
public class MockTestFramework : ITestFramework
{
IMember isTestMemberParameterUsed;
List<IMember> testMembers = new List<IMember>();
IClass isTestClassParameterUsed;
List<IClass> testClasses = new List<IClass>();
List<string> testMembers = new List<IMember>();
ITypeDefinition isTestClassParameterUsed;
List<string> testClasses = new List<ITypeDefinition>();
IProject isTestProjectParameterUsed;
List<IProject> testProjects = new List<IProject>();
List<MockTestRunner> testRunnersCreated = new List<MockTestRunner>();
@ -32,35 +33,35 @@ namespace UnitTesting.Tests.Utils @@ -32,35 +33,35 @@ namespace UnitTesting.Tests.Utils
return testMembers.Contains(member);
}
public IEnumerable<TestMember> GetTestMembersFor(IClass @class) {
return testMembers.Where(member => member.DeclaringType == @class).Select(member => new TestMember(member));
public IEnumerable<TestMember> 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);
}

2
src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs

@ -19,7 +19,7 @@ namespace UnitTesting.Tests.Utils @@ -19,7 +19,7 @@ namespace UnitTesting.Tests.Utils
{
}
public event TestFinishedEventHandler TestFinished;
public event EventHandler<TestFinishedEventArgs> TestFinished;
public long InitialFilePosition {
get { return filePosition; }

4
src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs

@ -14,9 +14,9 @@ namespace UnitTesting.Tests.Utils @@ -14,9 +14,9 @@ namespace UnitTesting.Tests.Utils
bool started = false;
SelectedTests selectedTests;
public event TestFinishedEventHandler TestFinished;
public event EventHandler<TestFinishedEventArgs> TestFinished;
public event EventHandler AllTestsFinished;
public event MessageReceivedEventHandler MessageReceived;
public event EventHandler<MessageReceivedEventArgs> MessageReceived;
public void Dispose()
{

9
src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs

@ -1,7 +1,6 @@ @@ -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 @@ -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; }
}

6
src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs

@ -10,12 +10,12 @@ namespace UnitTesting.Tests.Utils @@ -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;

3
src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs

@ -2,7 +2,6 @@ @@ -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 @@ -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";

91
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs

@ -1,91 +0,0 @@ @@ -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<MockAttribute> attributes = new List<MockAttribute>();
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);
}
}
}

49
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs

@ -1,49 +0,0 @@ @@ -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);
}
}
}

52
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs

@ -1,52 +0,0 @@ @@ -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));
}
}
}

67
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs

@ -1,67 +0,0 @@ @@ -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<MockAttribute> attributes = new List<MockAttribute>();
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);
}
}
}

49
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs

@ -1,49 +0,0 @@ @@ -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);
}
}
}

40
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs

@ -1,40 +0,0 @@ @@ -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);
}
}
}

1
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs

@ -2,7 +2,6 @@ @@ -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;

7
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs

@ -2,7 +2,6 @@ @@ -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 @@ -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 @@ -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]

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save