提交 adf1abac 编写于 作者: A Allison Chou

Accidentally deleted parts of tests

上级 0a4e552b
......@@ -2815,5 +2815,313 @@ private void NewMethod()
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)]
public Task TestExtractNullableObjectWithExplicitCast()
=> TestInRegularAndScriptAsync(
@"#nullable enable
using System;
class C
{
void M()
{
object? o = null;
var s = (string?)[|o|];
Console.WriteLine(s);
}
}",
@"#nullable enable
using System;
class C
{
void M()
{
object? o = null;
var s = (string?){|Rename:GetO|}(o);
Console.WriteLine(s);
}
private static object? GetO(object? o)
{
return o;
}
}");
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)]
public Task TestExtractNotNullableObjectWithExplicitCast()
=> TestInRegularAndScriptAsync(
@"#nullable enable
using System;
class C
{
void M()
{
object? o = new object();
var s = (string)[|o|];
Console.WriteLine(s);
}
}",
@"#nullable enable
using System;
class C
{
void M()
{
object? o = new object();
var s = (string){|Rename:GetO|}(o);
Console.WriteLine(s);
}
private static object GetO(object o)
{
return o;
}
}");
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)]
public Task TestExtractNotNullableWithExplicitCast()
=> TestInRegularAndScriptAsync(
@"#nullable enable
using System;
class A
{
}
class B : A
{
}
class C
{
void M()
{
B? b = new B();
var s = (A)[|b|];
}
}",
@"#nullable enable
using System;
class A
{
}
class B : A
{
}
class C
{
void M()
{
B? b = new B();
var s = (A){|Rename:GetB|}(b);
}
private static B GetB(B b)
{
return b;
}
}");
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)]
public Task TestExtractNullableWithExplicitCast()
=> TestInRegularAndScriptAsync(
@"#nullable enable
using System;
class A
{
}
class B : A
{
}
class C
{
void M()
{
B? b = null;
var s = (A)[|b|];
}
}",
@"#nullable enable
using System;
class A
{
}
class B : A
{
}
class C
{
void M()
{
B? b = null;
var s = (A){|Rename:GetB|}(b);
}
private static B? GetB(B? b)
{
return b;
}
}");
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)]
public Task TestExtractNotNullableWithExplicitCastSelected()
=> TestInRegularAndScriptAsync(
@"#nullable enable
using System;
class C
{
void M()
{
object? o = new object();
var s = [|(string)o|];
Console.WriteLine(s);
}
}",
@"#nullable enable
using System;
class C
{
void M()
{
object? o = new object();
var s = {|Rename:GetS|}(o);
Console.WriteLine(s);
}
private static string GetS(object o)
{
return (string)o;
}
}");
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)]
public Task TestExtractNullableWithExplicitCastSelected()
=> TestInRegularAndScriptAsync(
@"#nullable enable
using System;
class C
{
void M()
{
object? o = null;
var s = [|(string?)o|];
Console.WriteLine(s);
}
}",
@"#nullable enable
using System;
class C
{
void M()
{
object? o = null;
var s = {|Rename:GetS|}(o);
Console.WriteLine(s);
}
private static string? GetS(object? o)
{
return (string?)o;
}
}");
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)]
public Task TestExtractNullableNonNullFlowWithExplicitCastSelected()
=> TestInRegularAndScriptAsync(
@"#nullable enable
using System;
class C
{
void M()
{
object? o = new object();
var s = [|(string?)o|];
Console.WriteLine(s);
}
}",
@"#nullable enable
using System;
class C
{
void M()
{
object? o = new object();
var s = {|Rename:GetS|}(o);
Console.WriteLine(s);
}
private static string? GetS(object o)
{
return (string?)o;
}
}");
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)]
public Task TestExtractNullableToNonNullableWithExplicitCastSelected()
=> TestInRegularAndScriptAsync(
@"#nullable enable
using System;
class C
{
void M()
{
object? o = null;
var s = [|(string)o|];
Console.WriteLine(s);
}
}",
@"#nullable enable
using System;
class C
{
void M()
{
object? o = null;
var s = {|Rename:GetS|}(o);
Console.WriteLine(s);
}
private static string? GetS(object? o)
{
return (string)o;
}
}");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册