forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeObjectTestBase.cs
More file actions
68 lines (59 loc) · 2.44 KB
/
CodeObjectTestBase.cs
File metadata and controls
68 lines (59 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Collections.Specialized;
using Xunit;
namespace System.CodeDom.Tests
{
public abstract class CodeObjectTestBase<T> : CodeDomTestBase where T : CodeObject, new()
{
[Fact]
public void Ctor_Default_ObjectBase()
{
CodeObject codeObject = new T();
Assert.Empty(codeObject.UserData);
}
[Fact]
public void UserData_AddMultiple_ReturnsExpected()
{
CodeObject codeObject = new T();
codeObject.UserData.Add("key1", "value");
Assert.Equal(new ListDictionary() { ["key1"] = "value" }, codeObject.UserData);
codeObject.UserData.Add("key2", "value");
Assert.Equal(new ListDictionary() { ["key1"] = "value", ["key2"] = "value" }, codeObject.UserData);
}
}
public abstract class CodeDomTestBase
{
public static IEnumerable<object[]> CodeExpression_TestData()
{
yield return new object[] { null };
yield return new object[] { new CodePrimitiveExpression("Value") };
}
public static IEnumerable<object[]> CodeTypeReference_TestData()
{
yield return new object[] { null };
yield return new object[] { new CodeTypeReference(typeof(int)) };
yield return new object[] { new CodeTypeReference(typeof(int).MakePointerType()) };
yield return new object[] { new CodeTypeReference(typeof(int).MakeByRefType()) };
yield return new object[] { new CodeTypeReference(typeof(List<>)) };
yield return new object[] { new CodeTypeReference(typeof(List<string>)) };
}
public static IEnumerable<object[]> CodeStatement_TestData()
{
yield return new object[] { null };
yield return new object[] { new CodeCommentStatement("Text") };
}
public static IEnumerable<object[]> String_TestData()
{
yield return new object[] { null };
yield return new object[] { "" };
yield return new object[] { "Value" };
}
public static IEnumerable<object[]> LinePragma_TestData()
{
yield return new object[] { null };
yield return new object[] { new CodeLinePragma("FileName", 1) };
}
}
}