public static void NoFixWhenEndingWithNewLine() { var code = @" namespace N { public static class C { public static void M() { var text = ""↓a\n""; } } }"; var title = @" namespace N { public static class C { public static void M() { var text = ""\n"" + ""a""; } } }"; RoslynAssert.NoRefactoring(Refactoring, code, title); }
public static void WhenNoActionWithSpan() { var code = @" class C { }"; var refactoring = new ClassNameToUpperCaseRefactoringProvider(); RoslynAssert.NoRefactoring(refactoring, code, new TextSpan(8, 3)); RoslynAssert.NoRefactoring(refactoring, code, new TextSpan(8, 3), title: "To uppercase"); }
public static void WhenNoActionWithPositionIndicated() { var code = @" class ↓C { }"; var refactoring = new ClassNameToUpperCaseRefactoringProvider(); RoslynAssert.NoRefactoring(refactoring, code); RoslynAssert.NoRefactoring(refactoring, code, title: "To uppercase"); }
public static void WhenActionIsRegisteredWithSpan() { var code = @" class c { }"; var refactoring = new ClassNameToUpperCaseRefactoringProvider(); var expected = "Expected the refactoring to not register any code actions."; var exception = Assert.Throws <AssertException>(() => RoslynAssert.NoRefactoring(refactoring, code, new TextSpan(8, 3))); Assert.AreEqual(expected, exception.Message); exception = Assert.Throws <AssertException>(() => RoslynAssert.NoRefactoring(refactoring, code, new TextSpan(8, 3), title: "To uppercase")); Assert.AreEqual(expected, exception.Message); }
public void Refactoring_NoId_NoRefactor() { const string code = @" using System; namespace Tests { class Thing { public Thing Related {↓ get; set; } } } "; RoslynAssert.NoRefactoring(Refactoring, code); }
public void Refactoring_NoMappableProperties_DoesNotRefactor() { var code = CodeTemplates.BaseCoreUsings + @" class Test { public int Property { get; set; } } class TestDto { public int UnrelatedProperty { get; set; } } Enumerable.Empty<Test>().Select(x => new TestDto { ↓ }); "; RoslynAssert.NoRefactoring(Refactoring, code); }
public void Refactoring_HasPropertyKey_NoRefactor() { const string code = @" using System; namespace Tests { class Thing { public int Id { get; set; } public Thing Related {↓ get; set; } public int RelatedId { get; set; } } } "; RoslynAssert.NoRefactoring(Refactoring, code); }
public void Refactoring_WithTrackingStatement_RefactorOnlyOppositeTracking(string originalTracking) { var code = TestCode($"context.Things↓.{originalTracking}().ToList();"); RoslynAssert.NoRefactoring(Refactoring, code, TitleFor(originalTracking)); }