Skip to content

Commit

Permalink
Unit-tests have been ported to xUnit from old MSTest
Browse files Browse the repository at this point in the history
  • Loading branch information
3F committed Oct 11, 2019
1 parent a7c9fd2 commit 053a035
Show file tree
Hide file tree
Showing 26 changed files with 805 additions and 901 deletions.
64 changes: 38 additions & 26 deletions .vssbe
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@
"Mode": {
"$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent",
"Type": "Script",
"Command": "#[( $(Configuration) != \"PublicRelease\" ) {\n #[IO replace.Regex(\"$(pDir)/MvsSlnVersion.cs\", \"(\\sS_NUM\\s=).+?\\\";\", \"$1 \\\"$(pVer)\\\";\")]\n}]\n\n#[IO replace.Regex(\"$(pDir)/MvsSln.csproj\", \"<Version>.+?</Version>\", \"<Version>$(pVer)</Version>\")]",
"Command": "#[( ! $(isCIBuild) ) {\n #[IO replace.Regex(\"$(pDir)/MvsSlnVersion.cs\", \"(\\sS_NUM\\s=).+?\\\";\", \"$1 \\\"$(pVer)\\\";\")]\n}]\n\n#[IO replace.Regex(\"$(pDir)/MvsSln.csproj\", \"<Version>.+?</Version>\", \"<Version>$(pVer)</Version>\")]",
"Command__": [
"#[( $(Configuration) != \"PublicRelease\" ) {",
"#[( ! $(isCIBuild) ) {",
" #[IO replace.Regex(\"$(pDir)/MvsSlnVersion.cs\", \"(\\sS_NUM\\s=).+?\\\";\", \"$1 \\\"$(pVer)\\\";\")]",
"}]",
"",
Expand Down Expand Up @@ -393,7 +393,7 @@
"Mode": {
"$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent",
"Type": "Script",
"Command": "#[IO copy.file(\n \"$(SolutionDir)tools/*.*\", \n \"$(odir)/tools/\", \n true, \n {\"*.nuspec\"})]\n\n##[IO copy.file(\"tools/MvsSln.nuspec\", \"$(odir)/MvsSln.nuspec\", true)]\n##[IO copy.file(\"$(pDir)/$(OutputPath:$(pDir))/*.*\", \n \"$(odir)/lib/net$(netstamp)/\", true)]\n\n#[IO copy.file(\n {\"License.txt\", \"3rd-party.txt\", \"Readme.md\", \"changelog.txt\", \".version\", \"$(pDir)/obj/build-info.txt\"}, \n \"$(odir)/\", true\n)]\n\n#[$(_targets = $(TargetFrameworks))]\n#[$(_loop = true)]\n\n#[Box iterate(i = 0; $(_loop); i += 1): \n #[try\n {\n \n #[$(_target = $(_targets.Split(\";\")[$(i)]))]\n \n #[IO copy.file\n (\n \"$(pDir)/$(OutputPath:$(pDir))/$(_target)/*.*\", \n \"$(odir)/lib/$(_target)/\", \n true,\n {\"*.json\"}\n )]\n }\n catch { $(_loop = false) }]\n]\n",
"Command": "#[IO copy.file(\n \"$(SolutionDir)tools/*.*\", \n \"$(odir)/tools/\", \n true, \n {\"*.nuspec\"})]\n\n##[IO copy.file(\"tools/MvsSln.nuspec\", \"$(odir)/MvsSln.nuspec\", true)]\n##[IO copy.file(\"$(pDir)/$(OutputPath:$(pDir))/*.*\", \n \"$(odir)/lib/net$(netstamp)/\", true)]\n\n#[IO copy.file(\n {\"License.txt\", \"3rd-party.txt\", \"Readme.md\", \"changelog.txt\", \".version\", \"$(pDir)/obj/build-info.txt\"}, \n \"$(odir)/\", true\n)]\n\n#[( $(cfgname) == \"Release\" )\n{\n\n #[$(_targets = $(TargetFrameworks))]\n #[$(_loop = true)]\n \n #[Box iterate(i = 0; $(_loop); i += 1): \n #[try\n {\n \n #[$(_target = $(_targets.Split(\";\")[$(i)]))]\n \n #[IO copy.file\n (\n \"$(pDir)/$(OutputPath:$(pDir))/$(_target)/*.*\", \n \"$(odir)/lib/$(_target)/\", \n true,\n {\"*.json\"}\n )]\n }\n catch { $(_loop = false) }]\n ]\n \n}]\n\n",
"Command__": [
"#[IO copy.file(",
" \"$(SolutionDir)tools/*.*\", ",
Expand All @@ -410,25 +410,31 @@
" \"$(odir)/\", true",
")]",
"",
"#[$(_targets = $(TargetFrameworks))]",
"#[$(_loop = true)]",
"#[( $(cfgname) == \"Release\" )",
"{",
"",
"#[Box iterate(i = 0; $(_loop); i += 1): ",
" #[try",
" {",
" #[$(_targets = $(TargetFrameworks))]",
" #[$(_loop = true)]",
" ",
" #[$(_target = $(_targets.Split(\";\")[$(i)]))]",
" #[Box iterate(i = 0; $(_loop); i += 1): ",
" #[try",
" {",
" ",
" #[$(_target = $(_targets.Split(\";\")[$(i)]))]",
" ",
" #[IO copy.file",
" (",
" \"$(pDir)/$(OutputPath:$(pDir))/$(_target)/*.*\", ",
" \"$(odir)/lib/$(_target)/\", ",
" true,",
" {\"*.json\"}",
" )]",
" }",
" catch { $(_loop = false) }]",
" ]",
" ",
" #[IO copy.file",
" (",
" \"$(pDir)/$(OutputPath:$(pDir))/$(_target)/*.*\", ",
" \"$(odir)/lib/$(_target)/\", ",
" true,",
" {\"*.json\"}",
" )]",
" }",
" catch { $(_loop = false) }]",
"]",
"}]",
"",
""
]
}
Expand Down Expand Up @@ -456,20 +462,26 @@
"Mode": {
"$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent",
"Type": "Script",
"Command": "##[IO replace(\"$(odir)/MvsSln.nuspec\", \"{build_info}\", \"$(buildInfo)\")]\n\n##[NuGet gnt.raw(\"/t:pack /p:ngin=\\\"$(odir)\\\" /p:ngout=\\\"$(dbin)\\\"\")]\n\n#[($(revBuild) == \"\" || $(revBuild) ~= \"*\") {\n #[$(zipname = \"MvsSln.$(pVer).zip\")]\n}\nelse {\n #[$(zipname = \"MvsSln.$(pVer).$(revBuild)+$(bSha1).zip\")]\n}]\n\n#[7z pack.directory(\"$(odir)\", \"$(dbin)\\\\$(zipname)\")]\n\n#[IO copy.file\n(\n \"$(pDir)/$(OutputPath:$(pDir))/*$(pVer).nupkg\",\n \"$(dbin)/\", \n true \n)]",
"Command": "##[IO replace(\"$(odir)/MvsSln.nuspec\", \"{build_info}\", \"$(buildInfo)\")]\n\n##[NuGet gnt.raw(\"/t:pack /p:ngin=\\\"$(odir)\\\" /p:ngout=\\\"$(dbin)\\\"\")]\n\n#[( $(cfgname) == \"Release\" )\n{\n \n #[($(revBuild) == \"\" || $(revBuild) ~= \"*\") {\n #[$(zipname = \"MvsSln.$(pVer).zip\")]\n }\n else {\n #[$(zipname = \"MvsSln.$(pVer).$(revBuild)+$(bSha1).zip\")]\n }]\n \n #[7z pack.directory(\"$(odir)\", \"$(dbin)\\\\$(zipname)\")]\n\n}]\n\n\n#[IO copy.file\n(\n \"$(pDir)/$(OutputPath:$(pDir))/*$(pVer).nupkg\",\n \"$(dbin)/\", \n true \n)]",
"Command__": [
"##[IO replace(\"$(odir)/MvsSln.nuspec\", \"{build_info}\", \"$(buildInfo)\")]",
"",
"##[NuGet gnt.raw(\"/t:pack /p:ngin=\\\"$(odir)\\\" /p:ngout=\\\"$(dbin)\\\"\")]",
"",
"#[($(revBuild) == \"\" || $(revBuild) ~= \"*\") {",
" #[$(zipname = \"MvsSln.$(pVer).zip\")]",
"}",
"else {",
" #[$(zipname = \"MvsSln.$(pVer).$(revBuild)+$(bSha1).zip\")]",
"#[( $(cfgname) == \"Release\" )",
"{",
" ",
" #[($(revBuild) == \"\" || $(revBuild) ~= \"*\") {",
" #[$(zipname = \"MvsSln.$(pVer).zip\")]",
" }",
" else {",
" #[$(zipname = \"MvsSln.$(pVer).$(revBuild)+$(bSha1).zip\")]",
" }]",
" ",
" #[7z pack.directory(\"$(odir)\", \"$(dbin)\\\\$(zipname)\")]",
"",
"}]",
"",
"#[7z pack.directory(\"$(odir)\", \"$(dbin)\\\\$(zipname)\")]",
"",
"#[IO copy.file",
"(",
Expand Down
4 changes: 2 additions & 2 deletions 3rd-party.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ MvsSln [ https://github.com/3F/MvsSln ]
* vsSolutionBuildEvent
https://github.com/3F/vsSolutionBuildEvent

* MSTest Framework
https://github.com/microsoft/testfx
* xUnit.net
https://github.com/xunit/xunit

* hMSBuild
https://github.com/3F/hMSBuild
Expand Down
111 changes: 55 additions & 56 deletions MvsSlnTest/Core/ConfigItemTest.cs
Original file line number Diff line number Diff line change
@@ -1,124 +1,123 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using net.r_eg.MvsSln.Core;
using net.r_eg.MvsSln.Core;
using Xunit;

namespace net.r_eg.MvsSlnTest.Core
namespace MvsSlnTest.Core
{
[TestClass]
public class ConfigItemTest
{
[TestMethod]
[Fact]
public void EqTest1()
{
ConfigItem target1 = new ConfigItem("Debug", "Any CPU");

Assert.AreEqual("Debug", target1.Configuration);
Assert.AreEqual("Debug", target1.ConfigurationByRule);
Assert.AreEqual("Any CPU", target1.Platform);
Assert.AreEqual("AnyCPU", target1.PlatformByRule);
Assert.Equal("Debug", target1.Configuration);
Assert.Equal("Debug", target1.ConfigurationByRule);
Assert.Equal("Any CPU", target1.Platform);
Assert.Equal("AnyCPU", target1.PlatformByRule);


Assert.AreEqual(target1, new ConfigItem("Debug", "Any CPU"));
Assert.AreEqual(target1, new ConfigItem("Debug", "AnyCPU"));
Assert.AreEqual(target1, new ConfigItem("deBUG", "anycpu"));
Assert.AreNotEqual(target1, new ConfigItem("Release", "Any CPU"));
Assert.AreNotEqual(target1, new ConfigItem("Debug", "Any CP"));
Assert.Equal(target1, new ConfigItem("Debug", "Any CPU"));
Assert.Equal(target1, new ConfigItem("Debug", "AnyCPU"));
Assert.Equal(target1, new ConfigItem("deBUG", "anycpu"));
Assert.NotEqual(target1, new ConfigItem("Release", "Any CPU"));
Assert.NotEqual(target1, new ConfigItem("Debug", "Any CP"));
}

[TestMethod]
[Fact]
public void EqTest2()
{
var target1 = new ConfigItem("Config1|Platform1");

Assert.AreEqual("Config1", target1.Configuration);
Assert.AreEqual("Platform1", target1.Platform);
Assert.Equal("Config1", target1.Configuration);
Assert.Equal("Platform1", target1.Platform);

var target2 = new ConfigItem(null);

Assert.AreEqual(null, target2.Configuration);
Assert.AreEqual(null, target2.ConfigurationByRule);
Assert.AreEqual(null, target2.Platform);
Assert.AreEqual(null, target2.PlatformByRule);
Assert.Null(target2.Configuration);
Assert.Null(target2.ConfigurationByRule);
Assert.Null(target2.Platform);
Assert.Null(target2.PlatformByRule);

var target3 = new ConfigItem("Config1", "Platform1");
Assert.AreEqual("Config1|Platform1", target3.ToString());
Assert.AreEqual("Config1|Platform1", target3.Format());
Assert.Equal("Config1|Platform1", target3.ToString());
Assert.Equal("Config1|Platform1", target3.Format());
}

[TestMethod]
[Fact]
public void EqRuleTest1()
{
var target = new ConfigItem("Debug", "Any CPU");

Assert.AreEqual("Debug", target.Configuration);
Assert.AreEqual("Debug", target.ConfigurationByRule);
Assert.AreEqual("Any CPU", target.Platform);
Assert.AreEqual("AnyCPU", target.PlatformByRule);
Assert.Equal("Debug", target.Configuration);
Assert.Equal("Debug", target.ConfigurationByRule);
Assert.Equal("Any CPU", target.Platform);
Assert.Equal("AnyCPU", target.PlatformByRule);
}

[TestMethod]
[Fact]
public void EqRuleTest2()
{
Assert.AreEqual(new ConfigItem("Debug", "Platform1"), new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = true });
Assert.AreEqual(new ConfigItem("Debug", "Platform1") { SensitivityComparing = true }, new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = true });
Assert.Equal(new ConfigItem("Debug", "Platform1"), new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = true });
Assert.Equal(new ConfigItem("Debug", "Platform1") { SensitivityComparing = true }, new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = true });

Assert.AreNotEqual(new ConfigItem("Debug", "Platform1"), new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = false });
Assert.AreNotEqual(new ConfigItem("Debug", "Platform1") { SensitivityComparing = false }, new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = false });
Assert.AreNotEqual(new ConfigItem("Debug", "Platform1") { SensitivityComparing = false }, new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = true });
Assert.NotEqual(new ConfigItem("Debug", "Platform1"), new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = false });
Assert.NotEqual(new ConfigItem("Debug", "Platform1") { SensitivityComparing = false }, new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = false });
Assert.NotEqual(new ConfigItem("Debug", "Platform1") { SensitivityComparing = false }, new ConfigItem("deBUG", "platFORM1") { SensitivityComparing = true });
}

[TestMethod]
[Fact]
public void IsEqualByRuleTest1()
{
var target = new ConfigItem("Debug", "Any CPU");

Assert.AreEqual(true, target.IsEqualByRule("Debug", "Any CPU", false));
Assert.AreEqual(false, target.IsEqualByRule("debug", "Any CPU", false));
Assert.True(target.IsEqualByRule("Debug", "Any CPU", false));
Assert.False(target.IsEqualByRule("debug", "Any CPU", false));

Assert.AreEqual(true, target.IsEqualByRule("Debug", "AnyCPU", false));
Assert.AreEqual(false, target.IsEqualByRule("Debug", "Anycpu", false));
Assert.True(target.IsEqualByRule("Debug", "AnyCPU", false));
Assert.False(target.IsEqualByRule("Debug", "Anycpu", false));

Assert.AreEqual(true, target.IsEqualByRule("Debug", "Anycpu", true));
Assert.True(target.IsEqualByRule("Debug", "Anycpu", true));

Assert.AreEqual(false, target.IsEqualByRule(null, null, false));
Assert.AreEqual(false, target.IsEqualByRule(null, null, true));
Assert.False(target.IsEqualByRule(null, null, false));
Assert.False(target.IsEqualByRule(null, null, true));
}

[TestMethod]
[Fact]
public void NoPlatformTest1()
{
var target = new ConfigItem("Config");

Assert.AreEqual("Config", target.Configuration);
Assert.AreEqual(string.Empty, target.Platform);
Assert.Equal("Config", target.Configuration);
Assert.Equal(string.Empty, target.Platform);

target = new ConfigItem("Config|");

Assert.AreEqual("Config", target.Configuration);
Assert.AreEqual(string.Empty, target.Platform);
Assert.Equal("Config", target.Configuration);
Assert.Equal(string.Empty, target.Platform);

target = new ConfigItem("Config| ");

Assert.AreEqual("Config", target.Configuration);
Assert.AreEqual(" ", target.Platform);
Assert.Equal("Config", target.Configuration);
Assert.Equal(" ", target.Platform);
}

[TestMethod]
[Fact]
public void CtorTest1()
{
var target = new ConfigItem("");

Assert.AreEqual(string.Empty, target.Configuration);
Assert.AreEqual(string.Empty, target.Platform);
Assert.Equal(string.Empty, target.Configuration);
Assert.Equal(string.Empty, target.Platform);

target = new ConfigItem(" ");

Assert.AreEqual(" ", target.Configuration);
Assert.AreEqual(string.Empty, target.Platform);
Assert.Equal(" ", target.Configuration);
Assert.Equal(string.Empty, target.Platform);

target = new ConfigItem(null);

Assert.AreEqual(null, target.Configuration);
Assert.AreEqual(null, target.Platform);
Assert.Null(target.Configuration);
Assert.Null(target.Platform);
}
}
}
15 changes: 7 additions & 8 deletions MvsSlnTest/Core/ObjHandlers/WExtensibilityGlobalsTest.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using net.r_eg.MvsSln.Core.ObjHandlers;
using Xunit;

namespace net.r_eg.MvsSlnTest.Core.ObjHandlers
namespace MvsSlnTest.Core.ObjHandlers
{
[TestClass]
public class WExtensibilityGlobalsTest
{
[TestMethod]
[Fact]
public void ExtractTest1()
{
var target = (new WExtensibilityGlobals(null)).Extract(null);
var target = new WExtensibilityGlobals(null).Extract(null);

Assert.AreEqual(String.Empty, target);
Assert.Equal(String.Empty, target);
}

[TestMethod]
[Fact]
public void ExtractTest2()
{
var actual = new Dictionary<string, string>()
Expand All @@ -28,7 +27,7 @@ public void ExtractTest2()
};
var target = (new WExtensibilityGlobals(actual)).Extract(null);

Assert.AreEqual(SlnSamplesResource.Section_WExtensibilityGlobals_Test, target);
Assert.Equal(SlnSamplesResource.Section_WExtensibilityGlobals_Test, target);
}
}
}
Loading

0 comments on commit 053a035

Please sign in to comment.