Skip to content

Commit

Permalink
feat: Added unit test templates (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
KreativJos authored May 2, 2022
1 parent 596acc7 commit fb68452
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 11 deletions.
46 changes: 35 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,53 +90,77 @@
{
"command": "csharpextensions.createUwpResourceFile",
"title": "UWP Resource File"
},
{
"command": "csharpextensions.createXUnitTest",
"title": "XUnit Test"
},
{
"command": "csharpextensions.createNUnitTest",
"title": "NUnit Test"
},
{
"command": "csharpextensions.createMSTest",
"title": "MSTest"
}
],
"menus": {
"csharpextensions.new": [
{
"group": "basics@0",
"group": "00_basics@0",
"command": "csharpextensions.createClass"
},
{
"group": "basics@1",
"group": "00_basics@1",
"command": "csharpextensions.createInterface"
},
{
"group": "basics@2",
"group": "00_basics@2",
"command": "csharpextensions.createEnum"
},
{
"group": "basics@3",
"group": "00_basics@3",
"command": "csharpextensions.createStruct"
},
{
"group": "mvc@0",
"group": "10_mvc@0",
"command": "csharpextensions.createController"
},
{
"group": "mvc@1",
"group": "10_mvc@1",
"command": "csharpextensions.createApiController"
},
{
"group": "mvc@2",
"group": "10_mvc@2",
"command": "csharpextensions.createRazorPage"
},
{
"group": "uwp@0",
"group": "20_uwp@0",
"command": "csharpextensions.createUwpPage"
},
{
"group": "uwp@1",
"group": "20_uwp@1",
"command": "csharpextensions.createUwpWindow"
},
{
"group": "uwp@2",
"group": "20_uwp@2",
"command": "csharpextensions.createUwpUserControl"
},
{
"group": "uwp@3",
"group": "20_uwp@3",
"command": "csharpextensions.createUwpResourceFile"
},
{
"group": "30_test@0",
"command": "csharpextensions.createXUnitTest"
},
{
"group": "30_test@1",
"command": "csharpextensions.createNUnitTest"
},
{
"group": "30_test@2",
"command": "csharpextensions.createMSTest"
}
],
"explorer/context": [
Expand Down
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ export class Extension {
'Microsoft.AspNetCore.Mvc.RazorPages',
'Microsoft.Extensions.Logging',
]));
this.KnownTemplates.set('xunit', new CsTemplate('XUnit', 'createXUnitTest', ['XUnit']));
this.KnownTemplates.set('nunit', new CsTemplate('NUnit', 'createNUnitTest', ['NUnit.Framework']));
this.KnownTemplates.set('mstest', new CsTemplate('MSTest', 'createMSTest', ['Microsoft.VisualStudio.TestTools.UnitTesting']));
this.KnownTemplates.set('uwp_page', new XamlTemplate('UWP_Page', 'createUwpPage'));
this.KnownTemplates.set('uwp_window', new XamlTemplate('UWP_Window', 'createUwpWindow'));
this.KnownTemplates.set('uwp_usercontrol', new XamlTemplate('UWP_UserControl', 'createUwpUserControl'));
Expand Down
12 changes: 12 additions & 0 deletions templates/mstest.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
${namespaces}namespace ${namespace}
{
[TestClass]
public class ${classname}
{
[TestMethod]
public void TestMethod1()
{
Assert.IsTrue(true);${cursor}
}
}
}
16 changes: 16 additions & 0 deletions templates/nunit.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
${namespaces}namespace ${namespace}
{
public class ${classname}
{
[SetUp]
public void Setup()
{
}

[Test]
public void Test1()
{
Assert.Pass();${cursor}
}
}
}
11 changes: 11 additions & 0 deletions templates/xunit.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
${namespaces}namespace ${namespace}
{
public class ${classname}
{
[Fact]
public void Test1()
{
Assert.True(true);${cursor}
}
}
}

0 comments on commit fb68452

Please sign in to comment.