public async Task ThatThrowsNothing() { var source = @"using NUnit.Framework; using System; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertThat() { Assert.That(() => Console.WriteLine(""hello""), Throws.Nothing); } } }"; var fixtest = @"using Xunit; using System; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertThat() { new Action(() => Console.WriteLine(""hello"")).Invoke(); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(8, 9).WithArguments("TestAssertThat"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task ThatThrowsInstanceOf() { var source = @"using NUnit.Framework; using System; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertThat() { Assert.That(() => throw new Exception(), Throws.InstanceOf<Exception>()); } } }"; var fixtest = @"using Xunit; using System; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertThat() { Assert.Throws<Exception>(new Action(() => throw new Exception())); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(8, 9).WithArguments("TestAssertThat"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task ThatBoolFuncWithMessage() { var source = @"using NUnit.Framework; using System; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertThat() { Assert.That(() => true, ""error"", ""param""); } } }"; var fixtest = @"using Xunit; using System; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertThat() { Assert.True(new Func<Boolean>(() => true).Invoke()); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(8, 9).WithArguments("TestAssertThat"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task ThatIsFalse() { var source = @"using NUnit.Framework; using System; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertThat() { Assert.That(false, Is.False); } } }"; var fixtest = @"using Xunit; using System; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertThat() { Assert.False(false); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(8, 9).WithArguments("TestAssertThat"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task IsEmptyCollection() { var source = @"using NUnit.Framework; using System.Collections.Generic; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertEmpty() { Assert.IsEmpty(new List<object>(), ""some message"", ""param""); } } }"; var fixtest = @"using Xunit; using System.Collections.Generic; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertEmpty() { Assert.Empty(new List<object>()); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(8, 9).WithArguments("TestAssertEmpty"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task IsAssignableFromTest() { var source = @"using NUnit.Framework; using System; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertIsAssignableFrom() { Assert.IsAssignableFrom<ArgumentNullException>(new Exception(), ""some message""); } } }"; var fixtest = @"using Xunit; using System; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertIsAssignableFrom() { Assert.True(new Exception().GetType().IsAssignableFrom(typeof(ArgumentNullException))); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(8, 9).WithArguments("TestAssertIsAssignableFrom"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task IsNotInstanceOfTest() { var source = @"using NUnit.Framework; using System; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertIsNotInstanceOf() { Assert.IsNotInstanceOf<ArgumentNullException>(new Exception()); } } }"; var fixtest = @"using Xunit; using System; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertIsNotInstanceOf() { Assert.False(new Exception() is ArgumentNullException); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(8, 9).WithArguments("TestAssertIsNotInstanceOf"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task TestAndTestCaseAttributeReplacedWithInlineData() { var source = @"using NUnit.Framework; namespace NUnitToXUnitTests { public class UnitTests { [Test] [TestCase(""value"")] [TestCase(""value1"")] public void TestCase(string value) { } } }"; var fixtest = @"using Xunit; namespace NUnitToXUnitTests { public class UnitTests { [Theory] [InlineData(""value"")] [InlineData(""value1"")] public void TestCase(string value) { } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(7, 9).WithArguments("TestCase"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task AreSame() { var source = @"using NUnit.Framework; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertAreSame() { var o = new object(); Assert.AreSame(o, o, ""some message"", ""param""); } } }"; var fixtest = @"using Xunit; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertAreSame() { var o = new object(); Assert.Same(o, o); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(7, 9).WithArguments("TestAssertAreSame"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task DoesNotThrowBlock() { var source = @"using NUnit.Framework; using System; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertNotThrows() { Assert.DoesNotThrow(() => Console.WriteLine(""hello""), ""some message""); } } }"; var fixtest = @"using Xunit; using System; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertNotThrows() { Console.WriteLine(""hello""); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(8, 9).WithArguments("TestAssertNotThrows"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }
public async Task IsNotEmptyString() { var source = @"using NUnit.Framework; namespace NUnitToXUnitTests { public class UnitTests { [Test] public void TestAssertNotEmpty() { Assert.IsNotEmpty("""", ""some message"", ""param""); } } }"; var fixtest = @"using Xunit; namespace NUnitToXUnitTests { public class UnitTests { [Fact] public void TestAssertNotEmpty() { Assert.NotEqual(string.Empty, """"); } } }"; var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(7, 9).WithArguments("TestAssertNotEmpty"); await VerifyCodeFix.VerifyFixAsync(source, fixtest, expected); }