提交 1395a762 编写于 作者: J Julien Couvreur 提交者: GitHub

Adding some refactoring tests with tuples (#16663)

上级 85501ae9
......@@ -267,6 +267,56 @@ public Foo()
index: 2);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)]
public async Task TestGenerateClassWithCtorFromObjectCreationWithTuple()
{
await TestAsync(
@"class Class
{
var f = new [|Generated|]((1, 2));
}",
@"class Class
{
var f = new Generated((1, 2));
private class Generated
{
private (int, int) p;
public Generated((int, int) p)
{
this.p = p;
}
}
}",
index: 2);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)]
public async Task TestGenerateClassWithCtorFromObjectCreationWithTupleWithNames()
{
await TestAsync(
@"class Class
{
var f = new [|Generated|]((a: 1, b: 2, 3));
}",
@"class Class
{
var f = new Generated((a: 1, b: 2, 3));
private class Generated
{
private (int a, int b, int) p;
public Generated((int a, int b, int) p)
{
this.p = p;
}
}
}",
index: 2);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)]
public async Task TestGenerateClassFromBaseList()
{
......
......@@ -105,6 +105,35 @@ protected override string FooMethod()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)]
[WorkItem(16434, "https://github.com/dotnet/roslyn/issues/16434")]
public async Task TestMethodWithTupleNames()
{
await TestAllOptionsOffAsync(
@"abstract class Base
{
protected abstract (int a, int b) Method((string, string d) x);
}
class [|Program|] : Base
{
}",
@"using System;
abstract class Base
{
protected abstract (int a, int b) Method((string, string d) x);
}
class Program : Base
{
protected override (int a, int b) Method((string, string d) x)
{
throw new NotImplementedException();
}
}");
}
[WorkItem(543234, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543234")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)]
public async Task TestNotAvailableForStruct()
......
......@@ -113,6 +113,34 @@ public void Method1()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
public async Task TestMethodWithTuple()
{
await TestWithAllCodeStyleOptionsOffAsync(
@"interface IInterface
{
(int, int) Method((string, string) x);
}
class Class : [|IInterface|]
{
}",
@"using System;
interface IInterface
{
(int, int) Method((string, string) x);
}
class Class : IInterface
{
public (int, int) Method((string, string) x)
{
throw new NotImplementedException();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
public async Task TestExpressionBodiedMethod1()
{
......
......@@ -124,6 +124,46 @@ End Class",
index:=2)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)>
Public Async Function TestGenerateClassWithCtorFromObjectCreationWithTuple() As Task
Await TestAsync(
"Class C
Dim f = New [|Generated|]((1, 2))
End Class",
"Class C
Dim f = New Generated((1, 2))
Private Class Generated
Private p As (Integer, Integer)
Public Sub New(p As (Integer, Integer))
Me.p = p
End Sub
End Class
End Class",
index:=2)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)>
Public Async Function TestGenerateClassWithCtorFromObjectCreationWithTupleWithNames() As Task
Await TestAsync(
"Class C
Dim f = New [|Generated|]((a:=1, b:=2, 3))
End Class",
"Class C
Dim f = New Generated((a:=1, b:=2, 3))
Private Class Generated
Private p As (a As Integer, b As Integer, Integer)
Public Sub New(p As (a As Integer, b As Integer, Integer))
Me.p = p
End Sub
End Class
End Class",
index:=2)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)>
Public Async Function TestCreateException() As Task
Await TestAsync(
......
......@@ -39,6 +39,27 @@ Public Class Bar
End Class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)>
Public Async Function TestMethodWithTupleNames() As Task
Await TestAsync(
"Public MustInherit Class Base
Protected MustOverride Function Bar(x As (a As Integer, Integer)) As (c As Integer, Integer)
End Class
Public Class [|Derived|]
Inherits Base
End Class",
"Imports System
Public MustInherit Class Base
Protected MustOverride Function Bar(x As (a As Integer, Integer)) As (c As Integer, Integer)
End Class
Public Class Derived
Inherits Base
Protected Overrides Function Bar(x As (a As Integer, Integer)) As (c As Integer, Integer)
Throw New NotImplementedException()
End Function
End Class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)>
Public Async Function TestOptionalIntParameter() As Task
Await TestAsync(
......
......@@ -35,6 +35,28 @@ Class C
End Class")
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Async Function TestInterfaceWithTuple() As Task
Await TestAsync(
"Imports System
Class Foo
Implements [|IFoo|]
End Class
Interface IFoo
Function Method(x As (Alice As Integer, Bob As Integer)) As (String, String)
End Interface",
"Imports System
Class Foo
Implements IFoo
Public Function Method(x As (Alice As Integer, Bob As Integer)) As (String, String) Implements IFoo.Method
Throw New NotImplementedException()
End Function
End Class
Interface IFoo
Function Method(x As (Alice As Integer, Bob As Integer)) As (String, String)
End Interface")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Async Function TestMethodConflict1() As Task
Await TestAsync(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册