Browse Source

Add unit tests for IsTestClass and IsTestMethod; and fixed a bug where IsTestClass would incorrectly return false for static classes.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
b762264ac1
  1. 2
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs
  2. 1
      src/AddIns/Analysis/UnitTesting/Service/SDTestService.cs
  3. 94
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs
  4. 152
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMemberTests.cs
  5. 89
      src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDoozerTests.cs
  6. 121
      src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestFrameworkIsTestClassTests.cs
  7. 89
      src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestFrameworkIsTestMemberTests.cs
  8. 2
      src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestFrameworkIsTestProjectTests.cs
  9. 98
      src/AddIns/Analysis/UnitTesting/Test/NUnitConsoleExeSelectedTestFixture.cs
  10. 20
      src/AddIns/Analysis/UnitTesting/Test/Service/TestFrameworkDescriptorTests.cs
  11. 224
      src/AddIns/Analysis/UnitTesting/Test/UnitTestCommandLineTests.cs
  12. 5
      src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj
  13. 2
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs
  14. 17
      src/AddIns/Analysis/UnitTesting/Test/Utils/NRefactoryHelper.cs
  15. 8
      src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj
  16. 113
      src/Main/Base/Test/Utils/FakeMessageLoop.cs
  17. 84
      src/Main/Base/Test/Utils/MockAmbience.cs
  18. 367
      src/Main/Base/Test/Utils/MockClass.cs
  19. 160
      src/Main/Base/Test/Utils/MockDefaultReturnType.cs
  20. 34
      src/Main/Base/Test/Utils/MockEntity.cs
  21. 279
      src/Main/Base/Test/Utils/MockMethod.cs
  22. 26
      src/Main/Base/Test/Utils/MockProject.cs
  23. 297
      src/Main/Base/Test/Utils/MockProperty.cs

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

@ -55,7 +55,7 @@ namespace ICSharpCode.UnitTesting
return false; return false;
if (type.NestedTypes.Any(IsTestClass)) if (type.NestedTypes.Any(IsTestClass))
return true; return true;
if (type.IsAbstract) if (type.IsAbstract && !type.IsStatic)
return false; return false;
var testFixtureAttribute = testFixtureAttributeRef.Resolve(type.Compilation); var testFixtureAttribute = testFixtureAttributeRef.Resolve(type.Compilation);
if (type.Attributes.Any(attr => attr.AttributeType.Equals(testFixtureAttribute))) if (type.Attributes.Any(attr => attr.AttributeType.Equals(testFixtureAttribute)))

1
src/AddIns/Analysis/UnitTesting/Service/SDTestService.cs

@ -86,6 +86,7 @@ namespace ICSharpCode.UnitTesting
public void CancelRunningTests() public void CancelRunningTests()
{ {
SD.MainThread.VerifyAccess();
if (runTestsCancellationTokenSource != null) { if (runTestsCancellationTokenSource != null) {
runTestsCancellationTokenSource.Cancel(); runTestsCancellationTokenSource.Cancel();
runTestsCancellationTokenSource = null; runTestsCancellationTokenSource = null;

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

@ -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 ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests.Frameworks
{
[TestFixture]
public class NUnitTestFrameworkIsTestClassTests
{
NUnitTestFramework testFramework;
[SetUp]
public void Init()
{
testFramework = new NUnitTestFramework();
}
[Test]
public void IsTestClassReturnsFalseHasClassHasNoAttributes()
{
MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes();
Assert.IsFalse(testFramework.IsTestClass(mockClass));
}
[Test]
public void IsTestClassReturnsTrueHasClassHasTestFixtureAttributeMissingAttributePart()
{
MockAttribute testAttribute = new MockAttribute("TestFixture");
MockClass mockClass = MockClass.CreateMockClassWithAttribute(testAttribute);
Assert.IsTrue(testFramework.IsTestClass(mockClass));
}
[Test]
public void IsTestClassReturnsFalseWhenClassHasTestFixtureAttributeAndIsAbstract() {
MockAttribute testAttribute = new MockAttribute("TestFixture");
MockClass mockClass = MockClass.CreateMockClassWithAttribute(testAttribute);
mockClass.Modifiers = mockClass.Modifiers | ModifierEnum.Abstract;
Assert.IsFalse(testFramework.IsTestClass(mockClass));
}
[Test]
public void IsTestClassReturnsTrueHasClassHasTestFixtureAttribute()
{
MockAttribute testFixtureAttribute = new MockAttribute("TestFixtureAttribute");
MockClass mockClass = MockClass.CreateMockClassWithAttribute(testFixtureAttribute);
Assert.IsTrue(testFramework.IsTestClass(mockClass));
}
[Test]
public void IsTestClassReturnsTrueHasClassHasFullyQualifiedNUnitTestFixtureAttribute()
{
MockAttribute testFixtureAttribute = new MockAttribute("NUnit.Framework.TestFixtureAttribute");
MockClass mockClass = MockClass.CreateMockClassWithAttribute(testFixtureAttribute);
Assert.IsTrue(testFramework.IsTestClass(mockClass));
}
[Test]
public void IsTestClassReturnsFalseWhenClassIsNull()
{
Assert.IsFalse(testFramework.IsTestClass(null));
}
[Test]
public void IsTestClassReturnsFalseWhenProjectContentLanguageIsNull()
{
IProject project = new MockCSharpProject();
MockProjectContent mockProjectContent = new MockProjectContent();
mockProjectContent.Project = project;
MockClass mockClass = new MockClass(mockProjectContent);
Assert.IsFalse(testFramework.IsTestClass(mockClass));
}
[Test]
public void IsTestClassReturnsFalseWhenProjectContentLanguageNameComparerIsNull()
{
IProject project = new MockCSharpProject();
MockProjectContent mockProjectContent = new MockProjectContent();
mockProjectContent.Project = project;
mockProjectContent.Language = new LanguageProperties(null);
MockClass mockClass = new MockClass(mockProjectContent);
mockClass.Attributes.Add(new MockAttribute("Test"));
Assert.IsFalse(testFramework.IsTestClass(mockClass));
}
}
}

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

@ -1,152 +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 NUnit.Framework;
using System;
using System.Collections.Generic;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests.Frameworks
{
[TestFixture]
public class NUnitTestFrameworkIsTestMemberTests
{
NUnitTestFramework testFramework;
void CreateTestFramework()
{
testFramework = new NUnitTestFramework();
}
[Test]
public void IsTestMember_MethodHasNoAttributes_ReturnsFalse()
{
CreateTestFramework();
MockMethod mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes();
bool result = testFramework.IsTestMember(mockMethod);
Assert.IsFalse(result);
}
[Test]
public void IsTestMember_MethodHasTestAttributeWithoutAttributePart_ReturnsTrue()
{
CreateTestFramework();
MockAttribute testAttribute = new MockAttribute("Test");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
bool result = testFramework.IsTestMember(mockMethod);
Assert.IsTrue(result);
}
[Test]
public void IsTestMember_MethodHasTestAttributeAttribute_ReturnsTrue()
{
CreateTestFramework();
MockAttribute testAttribute = new MockAttribute("TestAttribute");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
bool result = testFramework.IsTestMember(mockMethod);
Assert.IsTrue(result);
}
[Test]
public void IsTestMember_MethodHasFullyQualifiedNUnitTestAttribute_ReturnsTrue()
{
CreateTestFramework();
MockAttribute testAttribute = new MockAttribute("NUnit.Framework.TestAttribute");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
bool result = testFramework.IsTestMember(mockMethod);
Assert.IsTrue(result);
}
[Test]
public void IsTestMember_MethodIsNull_ReturnsFalse()
{
CreateTestFramework();
bool result = testFramework.IsTestMember(null);
Assert.IsFalse(result);
}
[Test]
public void IsTestMember_ProjectContentLanguageHasNullNameComparer_ReturnsFalse()
{
CreateTestFramework();
MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes();
mockClass.MockProjectContent.Language = new LanguageProperties(null);
var mockMethod = new MockMethod(mockClass);
mockMethod.Attributes.Add(new MockAttribute("Test"));
bool result = testFramework.IsTestMember(mockMethod);
Assert.IsFalse(result);
}
/// <summary>
/// Even if the project is null the method should be
/// flagged as a TestMethod.
/// </summary>
[Test]
public void IsTestMember_ProjectIsNull_ReturnsTrue()
{
CreateTestFramework();
var testAttribute = new MockAttribute("Test");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
MockProjectContent mockProjectContent = (MockProjectContent)mockMethod.DeclaringType.ProjectContent;
mockProjectContent.Project = null;
bool result = testFramework.IsTestMember(mockMethod);
Assert.IsTrue(result);
}
[Test]
public void IsTestMember_MethodHasNullLanguage_ReturnsFalse()
{
CreateTestFramework();
MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes();
mockClass.MockProjectContent.Language = null;
var mockMethod = new MockMethod(mockClass);
bool result = testFramework.IsTestMember(mockMethod);
Assert.IsFalse(result);
}
[Test]
public void IsTestMember_MethodHasParameters_ReturnsFalse()
{
CreateTestFramework();
var testAttribute = new MockAttribute("Test");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
var mockParameter = new MockParameter();
mockMethod.Parameters.Add(mockParameter);
bool result = testFramework.IsTestMember(mockMethod);
Assert.IsFalse(result);
}
[Test]
public void IsTestMember_FieldHasOneAttribute_ReturnsFalseAndDoesNotThrowInvalidCastException()
{
CreateTestFramework();
MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes();
var field = new DefaultField(mockClass, "MyField");
var testAttribute = new MockAttribute("Test");
field.Attributes.Add(testAttribute);
bool result = testFramework.IsTestMember(field);
Assert.IsFalse(result);
}
}
}

89
src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDoozerTests.cs

@ -1,89 +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.Core;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests.Frameworks
{
[TestFixture]
public class TestFrameworkDoozerTests
{
Properties properties;
TestFrameworkDescriptor descriptor;
TestFrameworkDoozer doozer;
MockTestFramework mockTestFramework;
MockTestFrameworkFactory mockTestFrameworkFactory;
void CreateDoozer()
{
properties = new Properties();
properties["id"] = "Default";
properties["class"] = "UnitTesting.Tests.Utils.MockTestFramework";
Codon codon = new Codon(null, "TestFramework", properties, null);
mockTestFrameworkFactory = new MockTestFrameworkFactory();
mockTestFramework = mockTestFrameworkFactory.AddFakeTestFramework("UnitTesting.Tests.Utils.MockTestFramework");
doozer = new TestFrameworkDoozer();
descriptor = doozer.BuildItem(codon, mockTestFrameworkFactory);
}
[Test]
public void Id_PropertiesIdIsDefault_ReturnsDefault()
{
CreateDoozer();
properties["id"] = "Default";
string id = descriptor.Id;
Assert.AreEqual("Default", id);
}
[Test]
public void IDoozer_TestFrameworkDoozer_ImplementsIDoozer()
{
CreateDoozer();
IDoozer implementsDoozer = doozer as IDoozer;
Assert.IsNotNull(implementsDoozer);
}
[Test]
public void HandleConditions_TestFrameworkDoozerDoesNotHandleConditions_ReturnsFalse()
{
CreateDoozer();
bool conditions = doozer.HandleConditions;
Assert.IsFalse(conditions);
}
[Test]
public void TestFramework_TestFrameworkDescriptorTestFrameworkProperty_ReturnsMockTestFrameworkObject()
{
CreateDoozer();
bool result = descriptor.TestFramework is MockTestFramework;
Assert.IsTrue(result);
}
[Test]
public void TestFramework_PropertyAccessTwice_OnlyOneObjectCreated()
{
CreateDoozer();
ITestFramework testFramework = descriptor.TestFramework;
testFramework = descriptor.TestFramework;
List<string> expectedClassNames = new List<string>();
expectedClassNames.Add("UnitTesting.Tests.Utils.MockTestFramework");
List<string> classNamesCreated = mockTestFrameworkFactory.ClassNamesPassedToCreateMethod;
Assert.AreEqual(expectedClassNames, classNamesCreated);
}
}
}

121
src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestFrameworkIsTestClassTests.cs

@ -0,0 +1,121 @@
// 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;
using System;
using System.Collections.Generic;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests.NUnit
{
[TestFixture]
public class NUnitTestFrameworkIsTestClassTests
{
NUnitTestFramework testFramework;
[SetUp]
public void Init()
{
testFramework = new NUnitTestFramework();
}
[Test]
public void IsTestClassReturnsFalseHasClassHasNoAttributes()
{
var c = NRefactoryHelper.CreateTypeDefinition("class EmptyClass {}");
Assert.IsFalse(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueHasClassHasTestFixtureAttributeMissingAttributePart()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; [TestFixture] class EmptyClass {}");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsFalseWhenClassHasTestFixtureAttributeAndIsAbstract() {
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; [TestFixture] abstract class EmptyClass {}");
Assert.IsFalse(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueHasClassHasTestFixtureAttribute()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; [TestFixtureAttribute] class EmptyClass {}");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueHasClassHasFullyQualifiedNUnitTestFixtureAttribute()
{
var c = NRefactoryHelper.CreateTypeDefinition("[NUnit.Framework.TestFixtureAttribute] class EmptyClass {}");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsFalseWhenClassIsNull()
{
Assert.IsFalse(NUnitTestFramework.IsTestClass(null));
}
[Test]
public void IsTestClassReturnsFalseWhenClassHasTestAttributeWithoutUsingNUnit()
{
var c = NRefactoryHelper.CreateTypeDefinition("class C { [Test] public void M() {} }");
Assert.IsFalse(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueWhenContainingTestMethod()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; class C { [Test] public void M() {} }");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueWhenContainingTestCase()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; class C { [TestCase(1)] public void M(int i) {} }");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsFalseWhenAbstractClassContainsTestMethod()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; abstract class C { [Test] public void M() {} }");
Assert.IsFalse(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueWhenContainingInnerClassWithTestMethod()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; class C { class Inner { [Test] public void M() {} } }");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueWhenAbstractClassContainsInnerClassWithTestMethod()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; abstract class C { class Inner { [Test] public void M() {} } }");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueWhenStaticClassWithTestMethod()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; static class C { [Test] public static void M() {} }");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueWhenStaticClassWithAttribute()
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; [TestFixture] static class C { }");
Assert.IsTrue(NUnitTestFramework.IsTestClass(c));
}
}
}

89
src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestFrameworkIsTestMemberTests.cs

@ -0,0 +1,89 @@
// 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.Linq;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests.NUnit
{
[TestFixture]
public class NUnitTestFrameworkIsTestMemberTests
{
IMethod CreateMethod(string code)
{
var c = NRefactoryHelper.CreateTypeDefinition("using NUnit.Framework; class C { " + code + " } ");
return c.Methods.First();
}
[Test]
public void IsTestMember_MethodHasNoAttributes_ReturnsFalse()
{
var m = CreateMethod("public void M() {}");
Assert.IsFalse(NUnitTestFramework.IsTestMethod(m));
}
[Test]
public void IsTestMember_MethodHasTestAttributeWithoutAttributePart_ReturnsTrue()
{
var m = CreateMethod("[Test] public void M() {}");
Assert.IsTrue(NUnitTestFramework.IsTestMethod(m));
}
[Test]
public void IsTestMember_MethodHasTestAttributeAttribute_ReturnsTrue()
{
var m = CreateMethod("[TestAttribute] public void M() {}");
Assert.IsTrue(NUnitTestFramework.IsTestMethod(m));
}
[Test]
public void IsTestMember_MethodHasFullyQualifiedNUnitTestAttribute_ReturnsTrue()
{
var m = CreateMethod("[NUnit.Framework.TestAttribute] public void M() {}");
Assert.IsTrue(NUnitTestFramework.IsTestMethod(m));
}
[Test]
public void IsTestMember_MethodIsNull_ReturnsFalse()
{
Assert.IsFalse(NUnitTestFramework.IsTestMethod(null));
}
[Test]
public void IsTestMember_MethodHasParameters_ReturnsTrue()
{
// not actually executable, but NUnit still considers it a test case
// and marks it as ignored
var m = CreateMethod("[Test] public void M(int a) {}");
Assert.IsTrue(NUnitTestFramework.IsTestMethod(m));
}
[Test]
public void IsTestMember_MethodIsStatic_ReturnsTrue()
{
var m = CreateMethod("[Test] public static void M() {}");
Assert.IsTrue(NUnitTestFramework.IsTestMethod(m));
}
[Test]
public void TestCase()
{
var m = CreateMethod("[TestCase] public void M() {}");
Assert.IsTrue(NUnitTestFramework.IsTestMethod(m));
}
[Test]
public void TestCase_WithParameter()
{
var m = CreateMethod("[TestCase(1), TestCase(2)] public void M(int x) {}");
Assert.IsTrue(NUnitTestFramework.IsTestMethod(m));
}
}
}

2
src/AddIns/Analysis/UnitTesting/Test/NUnit/NUnitTestFrameworkIsTestProjectTests.cs

@ -43,7 +43,7 @@ namespace UnitTesting.Tests.NUnit
public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReference() public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReference()
{ {
MockCSharpProject project = new MockCSharpProject(); MockCSharpProject project = new MockCSharpProject();
project.AddAssemblyReference(AssemblyLoader.NUnitFramework); project.AddAssemblyReference(NRefactoryHelper.NUnitFramework);
SD.ParserService.Stub(p => p.GetCompilation(project)).Return(project.ProjectContent.CreateCompilation()); SD.ParserService.Stub(p => p.GetCompilation(project)).Return(project.ProjectContent.CreateCompilation());
Assert.IsTrue(testFramework.IsTestProject(project)); Assert.IsTrue(testFramework.IsTestProject(project));

98
src/AddIns/Analysis/UnitTesting/Test/NUnitConsoleExeSelectedTestFixture.cs

@ -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 System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using ICSharpCode.UnitTesting;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests
{
/// <summary>
/// If the project explicitly targets 32 bit (x86) architecture then nunit-console-x86.exe should be
/// used. Otherwise the normal nunit-console.exe is used.
/// </summary>
[TestFixture]
public class NUnitConsoleExeSelectedTestFixture
{
string oldRootPath;
[TestFixtureSetUpAttribute]
public void SetUpFixture()
{
oldRootPath = FileUtility.ApplicationRootPath;
FileUtility.ApplicationRootPath = @"D:\SharpDevelop";
}
[TestFixtureTearDown]
public void TearDownFixture()
{
FileUtility.ApplicationRootPath = oldRootPath;
}
[Test]
public void NothingSpecified()
{
MockCSharpProject project = new MockCSharpProject();
UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
helper.Initialize(project, null);
Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2-x86.exe", helper.UnitTestApplication);
}
[Test]
public void TargetCpuAnyCPUDotnet2()
{
MockCSharpProject project = new MockCSharpProject();
project.ActiveConfiguration = "Debug";
project.ActivePlatform = "AnyCPU";
project.SetProperty("PlatformTarget", "AnyCPU");
project.SetProperty("TargetFrameworkVersion", "v3.5");
UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
helper.Initialize(project, null);
Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2.exe", helper.UnitTestApplication);
}
[Test]
public void NUnitConsole32BitUsedWhenTargetCpuIs32BitDotnet2()
{
MockCSharpProject project = new MockCSharpProject();
project.ActiveConfiguration = "Debug";
project.ActivePlatform = "AnyCPU";
project.SetProperty("PlatformTarget", "x86");
project.SetProperty("TargetFrameworkVersion", "v3.5");
UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
helper.Initialize(project, null);
Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2-x86.exe", helper.UnitTestApplication);
}
[Test]
public void NUnitConsole32BitUsedWhenTargetCpuIs32Bit()
{
MockCSharpProject project = new MockCSharpProject();
project.ActiveConfiguration = "Debug";
project.ActivePlatform = "AnyCPU";
project.SetProperty("PlatformTarget", "x86");
project.SetProperty("TargetFrameworkVersion", "v4.0");
UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
helper.Initialize(project, null);
Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", helper.UnitTestApplication);
}
[Test]
public void NotMSBuildBasedProject()
{
MissingProject project = new MissingProject(@"C:\Projects\Test.proj", "Test");
UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
helper.Initialize(project, null);
Assert.AreEqual(project.GetType().BaseType, typeof(AbstractProject), "MissingProject should be derived from AbstractProject.");
Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", helper.UnitTestApplication);
}
}
}

20
src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorTests.cs → src/AddIns/Analysis/UnitTesting/Test/Service/TestFrameworkDescriptorTests.cs

@ -6,15 +6,16 @@ using ICSharpCode.Core;
using ICSharpCode.UnitTesting; using ICSharpCode.UnitTesting;
using NUnit.Framework; using NUnit.Framework;
using UnitTesting.Tests.Utils; using UnitTesting.Tests.Utils;
using Rhino.Mocks;
using ICSharpCode.SharpDevelop;
namespace UnitTesting.Tests.Frameworks namespace UnitTesting.Tests.Service
{ {
[TestFixture] [TestFixture]
public class TestFrameworkDescriptorTests public class TestFrameworkDescriptorTests : SDTestFixtureBase
{ {
TestFrameworkDescriptor descriptor; TestFrameworkDescriptor descriptor;
MockTestFrameworkFactory fakeTestFrameworkFactory; ITestFramework fakeTestFramework;
MockTestFramework fakeTestFramework;
void CreateTestFrameworkDescriptorToSupportCSharpProjects() void CreateTestFrameworkDescriptorToSupportCSharpProjects()
{ {
@ -28,24 +29,23 @@ namespace UnitTesting.Tests.Frameworks
properties["class"] = "NUnitTestFramework"; properties["class"] = "NUnitTestFramework";
properties["supportedProjects"] = fileExtensions; properties["supportedProjects"] = fileExtensions;
fakeTestFrameworkFactory = new MockTestFrameworkFactory(); descriptor = new TestFrameworkDescriptor(properties, _ => fakeTestFramework);
fakeTestFramework = new MockTestFramework();
fakeTestFrameworkFactory.Add("NUnitTestFramework", fakeTestFramework);
descriptor = new TestFrameworkDescriptor(properties, fakeTestFrameworkFactory);
} }
MockCSharpProject CreateCSharpProjectNotSupportedByTestFramework() MockCSharpProject CreateCSharpProjectNotSupportedByTestFramework()
{ {
var project = new MockCSharpProject(); var project = new MockCSharpProject();
project.FileName = @"d:\projects\MyProject\MyProject.csproj"; project.FileName = @"d:\projects\MyProject\MyProject.csproj";
fakeTestFramework = MockRepository.GenerateStrictMock<ITestFramework>();
fakeTestFramework.Stub(f => f.IsTestProject(project)).Return(false);
return project; return project;
} }
MockCSharpProject CreateCSharpProjectSupportedByTestFramework() MockCSharpProject CreateCSharpProjectSupportedByTestFramework()
{ {
MockCSharpProject project = CreateCSharpProjectNotSupportedByTestFramework(); MockCSharpProject project = CreateCSharpProjectNotSupportedByTestFramework();
fakeTestFramework.AddTestProject(project); fakeTestFramework = MockRepository.GenerateStrictMock<ITestFramework>();
fakeTestFramework.Stub(f => f.IsTestProject(project)).Return(true);
return project; return project;
} }

224
src/AddIns/Analysis/UnitTesting/Test/UnitTestCommandLineTests.cs

@ -1,224 +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.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests
{
[TestFixture]
public class UnitTestCommandLineTests
{
CompilableProject project;
UnitTestApplicationStartHelper helper;
[SetUp]
public void SetUp()
{
project = new MockCSharpProject();
project.FileName = @"C:\Projects\MyTests\MyTests.csproj";
project.AssemblyName = "MyTests";
project.OutputType = OutputType.Library;
project.SetProperty("OutputPath", "."); // don't create bin/Debug
project.SetProperty("TargetFrameworkVersion", "v4.0");
helper = new UnitTestApplicationStartHelper();
}
[Test]
public void TestResultsFile()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.Results = @"C:\results.txt";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /results=\"C:\\results.txt\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void NoLogo()
{
helper.Initialize(project, null, null);
helper.NoLogo = true;
helper.ShadowCopy = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nologo";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void NoShadowCopy()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = false;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /noshadow";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void NoThread()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.NoThread = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nothread";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void NoDots()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.NoDots = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nodots";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void Labels()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.Labels = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /labels";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void TestFixture()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.Fixture = "TestFixture";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void TestNamespace()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.NamespaceFilter = "TestFixture";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void XmlOutputFile()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.XmlOutputFile = @"C:\NUnit.xml";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /xml=\"C:\\NUnit.xml\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void TestMethod()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.Fixture = "TestFixture";
helper.Test = "Test";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void TestMethodSpecifiedInInitialize()
{
MockClass testFixture = new MockClass("TestFixture");
MockMethod testMethod = new MockMethod("Test");
helper.Initialize(project, testFixture, testMethod);
helper.NoLogo = false;
helper.ShadowCopy = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void TestNamespaceSpecifiedInInitialize()
{
helper.Initialize(project, "Project.MyTests");
helper.NoLogo = false;
helper.ShadowCopy = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"Project.MyTests\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void FullCommandLine()
{
helper.Initialize(project, null, null);
helper.NoLogo = true;
helper.ShadowCopy = true;
FileUtility.ApplicationRootPath = @"C:\SharpDevelop";
string expectedFullCommandLine = "\"C:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" \"C:\\Projects\\MyTests\\MyTests.dll\" /nologo";
Assert.AreEqual(expectedFullCommandLine, helper.GetCommandLine());
}
/// <summary>
/// Tests that a space is appended between the items added
/// to the UnitTestApplicationStartHelper.Assemblies
/// when the command line is generated.
/// </summary>
[Test]
public void SecondAssemblySpecified()
{
helper.Initialize(project, null, null);
helper.Assemblies.Add("SecondAssembly.dll");
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.Results = @"C:\results.txt";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" \"SecondAssembly.dll\" /results=\"C:\\results.txt\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void GetProject()
{
helper.Initialize(project, null, null);
Assert.AreSame(project, helper.Project);
}
[Test]
public void TestInnerClassSpecifiedInInitialize()
{
MockClass testFixture = new MockClass("MyTests.TestFixture.InnerTest", "MyTests.TestFixture+InnerTest");
helper.Initialize(project, testFixture, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"MyTests.TestFixture+InnerTest\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
}
}

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

@ -71,10 +71,13 @@
<Compile Include="NUnit\NUnitConsoleCommandLineTests.cs" /> <Compile Include="NUnit\NUnitConsoleCommandLineTests.cs" />
<Compile Include="NUnit\NUnitConsoleExeSelectedTestFixture.cs" /> <Compile Include="NUnit\NUnitConsoleExeSelectedTestFixture.cs" />
<Compile Include="NUnit\NUnitConsoleProcessStartInfoTestFixture.cs" /> <Compile Include="NUnit\NUnitConsoleProcessStartInfoTestFixture.cs" />
<Compile Include="NUnit\NUnitTestFrameworkIsTestClassTests.cs" />
<Compile Include="NUnit\NUnitTestFrameworkIsTestMemberTests.cs" />
<Compile Include="NUnit\NUnitTestFrameworkIsTestProjectTests.cs" /> <Compile Include="NUnit\NUnitTestFrameworkIsTestProjectTests.cs" />
<Compile Include="NUnit\NUnitTestResultFailureTestFixture.cs" /> <Compile Include="NUnit\NUnitTestResultFailureTestFixture.cs" />
<Compile Include="Service\TestFrameworkDescriptorTests.cs" />
<Compile Include="Utils\MockCSharpProject.cs" /> <Compile Include="Utils\MockCSharpProject.cs" />
<Compile Include="Utils\AssemblyLoader.cs" /> <Compile Include="Utils\NRefactoryHelper.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj"> <ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">

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

@ -31,7 +31,7 @@ namespace UnitTesting.Tests.Utils
{ {
OutputType = OutputType.Library; OutputType = OutputType.Library;
projectContent = new CSharpProjectContent().SetAssemblyName(name).SetProjectFileName(this.FileName); projectContent = new CSharpProjectContent().SetAssemblyName(name).SetProjectFileName(this.FileName);
projectContent = projectContent.AddAssemblyReferences(AssemblyLoader.Corlib); projectContent = projectContent.AddAssemblyReferences(NRefactoryHelper.Corlib);
} }
public override string Language { public override string Language {

17
src/AddIns/Analysis/UnitTesting/Test/Utils/AssemblyLoader.cs → src/AddIns/Analysis/UnitTesting/Test/Utils/NRefactoryHelper.cs

@ -3,12 +3,14 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Linq;
using System.Reflection; using System.Reflection;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
namespace UnitTesting.Tests.Utils namespace UnitTesting.Tests.Utils
{ {
public class AssemblyLoader public class NRefactoryHelper
{ {
static ConcurrentDictionary<string, IUnresolvedAssembly> dict = new ConcurrentDictionary<string, IUnresolvedAssembly>(); static ConcurrentDictionary<string, IUnresolvedAssembly> dict = new ConcurrentDictionary<string, IUnresolvedAssembly>();
@ -24,5 +26,18 @@ namespace UnitTesting.Tests.Utils
public static IUnresolvedAssembly NUnitFramework { public static IUnresolvedAssembly NUnitFramework {
get { return Load(typeof(global::NUnit.Framework.TestAttribute).Assembly); } get { return Load(typeof(global::NUnit.Framework.TestAttribute).Assembly); }
} }
public static ICompilation CreateCompilation(string code)
{
return new CSharpProjectContent()
.AddAssemblyReferences(Corlib, NUnitFramework)
.AddOrUpdateFiles(new CSharpParser().Parse(code, "test.cs").ToTypeSystem())
.CreateCompilation();
}
public static ITypeDefinition CreateTypeDefinition(string code)
{
return CreateCompilation(code).MainAssembly.TopLevelTypeDefinitions.First();
}
} }
} }

8
src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj

@ -114,16 +114,10 @@
<Compile Include="StringTagProvider\MockProjectForTagProvider.cs" /> <Compile Include="StringTagProvider\MockProjectForTagProvider.cs" />
<Compile Include="StringTagProvider\NullProjectStringTagProviderTestFixture.cs" /> <Compile Include="StringTagProvider\NullProjectStringTagProviderTestFixture.cs" />
<Compile Include="StringTagProvider\ProjectTagsTestFixture.cs" /> <Compile Include="StringTagProvider\ProjectTagsTestFixture.cs" />
<Compile Include="Utils\MockAmbience.cs" /> <Compile Include="Utils\FakeMessageLoop.cs" />
<Compile Include="Utils\MockAssembly.cs" /> <Compile Include="Utils\MockAssembly.cs" />
<Compile Include="Utils\MockClass.cs" />
<Compile Include="Utils\MockComponent.cs" /> <Compile Include="Utils\MockComponent.cs" />
<Compile Include="Utils\MockEntity.cs" />
<Compile Include="Utils\MockDefaultReturnType.cs" />
<Compile Include="Utils\MockMethod.cs" />
<Compile Include="Utils\MockOpenedFile.cs" /> <Compile Include="Utils\MockOpenedFile.cs" />
<Compile Include="Utils\MockProject.cs" />
<Compile Include="Utils\MockProperty.cs" />
<Compile Include="Utils\MockSite.cs" /> <Compile Include="Utils\MockSite.cs" />
<Compile Include="Utils\MockTextMarker.cs" /> <Compile Include="Utils\MockTextMarker.cs" />
<Compile Include="Utils\MockTextMarkerService.cs" /> <Compile Include="Utils\MockTextMarkerService.cs" />

113
src/Main/Base/Test/Utils/FakeMessageLoop.cs

@ -0,0 +1,113 @@
// 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.Threading;
using System.Threading.Tasks;
namespace ICSharpCode.SharpDevelop
{
/// <summary>
/// A fake message lop that always has <c>InvokeRequired=false</c> and synchronously invokes
/// the callback passed to <c>InvokeIfRequired</c>.
/// </summary>
public class FakeMessageLoop : IMessageLoop
{
public Thread Thread {
get {
throw new NotImplementedException();
}
}
public System.Windows.Threading.Dispatcher Dispatcher {
get {
throw new NotImplementedException();
}
}
public SynchronizationContext SynchronizationContext {
get {
throw new NotImplementedException();
}
}
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {
get {
throw new NotImplementedException();
}
}
public bool InvokeRequired {
get { return false; }
}
public bool CheckAccess()
{
return true;
}
public void VerifyAccess()
{
}
public void InvokeIfRequired(Action callback)
{
callback();
}
public void InvokeIfRequired(Action callback, System.Windows.Threading.DispatcherPriority priority)
{
callback();
}
public void InvokeIfRequired(Action callback, System.Windows.Threading.DispatcherPriority priority, CancellationToken cancellationToken)
{
callback();
}
public T InvokeIfRequired<T>(Func<T> callback)
{
return callback();
}
public T InvokeIfRequired<T>(Func<T> callback, System.Windows.Threading.DispatcherPriority priority)
{
return callback();
}
public T InvokeIfRequired<T>(Func<T> callback, System.Windows.Threading.DispatcherPriority priority, CancellationToken cancellationToken)
{
return callback();
}
public Task InvokeAsync(Action callback)
{
throw new NotImplementedException();
}
public Task InvokeAsync(Action callback, System.Windows.Threading.DispatcherPriority priority)
{
throw new NotImplementedException();
}
public Task InvokeAsync(Action callback, System.Windows.Threading.DispatcherPriority priority, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public Task<T> InvokeAsync<T>(Func<T> callback)
{
throw new NotImplementedException();
}
public Task<T> InvokeAsync<T>(Func<T> callback, System.Windows.Threading.DispatcherPriority priority)
{
throw new NotImplementedException();
}
public Task<T> InvokeAsync<T>(Func<T> callback, System.Windows.Threading.DispatcherPriority priority, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
}

84
src/Main/Base/Test/Utils/MockAmbience.cs

@ -1,84 +0,0 @@
#warning
//// 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;
//
//namespace ICSharpCode.SharpDevelop.Tests.Utils
//{
// /// <summary>
// /// Mock Ambience class.
// /// </summary>
// public class MockAmbience : AbstractAmbience
// {
// public MockAmbience()
// {
// }
//
// public override string Convert(IClass c)
// {
// return String.Empty;
// }
//
// public override string ConvertEnd(IClass c)
// {
// return String.Empty;
// }
//
// public override string Convert(IField c)
// {
// return String.Empty;
// }
//
// public override string Convert(IProperty property)
// {
// return property.Name;
// }
//
// public override string Convert(IEvent e)
// {
// return String.Empty;
// }
//
// public override string Convert(IMethod m)
// {
// return m.Name;
// }
//
// public override string ConvertEnd(IMethod m)
// {
// return String.Empty;
// }
//
// public override string Convert(IParameter param)
// {
// return String.Empty;
// }
//
// public override string Convert(IReturnType returnType)
// {
// return String.Empty;
// }
//
// public override string WrapAttribute(string attribute)
// {
// return String.Empty;
// }
//
// public override string WrapComment(string comment)
// {
// return String.Empty;
// }
//
// public override string GetIntrinsicTypeName(string dotNetTypeName)
// {
// return String.Empty;
// }
//
// public override string ConvertAccessibility(ModifierEnum accessibility)
// {
// return String.Empty;
// }
// }
//}

367
src/Main/Base/Test/Utils/MockClass.cs

@ -1,367 +0,0 @@
#warning
//// 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 ICSharpCode.SharpDevelop.Tests.Utils
//{
// /// <summary>
// /// Dummy class that implements the IClass interface. The
// /// only properties this mock class implements is DefaultReturnType and FullyQualifiedName.
// /// </summary>
// public class MockClass : IClass
// {
// public MockClass(string qualifiedName)
// {
// this.FullyQualifiedName = qualifiedName;
// }
//
// public string FullyQualifiedName { get; set; }
// public IReturnType DefaultReturnType { get; set;}
//
// public string DotNetName {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Name {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Namespace {
// get {
// throw new NotImplementedException();
// }
// }
//
// public ClassType ClassType {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IProjectContent ProjectContent {
// get {
// return DefaultProjectContent.DummyProjectContent;
// }
// }
//
// public ISyntaxTree SyntaxTree {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IUsingScope UsingScope {
// get {
// throw new NotImplementedException();
// }
// }
//
// public DomRegion Region {
// get {
// throw new NotImplementedException();
// }
// }
//
// public DomRegion BodyRegion {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IReturnType> BaseTypes {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IClass> InnerClasses {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IField> Fields {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IProperty> Properties {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IMethod> Methods {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IEvent> Events {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<ITypeParameter> TypeParameters {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IEnumerable<IClass> ClassInheritanceTree {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IEnumerable<IClass> ClassInheritanceTreeClassesOnly {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IClass BaseClass {
// get {
// return BaseType.GetUnderlyingClass();
// }
// }
//
// public IReturnType BaseType { get; set; }
//
// public bool HasPublicOrInternalStaticMembers {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool HasExtensionMethods {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsPartial {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public IClass DeclaringType {
// get {
// throw new NotImplementedException();
// }
// }
//
// public ModifierEnum Modifiers {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IAttribute> Attributes {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Documentation {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsAbstract {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsSealed {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsStatic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsConst {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsVirtual {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsPublic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtected {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsPrivate {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsReadonly {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtectedAndInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtectedOrInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsOverride {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsOverridable {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsNew {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsSynthetic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public object UserData {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public bool IsFrozen {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IReturnType GetBaseType(int index)
// {
// throw new NotImplementedException();
// }
//
// public IClass GetCompoundClass()
// {
// return this;
// }
//
// public IClass GetInnermostClass(int caretLine, int caretColumn)
// {
// throw new NotImplementedException();
// }
//
// public List<IClass> GetAccessibleTypes(IClass callingClass)
// {
// throw new NotImplementedException();
// }
//
// public IMember SearchMember(string memberName, LanguageProperties language)
// {
// throw new NotImplementedException();
// }
//
// public bool IsTypeInInheritanceTree(IClass possibleBaseClass)
// {
// throw new NotImplementedException();
// }
//
// public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree)
// {
// throw new NotImplementedException();
// }
//
// public void Freeze()
// {
// throw new NotImplementedException();
// }
//
// public int CompareTo(object obj)
// {
// throw new NotImplementedException();
// }
//
// public bool HasCompoundClass {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public IEnumerable<IMember> AllMembers {
// get {
// throw new NotImplementedException();
// }
// }
//
// public EntityType EntityType {
// get { return EntityType.Class; }
// }
//
// public bool AddDefaultConstructorIfRequired {
// get {
// throw new NotImplementedException();
// }
// }
// }
//}

160
src/Main/Base/Test/Utils/MockDefaultReturnType.cs

@ -1,160 +0,0 @@
#warning
//// 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 ICSharpCode.SharpDevelop.Tests.Utils
//{
// public class MockDefaultReturnType : IReturnType
// {
// List<IMethod> methods = new List<IMethod>();
// List<IProperty> properties = new List<IProperty>();
//
// public MockDefaultReturnType()
// {
// }
//
// /// <summary>
// /// Gets the method list directly. Only available in the
// /// mock default return type class.
// /// </summary>
// public List<IMethod> Methods {
// get {
// return methods;
// }
// }
//
// /// <summary>
// /// Gets the property list directly. Only available in the
// /// mock default return type class.
// /// </summary>
// public List<IProperty> Properties {
// get {
// return properties;
// }
// }
//
// public bool Equals(IReturnType other)
// {
// throw new NotImplementedException();
// }
//
// public string FullyQualifiedName {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Name {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Namespace {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string DotNetName {
// get {
// throw new NotImplementedException();
// }
// }
//
// public int TypeArgumentCount {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsDefaultReturnType {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IClass GetUnderlyingClass()
// {
// throw new NotImplementedException();
// }
//
// public List<IMethod> GetMethods()
// {
// return methods;
// }
//
// public List<IProperty> GetProperties()
// {
// return properties;
// }
//
// public List<IField> GetFields()
// {
// return new List<IField>();
// }
//
// public List<IEvent> GetEvents()
// {
// return new List<IEvent>();
// }
//
// public ArrayReturnType CastToArrayReturnType()
// {
// throw new NotImplementedException();
// }
//
// public GenericReturnType CastToGenericReturnType()
// {
// throw new NotImplementedException();
// }
//
// public ConstructedReturnType CastToConstructedReturnType()
// {
// throw new NotImplementedException();
// }
//
// public bool IsArrayReturnType {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsGenericReturnType {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsConstructedReturnType {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsDecoratingReturnType<T>() where T : DecoratingReturnType
// {
// throw new NotImplementedException();
// }
//
// public T CastToDecoratingReturnType<T>() where T : DecoratingReturnType
// {
// throw new NotImplementedException();
// }
//
// public Nullable<bool> IsReferenceType {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IReturnType GetDirectReturnType()
// {
// return this;
// }
// }
//}

34
src/Main/Base/Test/Utils/MockEntity.cs

@ -1,34 +0,0 @@
#warning
//// 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;
//
//namespace ICSharpCode.SharpDevelop.Tests.Utils
//{
// public class MockEntity : AbstractEntity
// {
// public MockEntity() : base(null)
// {
// }
//
// public override string DocumentationTag {
// get {
// return String.Empty;
// }
// }
//
// public override ISyntaxTree SyntaxTree {
// get {
// throw new NotImplementedException();
// }
// }
//
// public override EntityType EntityType {
// get {
// throw new NotImplementedException();
// }
// }
// }
//}

279
src/Main/Base/Test/Utils/MockMethod.cs

@ -1,279 +0,0 @@
#warning
//// 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 ICSharpCode.SharpDevelop.Tests.Utils
//{
// public class MockMethod : IMethod
// {
// string name = String.Empty;
//
// public MockMethod(string name)
// {
// this.name = name;
// }
//
// public string Name {
// get {
// return name;
// }
// }
//
// public IClass DeclaringType { get; set; }
// public bool IsConst { get; set; }
// public bool IsPrivate { get; set; }
// public bool IsOverridable { get; set; }
//
// public IList<ITypeParameter> TypeParameters {
// get {
// return new ITypeParameter[0];
// }
// }
//
// public bool IsConstructor {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsOperator {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<string> HandlesClauses {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IParameter> Parameters {
// get {
// return new IParameter[0];
// }
// }
//
// public bool IsExtensionMethod {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string FullyQualifiedName {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IReturnType DeclaringTypeReference {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public DomRegion Region {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Namespace {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string DotNetName {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IReturnType ReturnType {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public DomRegion BodyRegion {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<ExplicitInterfaceImplementation> InterfaceImplementations {
// get {
// throw new NotImplementedException();
// }
// }
//
// public ModifierEnum Modifiers {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IAttribute> Attributes {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Documentation {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsAbstract {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsSealed {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsStatic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsVirtual {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsPublic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtected {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsReadonly {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtectedAndInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtectedOrInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsOverride {
// get {
// return false;
// }
// }
//
// public bool IsFrozen {
// get {
// throw new NotImplementedException();
// }
// }
//
// public void Freeze()
// {
// throw new NotImplementedException();
// }
//
// public IMember GenericMember {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsNew {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsSynthetic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public object UserData {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public IMember CreateSpecializedMember()
// {
// throw new NotImplementedException();
// }
//
// public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree)
// {
// return !IsPrivate;
// }
//
// public int CompareTo(object obj)
// {
// throw new NotImplementedException();
// }
//
// public object Clone()
// {
// throw new NotImplementedException();
// }
//
// public ISyntaxTree SyntaxTree {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IProjectContent ProjectContent {
// get {
// throw new NotImplementedException();
// }
// }
//
// public EntityType EntityType {
// get { return EntityType.Method; }
// }
// }
//}

26
src/Main/Base/Test/Utils/MockProject.cs

@ -1,26 +0,0 @@
#warning
//// 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.Dom.CSharp;
//using ICSharpCode.SharpDevelop.Project;
//
//namespace ICSharpCode.SharpDevelop.Tests.Utils
//{
// /// <summary>
// /// Mocks IProject class that returns a dummy ambience.
// /// </summary>
// public class MockProject : AbstractProject
// {
// public MockProject()
// {
// }
//
// public override IAmbience GetAmbience()
// {
// return null;
// }
// }
//}

297
src/Main/Base/Test/Utils/MockProperty.cs

@ -1,297 +0,0 @@
#warning
//// 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 ICSharpCode.SharpDevelop.Tests.Utils
//{
// public class MockProperty : IProperty
// {
// string name = String.Empty;
//
// public MockProperty(string name)
// {
// this.name = name;
// }
//
// public string Name {
// get {
// return name;
// }
// }
//
// public IClass DeclaringType { get; set; }
// public bool IsConst { get; set; }
// public bool IsPrivate { get; set;}
// public bool IsOverridable { get; set;}
//
// public DomRegion GetterRegion {
// get {
// throw new NotImplementedException();
// }
// }
//
// public DomRegion SetterRegion {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool CanGet {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool CanSet {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsIndexer {
// get {
// throw new NotImplementedException();
// }
// }
//
// public ModifierEnum GetterModifiers {
// get {
// throw new NotImplementedException();
// }
// }
//
// public ModifierEnum SetterModifiers {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IParameter> Parameters {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsExtensionMethod {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string FullyQualifiedName {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IReturnType DeclaringTypeReference {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public IMember GenericMember {
// get {
// throw new NotImplementedException();
// }
// }
//
// public DomRegion Region {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Namespace {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string DotNetName {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IReturnType ReturnType {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public DomRegion BodyRegion {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<ExplicitInterfaceImplementation> InterfaceImplementations {
// get {
// throw new NotImplementedException();
// }
// }
//
// public ModifierEnum Modifiers {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IList<IAttribute> Attributes {
// get {
// throw new NotImplementedException();
// }
// }
//
// public string Documentation {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsAbstract {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsSealed {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsStatic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsVirtual {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsPublic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtected {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsReadonly {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtectedAndInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsProtectedOrInternal {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsOverride {
// get {
// return false;
// }
// }
//
// public bool IsNew {
// get {
// throw new NotImplementedException();
// }
// }
//
// public bool IsSynthetic {
// get {
// throw new NotImplementedException();
// }
// }
//
// public object UserData {
// get {
// throw new NotImplementedException();
// }
// set {
// throw new NotImplementedException();
// }
// }
//
// public bool IsFrozen {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IMember CreateSpecializedMember()
// {
// throw new NotImplementedException();
// }
//
// public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree)
// {
// return !IsPrivate;
// }
//
// public void Freeze()
// {
// throw new NotImplementedException();
// }
//
// public int CompareTo(object obj)
// {
// throw new NotImplementedException();
// }
//
// public object Clone()
// {
// throw new NotImplementedException();
// }
//
// public ISyntaxTree SyntaxTree {
// get {
// throw new NotImplementedException();
// }
// }
//
// public IProjectContent ProjectContent {
// get {
// throw new NotImplementedException();
// }
// }
//
// public EntityType EntityType {
// get { return EntityType.Property; }
// }
// }
//}
Loading…
Cancel
Save