-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathNameOfTests.cs
21 lines (20 loc) · 1.28 KB
/
NameOfTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using Cecilifier.Core.Tests.Tests.Unit.Framework;
using NUnit.Framework;
namespace Cecilifier.Core.Tests.Tests.Unit
{
[TestFixture]
public class NameOfTests : CecilifierUnitTestBase
{
[TestCase("class Foo { [System.Obsolete(nameof(parameter))] void M(int parameter) {} }", "new CustomAttributeArgument(assembly.MainModule.TypeSystem.String, \"parameter\")", TestName = "Parameter")]
[TestCase("using System; [Obsolete(nameof(Foo))] public class Foo { }", "new CustomAttributeArgument(assembly.MainModule.TypeSystem.String, \"Foo\")", TestName = "Attribute")]
[TestCase("public class Foo { string ConstString = nameof(ConstString); }", "Ldstr, \"ConstString\"", TestName = "Field Initialization")]
[TestCase("public class Foo { string Name() => nameof(Name); }", "Ldstr, \"Name\"", TestName = "Method Return")]
[TestCase("public class Foo { string StringInterpolation() => $\"Name={nameof(StringInterpolation)}\"; }", "Ldstr, \"Name={0}\"", TestName = "String Interpolation")]
public void Test(string code, string expectedLiteral)
{
var result = RunCecilifier(code);
var cecilifiedCode = result.GeneratedCode.ReadToEnd();
Assert.That(cecilifiedCode, Contains.Substring(expectedLiteral));
}
}
}