Browse Source

Fixed context action unit tests.

newNRvisualizers
mike 14 years ago
parent
commit
e93009afee
  1. 4
      ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs
  2. 6
      ICSharpCode.NRefactory.CSharp/Refactoring/ContextAction/AddAnotherAccessor.cs
  3. 6
      ICSharpCode.NRefactory.CSharp/Refactoring/ContextAction/InvertIf.cs
  4. 2
      ICSharpCode.NRefactory.Tests/CSharp/ContextAction/AddAnotherAccessorTests.cs
  5. 1
      ICSharpCode.NRefactory.Tests/CSharp/ContextAction/GenerateGetterTests.cs
  6. 1
      ICSharpCode.NRefactory.Tests/CSharp/ContextAction/GeneratePropertyTests.cs
  7. 1
      ICSharpCode.NRefactory.Tests/CSharp/ContextAction/InvertIfTests.cs
  8. 8
      ICSharpCode.NRefactory.Tests/CSharp/ContextAction/RemoveBracesTests.cs

4
ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs

@ -74,7 +74,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -74,7 +74,6 @@ namespace ICSharpCode.NRefactory.CSharp
return new UnaryOperatorExpression (UnaryOperatorType.Not, new ParenthesizedExpression (condition));
}
}
if (condition is ConditionalExpression) {
var cEx = condition as ConditionalExpression;
cEx.Condition = InvertCondition (cEx.Condition);
@ -83,8 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -83,8 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (condition is PrimitiveExpression) {
var pex = condition as PrimitiveExpression;
if (pex.Value is bool) {
pex.Value = !((bool)pex.Value);
return pex;
return new PrimitiveExpression (!((bool)pex.Value));
}
}

6
ICSharpCode.NRefactory.CSharp/Refactoring/ContextAction/AddAnotherAccessor.cs

@ -56,7 +56,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -56,7 +56,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
accessor.Role = pdecl.Setter.IsNull ? PropertyDeclaration.SetterRole : PropertyDeclaration.GetterRole;
using (var script = context.StartScript ()) {
script.InsertBefore (pdecl.RBraceToken, accessor);
if (pdecl.Setter.IsNull && !pdecl.Getter.IsNull) {
script.InsertBefore (pdecl.RBraceToken, accessor);
} else {
script.InsertBefore (pdecl.Getter, accessor);
}
script.Select (accessorStatement);
script.FormatText (pdecl);
}

6
ICSharpCode.NRefactory.CSharp/Refactoring/ContextAction/InvertIf.cs

@ -44,9 +44,9 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -44,9 +44,9 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
var ifStatement = GetIfElseStatement (context);
using (var script = context.StartScript ()) {
script.Replace (ifStatement.Condition, CSharpUtil.InvertCondition (ifStatement.Condition));
script.Replace (ifStatement.TrueStatement, ifStatement.FalseStatement);
script.Replace (ifStatement.FalseStatement, ifStatement.TrueStatement);
script.Replace (ifStatement.Condition, CSharpUtil.InvertCondition (ifStatement.Condition.Clone ()));
script.Replace (ifStatement.TrueStatement, ifStatement.FalseStatement.Clone ());
script.Replace (ifStatement.FalseStatement, ifStatement.TrueStatement.Clone ());
script.FormatText (ifStatement);
}
}

2
ICSharpCode.NRefactory.Tests/CSharp/ContextAction/AddAnotherAccessorTests.cs

@ -33,7 +33,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -33,7 +33,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
[TestFixture]
public class AddAnotherAccessorTests : ContextActionTestBase
{
[Ignore("Format action is not implemented.")]
[Test()]
public void TestAddSet ()
{
@ -65,7 +64,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -65,7 +64,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
"}", result);
}
[Ignore("Format action is not implemented.")]
[Test()]
public void TestAddGet ()
{

1
ICSharpCode.NRefactory.Tests/CSharp/ContextAction/GenerateGetterTests.cs

@ -33,7 +33,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -33,7 +33,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
[TestFixture]
public class GenerateGetterTests : ContextActionTestBase
{
[Ignore("Insert with cursor is not implemented.")]
[Test()]
public void Test ()
{

1
ICSharpCode.NRefactory.Tests/CSharp/ContextAction/GeneratePropertyTests.cs

@ -32,7 +32,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -32,7 +32,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
[TestFixture]
public class GeneratePropertyTests : ContextActionTestBase
{
[Ignore("Insert with cursor is not implemented.")]
[Test()]
public void Test ()
{

1
ICSharpCode.NRefactory.Tests/CSharp/ContextAction/InvertIfTests.cs

@ -33,7 +33,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -33,7 +33,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
[TestFixture]
public class InvertIfTestsTests : ContextActionTestBase
{
[Ignore("Formatting not implemented in test context")]
[Test()]
public void Test ()
{

8
ICSharpCode.NRefactory.Tests/CSharp/ContextAction/RemoveBracesTests.cs

@ -32,7 +32,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -32,7 +32,6 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
[TestFixture]
public class RemoveBracesTests : ContextActionTestBase
{
[Ignore("Formatting not implemented in test context")]
[Test()]
public void TestSimpleBraces ()
{
@ -42,8 +41,8 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -42,8 +41,8 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
"{" + Environment.NewLine +
" void Test ()" + Environment.NewLine +
" {" + Environment.NewLine +
" if (true) ${" + Environment.NewLine +
" ;" + Environment.NewLine +
" if (true) ${" + Environment.NewLine +
" ;" + Environment.NewLine +
" }" + Environment.NewLine +
" }" + Environment.NewLine +
"}"
@ -54,7 +53,8 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -54,7 +53,8 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
"{" + Environment.NewLine +
" void Test ()" + Environment.NewLine +
" {" + Environment.NewLine +
" ;" + Environment.NewLine +
" if (true) " + Environment.NewLine +
" ;" + Environment.NewLine +
" }" + Environment.NewLine +
"}", result);
}

Loading…
Cancel
Save