30 changed files with 432 additions and 1165 deletions
@ -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 System.Linq; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Project |
||||
{ |
||||
[TestFixture] |
||||
public class TestClassWithFieldsDefinedAsTestMembersByTestFrameworkTests : ProjectTestFixtureBase |
||||
{ |
||||
[Test] |
||||
public void TestMembers_ClassHasOneFieldDefinedAsTestMemberByTestFramework_FirstItemHasSameNameAsField() |
||||
{ |
||||
var fakeTestFramework = new MockTestFramework(); |
||||
fakeTestFramework.AddTestClass("MyClass"); |
||||
fakeTestFramework.AddTestMember("MyClass.MyField"); |
||||
|
||||
CreateProject(fakeTestFramework, Parse("class MyClass { int MyField; }")); |
||||
|
||||
TestMember testField = testProject.TestClasses.Single().Members.Single(); |
||||
Assert.AreEqual("MyField", testField.Name); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,188 @@
@@ -0,0 +1,188 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a TestClassCollection with three test classes.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class TestCollectionTests |
||||
{ |
||||
class FakeTest : TestBase |
||||
{ |
||||
public override ITestProject ParentProject { |
||||
get { throw new NotImplementedException(); } |
||||
} |
||||
|
||||
public override string DisplayName { |
||||
get { throw new NotImplementedException(); } |
||||
} |
||||
|
||||
public new TestResultType Result { |
||||
get { return base.Result; } |
||||
// expose the setter
|
||||
set { base.Result = value; } |
||||
} |
||||
} |
||||
|
||||
FakeTest testClass1; |
||||
FakeTest testClass2; |
||||
FakeTest testClass3; |
||||
TestCollection testCollection; |
||||
bool testClassesResultChanged; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
testClassesResultChanged = false; |
||||
testCollection = new TestCollection(); |
||||
|
||||
// TestClass1.
|
||||
testClass1 = new FakeTest(); |
||||
testCollection.Add(testClass1); |
||||
|
||||
// TestClass2.
|
||||
testClass2 = new FakeTest(); |
||||
testCollection.Add(testClass2); |
||||
|
||||
// TestClass3.
|
||||
testClass3 = new FakeTest(); |
||||
testCollection.Add(testClass3); |
||||
|
||||
testCollection.PropertyChanged += testCollection_PropertyChanged; |
||||
} |
||||
|
||||
[Test] |
||||
public void InitialTestResult() |
||||
{ |
||||
Assert.AreEqual(TestResultType.None, testCollection.CompositeResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestClass1Fails() |
||||
{ |
||||
testClass1.Result = TestResultType.Failure; |
||||
Assert.AreEqual(TestResultType.Failure, testCollection.CompositeResult); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterTestClass1Failed() |
||||
{ |
||||
TestClass1Fails(); |
||||
foreach (var test in testCollection) |
||||
test.ResetTestResults(); |
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testClass1.Result); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestClassesPass() |
||||
{ |
||||
testClass1.Result = TestResultType.Success; |
||||
testClass2.Result = TestResultType.Success; |
||||
testClass3.Result = TestResultType.Success; |
||||
Assert.AreEqual(TestResultType.Success, testCollection.CompositeResult); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterAllPassed() |
||||
{ |
||||
AllTestClassesPass(); |
||||
foreach (var test in testCollection) |
||||
test.ResetTestResults(); |
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testClass1.Result); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestClassesIgnored() |
||||
{ |
||||
testClass1.Result = TestResultType.Ignored; |
||||
testClass2.Result = TestResultType.Ignored; |
||||
testClass3.Result = TestResultType.Ignored; |
||||
Assert.AreEqual(TestResultType.Ignored, testCollection.CompositeResult); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterAllTestClasssIgnored() |
||||
{ |
||||
AllTestClassesIgnored(); |
||||
|
||||
testClassesResultChanged = false; |
||||
foreach (var test in testCollection) |
||||
test.ResetTestResults(); |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testClass1.Result); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestClass1Removed() |
||||
{ |
||||
testCollection.Remove(testClass1); |
||||
testClass1.Result = TestResultType.Failure; |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.IsFalse(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestClassesResultSetToNoneAfterAllTestClassesIgnored() |
||||
{ |
||||
AllTestClassesIgnored(); |
||||
|
||||
testClassesResultChanged = false; |
||||
testClass1.Result = TestResultType.None; |
||||
testClass2.Result = TestResultType.None; |
||||
testClass3.Result = TestResultType.None; |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void AddTestFailureClassAfterAllTestsPassed() |
||||
{ |
||||
AllTestClassesPass(); |
||||
|
||||
FakeTest testClass4 = new FakeTest(); |
||||
testClass4.Result = TestResultType.Failure; |
||||
testCollection.Add(testClass4); |
||||
|
||||
Assert.AreEqual(TestResultType.Failure, testCollection.CompositeResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestClass1RemovedAfterSetToIgnored() |
||||
{ |
||||
testClass1.Result = TestResultType.Ignored; |
||||
|
||||
testCollection.Remove(testClass1); |
||||
InitialTestResult(); |
||||
} |
||||
|
||||
void testCollection_PropertyChanged(object sender, PropertyChangedEventArgs e) |
||||
{ |
||||
if (e.PropertyName == "CompositeResult") { |
||||
testClassesResultChanged = true; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,173 +0,0 @@
@@ -1,173 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Project |
||||
{ |
||||
/* |
||||
/// <summary>
|
||||
/// Creates a TestClassCollection with three test classes.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ThreeTestClassesTestResultsTestFixture |
||||
{ |
||||
TestClass testClass1; |
||||
TestClass testClass2; |
||||
TestClass testClass3; |
||||
bool testClassesResultChanged; |
||||
MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); |
||||
|
||||
testClassesResultChanged = false; |
||||
testClasses = new TestClassCollection(); |
||||
|
||||
// TestClass1.
|
||||
MockClass mockClass = new MockClass("TestClass1"); |
||||
testClass1 = new TestClass(mockClass, testFrameworks); |
||||
testClasses.Add(testClass1); |
||||
|
||||
// TestClass2.
|
||||
mockClass = new MockClass("TestClass2"); |
||||
testClass2 = new TestClass(mockClass, testFrameworks); |
||||
testClasses.Add(testClass2); |
||||
|
||||
// TestClass3.
|
||||
mockClass = new MockClass("TestClass3"); |
||||
testClass3 = new TestClass(mockClass, testFrameworks); |
||||
testClasses.Add(testClass3); |
||||
|
||||
testClasses.ResultChanged += TestClassesResultChanged; |
||||
} |
||||
|
||||
[Test] |
||||
public void InitialTestResult() |
||||
{ |
||||
Assert.AreEqual(TestResultType.None, testClasses.Result); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestClass1Fails() |
||||
{ |
||||
testClass1.TestResult = TestResultType.Failure; |
||||
Assert.AreEqual(TestResultType.Failure, testClasses.Result); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterTestClass1Failed() |
||||
{ |
||||
TestClass1Fails(); |
||||
testClasses.ResetTestResults(); |
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testClass1.TestResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestClassesPass() |
||||
{ |
||||
testClass1.TestResult = TestResultType.Success; |
||||
testClass2.TestResult = TestResultType.Success; |
||||
testClass3.TestResult = TestResultType.Success; |
||||
Assert.AreEqual(TestResultType.Success, testClasses.Result); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterAllPassed() |
||||
{ |
||||
AllTestClassesPass(); |
||||
testClasses.ResetTestResults(); |
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testClass1.TestResult); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestClassesIgnored() |
||||
{ |
||||
testClass1.TestResult = TestResultType.Ignored; |
||||
testClass2.TestResult = TestResultType.Ignored; |
||||
testClass3.TestResult = TestResultType.Ignored; |
||||
Assert.AreEqual(TestResultType.Ignored, testClasses.Result); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterAllTestClasssIgnored() |
||||
{ |
||||
AllTestClassesIgnored(); |
||||
|
||||
testClassesResultChanged = false; |
||||
testClasses.ResetTestResults(); |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testClass1.TestResult); |
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestClass1Removed() |
||||
{ |
||||
testClasses.Remove(testClass1); |
||||
testClass1.TestResult = TestResultType.Failure; |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.IsFalse(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestClassesResultSetToNoneAfterAllTestClassesIgnored() |
||||
{ |
||||
AllTestClassesIgnored(); |
||||
|
||||
testClassesResultChanged = false; |
||||
testClass1.TestResult = TestResultType.None; |
||||
testClass2.TestResult = TestResultType.None; |
||||
testClass3.TestResult = TestResultType.None; |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.IsTrue(testClassesResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void AddTestFailureClassAfterAllTestsPassed() |
||||
{ |
||||
AllTestClassesPass(); |
||||
|
||||
MockClass mockClass = new MockClass("TestClass4"); |
||||
TestClass testClass4 = new TestClass(mockClass, testFrameworks); |
||||
testClass4.TestResult = TestResultType.Failure; |
||||
testClasses.Add(testClass4); |
||||
|
||||
Assert.AreEqual(TestResultType.Failure, testClasses.Result); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestClass1RemovedAfterSetToIgnored() |
||||
{ |
||||
testClass1.TestResult = TestResultType.Ignored; |
||||
|
||||
testClasses.Remove(testClass1); |
||||
InitialTestResult(); |
||||
} |
||||
|
||||
void TestClassesResultChanged(object source, EventArgs e) |
||||
{ |
||||
testClassesResultChanged = true; |
||||
} |
||||
} |
||||
*/ |
||||
} |
@ -1,156 +0,0 @@
@@ -1,156 +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.Linq; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a TestMethodCollection with three TestMethods.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ThreeTestMethodsTestResultsTestFixture : ProjectTestFixtureBase |
||||
{ |
||||
TestClass testClass; |
||||
TestMember testMethod1; |
||||
TestMember testMethod2; |
||||
TestMember testMethod3; |
||||
bool testMethodsResultChanged; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
testMethodsResultChanged = false; |
||||
|
||||
testClass = new TestClass(MockClass.CreateMockClassWithoutAnyAttributes(), new NUnitTestFramework()); |
||||
testClass.Members.Add(new TestMember(MockMethod.CreateUnresolvedMethod("TestMethod1"))); |
||||
testClass.Members.Add(new TestMember(MockMethod.CreateUnresolvedMethod("TestMethod2"))); |
||||
testClass.Members.Add(new TestMember(MockMethod.CreateUnresolvedMethod("TestMethod3"))); |
||||
|
||||
testClass.TestResultChanged += TestMethodsResultChanged; |
||||
} |
||||
|
||||
[Test] |
||||
public void InitialTestResult() |
||||
{ |
||||
Assert.AreEqual(TestResultType.None, testClass.TestResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestMethod1Fails() |
||||
{ |
||||
testMethod1.TestResult = TestResultType.Failure; |
||||
Assert.AreEqual(TestResultType.Failure, testClass.TestResult); |
||||
Assert.IsTrue(testMethodsResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterTestMethod1Failed() |
||||
{ |
||||
TestMethod1Fails(); |
||||
testClass.ResetTestResults(); |
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testMethod1.TestResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestMethodsPass() |
||||
{ |
||||
testMethod1.TestResult = TestResultType.Success; |
||||
testMethod2.TestResult = TestResultType.Success; |
||||
testMethod3.TestResult = TestResultType.Success; |
||||
Assert.AreEqual(TestResultType.Success, testClass.TestResult); |
||||
Assert.IsTrue(testMethodsResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterAllPassed() |
||||
{ |
||||
AllTestMethodsPass(); |
||||
testClass.ResetTestResults(); |
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testMethod1.TestResult); |
||||
Assert.IsTrue(testMethodsResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestMethodsIgnored() |
||||
{ |
||||
testMethod1.TestResult = TestResultType.Ignored; |
||||
testMethod2.TestResult = TestResultType.Ignored; |
||||
testMethod3.TestResult = TestResultType.Ignored; |
||||
Assert.AreEqual(TestResultType.Ignored, testClass.TestResult); |
||||
Assert.IsTrue(testMethodsResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResetAfterAllTestMethodsIgnored() |
||||
{ |
||||
AllTestMethodsIgnored(); |
||||
|
||||
testMethodsResultChanged = false; |
||||
testClass.ResetTestResults(); |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.AreEqual(TestResultType.None, testMethod1.TestResult); |
||||
Assert.IsTrue(testMethodsResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestMethod1Removed() |
||||
{ |
||||
testClass.Members.Remove(testMethod1); |
||||
testMethod1.TestResult = TestResultType.Failure; |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.IsFalse(testMethodsResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestMethodsResultSetToNoneAfterAllTestClasssIgnored() |
||||
{ |
||||
AllTestMethodsIgnored(); |
||||
|
||||
testMethodsResultChanged = false; |
||||
testMethod1.TestResult = TestResultType.None; |
||||
testMethod2.TestResult = TestResultType.None; |
||||
testMethod3.TestResult = TestResultType.None; |
||||
|
||||
InitialTestResult(); |
||||
|
||||
Assert.IsTrue(testMethodsResultChanged); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestMethod1RemovedAfterSetToIgnored() |
||||
{ |
||||
testMethod1.TestResult = TestResultType.Ignored; |
||||
|
||||
testClass.Members.Remove(testMethod1); |
||||
InitialTestResult(); |
||||
} |
||||
|
||||
[Test] |
||||
public void AddTestFailureAfterAllTestsPassed() |
||||
{ |
||||
AllTestMethodsPass(); |
||||
|
||||
testClass.Members.Add(new TestMember(MockMethod.CreateUnresolvedMethod("TestMethod4"))); |
||||
|
||||
Assert.AreEqual(TestResultType.Failure, testClass.TestResult); |
||||
} |
||||
|
||||
void TestMethodsResultChanged(object source, EventArgs e) |
||||
{ |
||||
testMethodsResultChanged = true; |
||||
} |
||||
} |
||||
} |
@ -1,96 +0,0 @@
@@ -1,96 +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.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the test methods of a second parent base class are detected:
|
||||
///
|
||||
/// class BaseBaseTestFixture { [Test] public void BaseBaseTest() ... }
|
||||
/// class BaseTestFixture : BaseBaseTestFixture ...
|
||||
/// class TestFixture : BaseTestFixture
|
||||
/// </summary>
|
||||
[TestFixture, Ignore("Test inheritance not implemented")] |
||||
public class TwoBaseClassesWithTestMethodsTestFixture |
||||
{ |
||||
/* |
||||
TestClass testClass; |
||||
MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; |
||||
|
||||
[SetUp] |
||||
public void SetUp() |
||||
{ |
||||
MockProjectContent projectContent = new MockProjectContent(); |
||||
projectContent.Language = LanguageProperties.None; |
||||
|
||||
// Create the top base test class.
|
||||
MockClass baseBaseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.BaseBaseTestFixture"); |
||||
MockMethod baseMethod = new MockMethod(baseBaseClass, "BaseBaseTest"); |
||||
baseMethod.Attributes.Add(new MockAttribute("Test")); |
||||
baseBaseClass.Methods.Add(baseMethod); |
||||
|
||||
// Create the next level test class.
|
||||
MockClass baseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.BaseTestFixture"); |
||||
baseMethod = new MockMethod(baseClass, "BaseTest"); |
||||
baseMethod.Attributes.Add(new MockAttribute("Test")); |
||||
baseClass.Methods.Add(baseMethod); |
||||
|
||||
// Create the derived test class.
|
||||
c = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.MainTestFixture"); |
||||
c.Attributes.Add(new MockAttribute("TestFixture")); |
||||
projectContent.Classes.Add(c); |
||||
|
||||
// Set the base class for each class in the hierarchy.
|
||||
c.AddBaseClass(baseClass); |
||||
baseClass.AddBaseClass(baseBaseClass); |
||||
|
||||
// Create TestClass.
|
||||
testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); |
||||
testClass = new TestClass(c, testFrameworks); |
||||
} |
||||
|
||||
[Test] |
||||
public void BaseBaseTestMethodExists() |
||||
{ |
||||
Assert.IsTrue(testClass.Members.Contains("BaseBaseTestFixture.BaseBaseTest")); |
||||
} |
||||
|
||||
[Test] |
||||
public void BaseMethodExists() |
||||
{ |
||||
Assert.IsTrue(testClass.Members.Contains("BaseTestFixture.BaseTest")); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The TestMethod.Method property should return an IMethod
|
||||
/// that returns the derived class from the DeclaringType property
|
||||
/// and not the base class. This ensures that the correct
|
||||
/// test is run when selected in the unit test tree.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void BaseBaseMethodDeclaringTypeIsDerivedClass() |
||||
{ |
||||
TestMember method = testClass.Members["BaseBaseTestFixture.BaseBaseTest"]; |
||||
Assert.AreEqual(c, method.Member.DeclaringType); |
||||
} |
||||
|
||||
[Test] |
||||
public void UpdateTestResult() |
||||
{ |
||||
TestClassCollection testClasses = new TestClassCollection(); |
||||
testClasses.Add(testClass); |
||||
|
||||
TestResult testResult = new TestResult("ICSharpCode.SharpDevelop.Tests.MainTestFixture.BaseBaseTest"); |
||||
testResult.ResultType = TestResultType.Failure; |
||||
testClasses.UpdateTestResult(testResult); |
||||
|
||||
Assert.AreEqual(TestResultType.Failure, testClass.TestResult); |
||||
}*/ |
||||
} |
||||
} |
@ -1,32 +0,0 @@
@@ -1,32 +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; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace UnitTesting.Tests.Utils |
||||
{ |
||||
public class MockStatusBarService : IStatusBarService |
||||
{ |
||||
public void SetCaretPosition(int x, int y, int charOffset) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void SetMessage(string message, bool highlighted, IImage icon) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IProgressMonitor CreateProgressMonitor(System.Threading.CancellationToken cancellationToken) |
||||
{ |
||||
return new DummyProgressMonitor(); |
||||
} |
||||
|
||||
public void AddProgress(ProgressCollector progress) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -1,106 +0,0 @@
@@ -1,106 +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.Linq; |
||||
|
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace UnitTesting.Tests.Utils |
||||
{ |
||||
public class MockTestFramework : ITestFramework |
||||
{ |
||||
IMember isTestMemberParameterUsed; |
||||
List<string> testMembers = new List<string>(); |
||||
ITypeDefinition isTestClassParameterUsed; |
||||
List<string> testClasses = new List<string>(); |
||||
IProject isTestProjectParameterUsed; |
||||
List<IProject> testProjects = new List<IProject>(); |
||||
List<MockTestRunner> testRunnersCreated = new List<MockTestRunner>(); |
||||
List<MockTestRunner> testDebuggersCreated = new List<MockTestRunner>(); |
||||
bool buildNeededBeforeTestRun = true; |
||||
|
||||
public MockTestFramework() |
||||
{ |
||||
} |
||||
|
||||
public bool IsTestMember(IMember member) |
||||
{ |
||||
isTestMemberParameterUsed = member; |
||||
return testMembers.Contains(member.ReflectionName); |
||||
} |
||||
|
||||
public IEnumerable<TestMember> GetTestMembersFor(ITypeDefinition @class) { |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IMember IsTestMemberParameterUsed { |
||||
get { return isTestMemberParameterUsed; } |
||||
} |
||||
|
||||
public void AddTestMember(string reflectionName) |
||||
{ |
||||
testMembers.Add(reflectionName); |
||||
} |
||||
|
||||
public bool IsTestClass(ITypeDefinition c) |
||||
{ |
||||
isTestClassParameterUsed = c; |
||||
return testClasses.Contains(c.ReflectionName); |
||||
} |
||||
|
||||
public ITypeDefinition IsTestClassParameterUsed { |
||||
get { return isTestClassParameterUsed; } |
||||
} |
||||
|
||||
public void AddTestClass(string reflectionName) |
||||
{ |
||||
testClasses.Add(reflectionName); |
||||
} |
||||
|
||||
public bool IsTestProject(IProject project) |
||||
{ |
||||
isTestProjectParameterUsed = project; |
||||
return testProjects.Contains(project); |
||||
} |
||||
|
||||
public IProject IsTestProjectParameterUsed { |
||||
get { return isTestProjectParameterUsed; } |
||||
} |
||||
|
||||
public void AddTestProject(IProject project) |
||||
{ |
||||
testProjects.Add(project); |
||||
} |
||||
|
||||
public ITestRunner CreateTestRunner() |
||||
{ |
||||
MockTestRunner testRunner = new MockTestRunner(); |
||||
testRunnersCreated.Add(testRunner); |
||||
return testRunner; |
||||
} |
||||
|
||||
public List<MockTestRunner> TestRunnersCreated { |
||||
get { return testRunnersCreated; } |
||||
} |
||||
|
||||
public ITestRunner CreateTestDebugger() |
||||
{ |
||||
MockTestRunner testRunner = new MockTestRunner(); |
||||
testDebuggersCreated.Add(testRunner); |
||||
return testRunner; |
||||
} |
||||
|
||||
public List<MockTestRunner> TestDebuggersCreated { |
||||
get { return testDebuggersCreated; } |
||||
} |
||||
|
||||
public bool IsBuildNeededBeforeTestRun { |
||||
get { return buildNeededBeforeTestRun; } |
||||
set { buildNeededBeforeTestRun = value; } |
||||
} |
||||
} |
||||
} |
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace UnitTesting.Tests.Utils |
||||
{ |
||||
public class MockTestFrameworkFactory : ITestFrameworkFactory |
||||
{ |
||||
Dictionary<string, ITestFramework> frameworks = new Dictionary<string, ITestFramework>(); |
||||
List<string> classNames = new List<string>(); |
||||
|
||||
public void Add(string className, ITestFramework framework) |
||||
{ |
||||
frameworks.Add(className, framework); |
||||
} |
||||
|
||||
public ITestFramework Create(string className) |
||||
{ |
||||
classNames.Add(className); |
||||
|
||||
ITestFramework framework; |
||||
if (frameworks.TryGetValue(className, out framework)) { |
||||
return framework; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public List<string> ClassNamesPassedToCreateMethod { |
||||
get { return classNames; } |
||||
} |
||||
|
||||
public MockTestFramework AddFakeTestFramework(string className) |
||||
{ |
||||
var testFramework = new MockTestFramework(); |
||||
Add(className, testFramework); |
||||
return testFramework; |
||||
} |
||||
} |
||||
} |
@ -1,32 +0,0 @@
@@ -1,32 +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.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace UnitTesting.Tests.Utils |
||||
{ |
||||
public class MockTestFrameworksWithNUnitFrameworkSupport : NUnitTestFramework, IRegisteredTestFrameworks |
||||
{ |
||||
public ITestFramework GetTestFrameworkForProject(IProject project) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ITestRunner CreateTestRunner(IProject project) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ITestRunner CreateTestDebugger(IProject project) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool IsBuildNeededBeforeTestRunForProject(IProject project) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -1,80 +0,0 @@
@@ -1,80 +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; |
||||
|
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.UnitTesting; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Utils |
||||
{ |
||||
public struct ActionArguments<T> { |
||||
public Action<T> Action; |
||||
public T Arg; |
||||
} |
||||
|
||||
public class MockUnitTestWorkbench : IUnitTestWorkbench |
||||
{ |
||||
public List<Action> SafeThreadAsyncMethodCalls = new List<Action>(); |
||||
public List<object> SafeThreadAsyncMethodCallsWithArguments = |
||||
new List<object>(); |
||||
public bool MakeSafeThreadAsyncMethodCallsWithArguments; |
||||
public bool MakeNonGenericSafeThreadAsyncMethodCalls; |
||||
public List<Type> TypesPassedToGetPadMethod = new List<Type>(); |
||||
public PadDescriptor CompilerMessageViewPadDescriptor; |
||||
public PadDescriptor ErrorListPadDescriptor; |
||||
|
||||
List<PadDescriptor> padDescriptors = new List<PadDescriptor>(); |
||||
|
||||
public MockUnitTestWorkbench() |
||||
{ |
||||
CompilerMessageViewPadDescriptor = new PadDescriptor(typeof(CompilerMessageView), "Output", String.Empty); |
||||
AddPadDescriptor(CompilerMessageViewPadDescriptor); |
||||
|
||||
ErrorListPadDescriptor = new PadDescriptor(typeof(ErrorListPad), "Errors", String.Empty); |
||||
AddPadDescriptor(ErrorListPadDescriptor); |
||||
} |
||||
|
||||
public void AddPadDescriptor(PadDescriptor padDescriptor) |
||||
{ |
||||
padDescriptors.Add(padDescriptor); |
||||
} |
||||
|
||||
public PadDescriptor GetPad(Type type) |
||||
{ |
||||
TypesPassedToGetPadMethod.Add(type); |
||||
|
||||
foreach (PadDescriptor padDescriptor in padDescriptors) { |
||||
if (padDescriptor.Class == type.FullName) { |
||||
return padDescriptor; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public void SafeThreadAsyncCall(Action method) |
||||
{ |
||||
SafeThreadAsyncMethodCalls.Add(method); |
||||
|
||||
if (MakeNonGenericSafeThreadAsyncMethodCalls) { |
||||
method(); |
||||
} |
||||
} |
||||
|
||||
public void SafeThreadAsyncCall<T>(Action<T> method, T arg) |
||||
{ |
||||
ActionArguments<T> actionArgs = new ActionArguments<T>(); |
||||
actionArgs.Action = method; |
||||
actionArgs.Arg = arg; |
||||
|
||||
SafeThreadAsyncMethodCallsWithArguments.Add(actionArgs); |
||||
|
||||
if (MakeSafeThreadAsyncMethodCallsWithArguments) { |
||||
method(arg); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,74 +0,0 @@
@@ -1,74 +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.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace UnitTesting.Tests.Utils |
||||
{ |
||||
public class MockUnitTestsPad : IUnitTestsPad |
||||
{ |
||||
bool updateToolbarMethodCalled; |
||||
bool bringToFrontMethodCalled; |
||||
bool resetTestResultsMethodCalled; |
||||
List<IProject> projects = new List<IProject>(); |
||||
List<TestProject> testProjects = new List<TestProject>(); |
||||
|
||||
public bool IsUpdateToolbarMethodCalled { |
||||
get { return updateToolbarMethodCalled; } |
||||
set { updateToolbarMethodCalled = value; } |
||||
} |
||||
|
||||
public void UpdateToolbar() |
||||
{ |
||||
updateToolbarMethodCalled = true; |
||||
} |
||||
|
||||
public bool IsBringToFrontMethodCalled { |
||||
get { return bringToFrontMethodCalled; } |
||||
} |
||||
|
||||
public void BringToFront() |
||||
{ |
||||
bringToFrontMethodCalled = true; |
||||
} |
||||
|
||||
public bool IsResetTestResultsMethodCalled { |
||||
get { return resetTestResultsMethodCalled; } |
||||
} |
||||
|
||||
public void ResetTestResults() |
||||
{ |
||||
resetTestResultsMethodCalled = true; |
||||
} |
||||
|
||||
public void AddProject(IProject project) |
||||
{ |
||||
projects.Add(project); |
||||
} |
||||
|
||||
public IProject[] GetProjects() |
||||
{ |
||||
return projects.ToArray(); |
||||
} |
||||
|
||||
public TestProject GetTestProject(IProject project) |
||||
{ |
||||
foreach (TestProject testProject in testProjects) { |
||||
if (testProject.Project == project) { |
||||
return testProject; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public void AddTestProject(TestProject testProject) |
||||
{ |
||||
testProjects.Add(testProject); |
||||
} |
||||
|
||||
public void CollapseAll() { } |
||||
} |
||||
} |
Loading…
Reference in new issue