void TestBackingStore(string inputString, string outputString)
        {
            RemoveBackingStore refactoring = new RemoveBackingStore();
            RefactoringOptions options     = ExtractMethodTests.CreateRefactoringOptions(inputString);
            List <Change>      changes     = refactoring.PerformChanges(options, null);
            string             output      = ExtractMethodTests.GetOutput(options, changes);

            Assert.IsTrue(ExtractMethodTests.CompareSource(output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output);
        }
Exemplo n.º 2
0
        static Statement BuildAccessorStatement(RefactoringContext context, PropertyDeclaration pdecl)
        {
            if (pdecl.Setter.IsNull && !pdecl.Getter.IsNull)
            {
                var field = RemoveBackingStore.ScanGetter(context, pdecl);
                if (field != null)
                {
                    return(new ExpressionStatement(new AssignmentExpression(new IdentifierExpression(field.Name), AssignmentOperatorType.Assign, new IdentifierExpression("value"))));
                }
            }

            if (!pdecl.Setter.IsNull && pdecl.Getter.IsNull)
            {
                var field = RemoveBackingStore.ScanSetter(context, pdecl);
                if (field != null)
                {
                    return(new ReturnStatement(new IdentifierExpression(field.Name)));
                }
            }

            return(new ThrowStatement(new ObjectCreateExpression(context.CreateShortType("System", "NotImplementedException"))));
        }