Skip to content

Instantly share code, notes, and snippets.

@GeorgDangl
Created May 25, 2017 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeorgDangl/7e3b786f2973b72bbae17974e7d33c54 to your computer and use it in GitHub Desktop.
Save GeorgDangl/7e3b786f2973b72bbae17974e7d33c54 to your computer and use it in GitHub Desktop.
Migrating MSTest to xUnit
Param(
[string ]$ProjectDir
)
get-childitem $ProjectDir -recurse -include *.cs |
select -expand fullname |
foreach {
( Get-Content $_ ) -replace '\[TestMethod\]','[Fact]' `
-replace 'Assert.AreEqual' , 'Assert.Equal' `
-replace 'Assert.AreNotEqual' , 'Assert.NotEqual' `
-replace 'Assert.IsTrue' , 'Assert.True' `
-replace 'Assert.IsFalse' , 'Assert.False' `
-replace 'Assert.IsNotNull' , 'Assert.NotNull' `
-replace 'Assert.IsNull' , 'Assert.Null' `
-replace '\[TestClass\]' , ' ' `
-replace 'Assert.AreNotSame' , 'Assert.NotSame' `
-replace 'Assert.AreSame' , 'Assert.Same' `
-replace 'Assert.IsInstanceOfType' , 'Assert.IsType' `
-replace 'Assert.IsNotInstanceOfType' , 'Assert.IsNotType' `
-replace 'using Microsoft.VisualStudio.TestTools.UnitTesting' , 'using Xunit' `
| Set-Content -Encoding utf8 $_
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment