提交 71480989 编写于 作者: C CyrusNajmabadi

Add C# tests.

上级 4d62bd69
......@@ -2150,6 +2150,52 @@ public void PreviousSubmissionWithError()
Assert.Throws<InvalidOperationException>(() => CreateSubmission("a + 1", previous: s0));
}
[Fact()]
public void CreateAnonymousType_IncorrectLengths()
{
var compilation = CSharpCompilation.Create("HelloWorld");
Assert.Throws<ArgumentException>(() =>
compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create((ITypeSymbol)null),
ImmutableArray.Create("m1", "m2")));
}
[Fact()]
public void CreateAnonymousType_NothingArgument()
{
var compilation = CSharpCompilation.Create("HelloWorld");
Assert.Throws<ArgumentNullException>(() =>
compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create((ITypeSymbol)null),
ImmutableArray.Create("m1")));
}
[Fact()]
public void CreateAnonymousType1()
{
var compilation = CSharpCompilation.Create("HelloWorld");
var type = compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create<ITypeSymbol>(compilation.GetSpecialType(SpecialType.System_Int32)),
ImmutableArray.Create("m1"));
Assert.True(type.IsAnonymousType);
Assert.Equal(1, type.GetMembers().OfType<IPropertySymbol>().Count());
Assert.Equal("<anonymous type: int m1>", type.ToDisplayString());
}
[Fact()]
public void CreateAnonymousType2()
{
var compilation = CSharpCompilation.Create("HelloWorld");
var type = compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create<ITypeSymbol>(compilation.GetSpecialType(SpecialType.System_Int32), compilation.GetSpecialType(SpecialType.System_Boolean)),
ImmutableArray.Create("m1", "m2"));
Assert.True(type.IsAnonymousType);
Assert.Equal(2, type.GetMembers().OfType<IPropertySymbol>().Count());
Assert.Equal("<anonymous type: int m1, bool m2>", type.ToDisplayString());
}
#region Script return values
[Fact]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册