-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added code for NUnit 3, and split V2 and V3
- Loading branch information
1 parent
bad30a0
commit f8f5ba8
Showing
14 changed files
with
590 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using Microsoft.VisualStudio.TestPlatform.TestGeneration.Data; | ||
using Microsoft.VisualStudio.TestPlatform.TestGeneration.Model; | ||
|
||
namespace TestGeneration.Extensions.NUnit | ||
{ | ||
/// <summary> | ||
/// The provider for the NUnit 2 unit test framework. | ||
/// </summary> | ||
[Export(typeof(IFrameworkProvider))] | ||
public class NUnit2FrameworkProvider : FrameworkProviderBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NUnit2FrameworkProvider"/> class. | ||
/// </summary> | ||
/// <param name="serviceProvider">The service provider to use to get the interfaces required.</param> | ||
/// <param name="configurationSettings">The configuration settings object to be used to determine how the test method is generated.</param> | ||
/// <param name="naming">The naming object used to decide how projects, classes and methods are named and created.</param> | ||
/// <param name="directory">The directory object to use for directory operations.</param> | ||
[ImportingConstructor] | ||
public NUnit2FrameworkProvider(IServiceProvider serviceProvider, IConfigurationSettings configurationSettings, INaming naming, IDirectory directory) | ||
: base(new NUnit2SolutionManager(serviceProvider, naming, directory), new NUnitUnitTestProjectManager(serviceProvider, naming), new NUnitUnitTestClassManager(configurationSettings, naming)) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets the name of the provider. | ||
/// </summary> | ||
public override string Name => "NUnit2"; | ||
|
||
/// <summary> | ||
/// Gets the name of the assembly. | ||
/// </summary> | ||
public override string AssemblyName => "nunit.framework"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using EnvDTE; | ||
using EnvDTE80; | ||
using Microsoft.VisualStudio.TestPlatform.TestGeneration; | ||
using Microsoft.VisualStudio.TestPlatform.TestGeneration.Data; | ||
using Microsoft.VisualStudio.TestPlatform.TestGeneration.Logging; | ||
using Microsoft.VisualStudio.TestPlatform.TestGeneration.Model; | ||
using VSLangProj80; | ||
|
||
namespace TestGeneration.Extensions.NUnit | ||
{ | ||
public class NUnitSolutionManager : SolutionManagerBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NUnitSolutionManager"/> class. | ||
/// </summary> | ||
/// <param name="serviceProvider">The service provider to use to get the interfaces required.</param> | ||
/// <param name="naming">The naming object used to decide how projects, classes and methods are named and created.</param> | ||
/// <param name="directory">The directory object to use for directory operations.</param> | ||
public NUnitSolutionManager(IServiceProvider serviceProvider, INaming naming, IDirectory directory) | ||
: base(serviceProvider, naming, directory) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Performs any preparatory tasks that have to be done after a new unit test project has been created. | ||
/// </summary> | ||
/// <param name="unitTestProject">The <see cref="Project"/> of the unit test project that has just been created.</param> | ||
/// <param name="sourceMethod">The <see cref="CodeFunction2"/> of the source method that is to be unit tested.</param> | ||
protected override void OnUnitTestProjectCreated(Project unitTestProject, CodeFunction2 sourceMethod) | ||
{ | ||
if (unitTestProject == null) | ||
{ | ||
throw new ArgumentNullException(nameof(unitTestProject)); | ||
} | ||
|
||
TraceLogger.LogInfo("NUnitSolutionManager.OnUnitTestProjectCreated: Adding reference to NUnit assemblies through nuget."); | ||
|
||
base.OnUnitTestProjectCreated(unitTestProject, sourceMethod); | ||
this.EnsureNuGetReference(unitTestProject, "NUnit", "3.0.0-beta-2"); | ||
|
||
var vsp = unitTestProject.Object as VSProject2; | ||
var reference = vsp?.References.Find(GlobalConstants.MSTestAssemblyName); | ||
if (reference != null) | ||
{ | ||
TraceLogger.LogInfo("NUnitSolutionManager.OnUnitTestProjectCreated: Removing reference to {0}", reference.Name); | ||
reference.Remove(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.