Example #1
0
        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);
        }
Example #2
0
            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");
            }
Example #3
0
            public static void WhenNoActionWithPositionIndicated()
            {
                var code = @"
class ↓C
{
}";

                var refactoring = new ClassNameToUpperCaseRefactoringProvider();

                RoslynAssert.NoRefactoring(refactoring, code);
                RoslynAssert.NoRefactoring(refactoring, code, title: "To uppercase");
            }
Example #4
0
            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);
            }
Example #5
0
        public void Refactoring_NoId_NoRefactor()
        {
            const string code = @"
using System;
namespace Tests
{
    class Thing
    {
        public Thing Related {↓ get; set; }
    }
}
";

            RoslynAssert.NoRefactoring(Refactoring, code);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        public void Refactoring_WithTrackingStatement_RefactorOnlyOppositeTracking(string originalTracking)
        {
            var code = TestCode($"context.Things↓.{originalTracking}().ToList();");

            RoslynAssert.NoRefactoring(Refactoring, code, TitleFor(originalTracking));
        }