Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/tests/UnitTests/MonoDevelop.CSharpBinding/UnitTesteditorIntegrationTests.cs')
-rw-r--r--main/tests/UnitTests/MonoDevelop.CSharpBinding/UnitTesteditorIntegrationTests.cs81
1 files changed, 61 insertions, 20 deletions
diff --git a/main/tests/UnitTests/MonoDevelop.CSharpBinding/UnitTesteditorIntegrationTests.cs b/main/tests/UnitTests/MonoDevelop.CSharpBinding/UnitTesteditorIntegrationTests.cs
index 9a7e8e1077..237e7e08de 100644
--- a/main/tests/UnitTests/MonoDevelop.CSharpBinding/UnitTesteditorIntegrationTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.CSharpBinding/UnitTesteditorIntegrationTests.cs
@@ -25,13 +25,16 @@
// THE SOFTWARE.
using System;
-using System.Collections;
using MonoDevelop.Ide.Gui;
using System.Collections.Generic;
-using Mono.Addins;
using NUnit.Framework;
using MonoDevelop.CSharp;
+using System.Threading;
+using MonoDevelop.Projects;
+using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.Ide;
+using MonoDevelop.Core.ProgressMonitoring;
namespace MonoDevelop.CSharpBinding.Tests
{
@@ -40,19 +43,18 @@ namespace MonoDevelop.CSharpBinding.Tests
{
static UnitTestTextEditorExtension Setup (string input, out TestViewContent content)
{
- TestWorkbenchWindow tww = new TestWorkbenchWindow ();
+ var tww = new TestWorkbenchWindow ();
content = new TestViewContent ();
tww.ViewContent = content;
- content.ContentName = "a.cs";
- content.GetTextEditorData ().Document.MimeType = "text/x-csharp";
-
- Document doc = new Document (tww);
+ content.ContentName = "/a.cs";
+ content.Data.MimeType = "text/x-csharp";
+ MonoDevelop.AnalysisCore.AnalysisOptions.EnableUnitTestEditorIntegration.Set (true);
+ var doc = new Document (tww);
var text = @"namespace NUnit.Framework {
- using System;
- class TestFixtureAttribute : Attribute {}
- class TestAttribute : Attribute {}
-} namespace Test { " + input +"}";
+ public class TestFixtureAttribute : System.Attribute {}
+ public class TestAttribute : System.Attribute {}
+} namespace TestNs { " + input +"}";
int endPos = text.IndexOf ('$');
if (endPos >= 0)
text = text.Substring (0, endPos) + text.Substring (endPos + 1);
@@ -60,28 +62,46 @@ namespace MonoDevelop.CSharpBinding.Tests
content.Text = text;
content.CursorPosition = System.Math.Max (0, endPos);
+ var project = new DotNetAssemblyProject (Microsoft.CodeAnalysis.LanguageNames.CSharp);
+ project.Name = "test";
+ project.FileName = "test.csproj";
+ project.Files.Add (new ProjectFile ("/a.cs", BuildAction.Compile));
+
+ var solution = new Solution ();
+ solution.AddConfiguration ("", true);
+ solution.DefaultSolutionFolder.AddItem (project);
+ using (var monitor = new NullProgressMonitor ())
+ TypeSystemService.Load (solution, monitor, false);
+ content.Project = project;
+ doc.SetProject (project);
var compExt = new UnitTestTextEditorExtension ();
- compExt.Initialize (doc);
+ compExt.Initialize (doc.Editor, doc);
content.Contents.Add (compExt);
-
doc.UpdateParseDocument ();
+ TypeSystemService.Unload (solution);
return compExt;
}
+ protected override void InternalSetup (string rootDir)
+ {
+ base.InternalSetup (rootDir);
+ IdeApp.Initialize (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor ());
+ }
+
[Test]
public void TestSimple ()
{
TestViewContent content;
var ext = Setup (@"using NUnit.Framework;
[TestFixture]
-class Test
+class TestClass
{
[Test]
public void MyTest () {}
}
", out content);
- var tests = ext.GatherUnitTests ();
+ var tests = ext.GatherUnitTests (default(CancellationToken)).Result;
Assert.IsNotNull (tests);
Assert.AreEqual (2, tests.Count);
}
@@ -91,12 +111,12 @@ class Test
{
TestViewContent content;
var ext = Setup (@"using NUnit.Framework;
-class Test
+class TestClass
{
public void MyTest () {}
}
", out content);
- var tests = ext.GatherUnitTests ();
+ var tests = ext.GatherUnitTests (default(CancellationToken)).Result;
Assert.IsNotNull (tests);
Assert.AreEqual (0, tests.Count);
}
@@ -122,13 +142,34 @@ public class Derived : MyBase
public void MyTest () {}
}
", out content);
- var tests = ext.GatherUnitTests ();
+ var tests = ext.GatherUnitTests (default(CancellationToken)).Result;
Assert.IsNotNull (tests);
Assert.AreEqual (2, tests.Count);
- Assert.AreEqual ("Test.Derived", tests [0].UnitTestIdentifier);
- Assert.AreEqual ("Test.Derived.MyTest", tests [1].UnitTestIdentifier);
+ Assert.AreEqual ("TestNs.Derived", tests [0].UnitTestIdentifier);
+ Assert.AreEqual ("TestNs.Derived.MyTest", tests [1].UnitTestIdentifier);
}
+
+
+ /// <summary>
+ /// Bug 19651 - Should not require [TestFixture] for Unit Test Integration
+ /// </summary>
+ [Test]
+ public void TestBug19651 ()
+ {
+ TestViewContent content;
+ var ext = Setup (@"using NUnit.Framework;
+class TestClass
+{
+ [Test]
+ public void MyTest () {}
+}
+", out content);
+ var tests = ext.GatherUnitTests (default(CancellationToken)).Result;
+ Assert.IsNotNull (tests);
+ Assert.AreEqual (2, tests.Count);
+ }
+
}
}