Skip to content

Instantly share code, notes, and snippets.

@Pondidum
Last active April 5, 2017 07:27
Show Gist options
  • Select an option

  • Save Pondidum/46ae629aaec4398d312f69ff8b8a0f6a to your computer and use it in GitHub Desktop.

Select an option

Save Pondidum/46ae629aaec4398d312f69ff8b8a0f6a to your computer and use it in GitHub Desktop.
#!/bin/bash
for file in $(find $1 *.cs -type f);
do
sed -b -i -r \
-e 's/using Microsoft.VisualStudio.TestTools.UnitTesting;/using Xunit;/g' \
-e 's/\[TestMethod\]/\[Fact\]/g' \
-e '/\[TestClass\]/d' \
-e '/\[TestCategory.*/d' \
-e '/\[Category.*/d' \
-e 's/Assert.IsInstanceOfType\((.*), typeof\((.*)\), "(.*)"\);/\1.ShouldBeOfType<\2>("\3");/g' \
-e 's/Assert.IsInstanceOfType\((.*), typeof\((.*)\)\);/\1.ShouldBeOfType<\2>();/g' \
-e 's/Assert.IsInstanceOfType\((.*), typeof\((.*)\), (.*)\);/\1.ShouldBeOfType<\2>(\3);/g' \
-e 's/Assert.IsTrue\((.*) > (.*)\);/\1.ShouldBeGreaterThan(\2);/g' \
-e 's/Assert.IsTrue\((.*) < (.*)\);/\1.ShouldBeLessThan(\2);/g' \
-e 's/Assert.IsTrue\((.*) >= (.*)\);/\1.ShouldBeGreaterThanOrEqualTo(\2);/g' \
-e 's/Assert.IsTrue\((.*) <= (.*)\);/\1.ShouldBeLessThanOrEqualTo(\2);/g' \
-e 's/Assert.IsTrue\((.*), "(.*)"\);/\1.ShouldBeTrue("\2");/g' \
-e 's/Assert.IsFalse\((.*), "(.*)"\);/\1.ShouldBeFalse("\2");/g' \
-e 's/Assert.IsTrue\((.*)\);/\1.ShouldBeTrue();/g' \
-e 's/Assert.IsFalse\((.*)\);/\1.ShouldBeFalse();/g' \
-e 's/Assert.AreEqual\(false, (.*)\);/\1.ShouldBeFalse();/g' \
-e 's/Assert.AreEqual\(true, (.*)\);/\1.ShouldBeTrue();/g' \
-e 's/Assert.IsNull\((.*), "(.*)"\);/\1.ShouldBeNull("\2");/g' \
-e 's/Assert.IsNull\((.*)\);/\1.ShouldBeNull();/g' \
-e 's/Assert.IsNotNull\((.*), "(.*)"\);/\1.ShouldNotBeNull("\2");/g' \
-e 's/Assert.IsNotNull\((.*)\);/\1.ShouldNotBeNull();/g' \
-e 's/Assert.AreEqual\((.*), (.*), "(.*)"\);/\2.ShouldBe(\1, "\3");/g' \
"$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment