-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleMethodWithParameter.cs
More file actions
46 lines (37 loc) · 1.55 KB
/
SimpleMethodWithParameter.cs
File metadata and controls
46 lines (37 loc) · 1.55 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
using EasySourceGenerators.Abstractions;
namespace EasySourceGenerators.Tests;
public class SimpleMethodWithParameterTests
{
[Test]
public void ColorsClassLikeGenerator_ProducesExpectedRuntimeOutput()
{
SimpleMethodWithParameterClass testColorsClass = new SimpleMethodWithParameterClass();
int result = testColorsClass.SimpleMethodWithParameter(123123);
Assert.That(result, Is.EqualTo(5));
}
[Test]
public void ColorsClassLikeGenerator_ProducesExpectedGeneratedCode()
{
string generatedCode = GeneratedCodeTestHelper.ReadGeneratedCode("SimpleMethodWithParameterClass_SimpleMethodWithParameter.g.cs");
string expectedCode = """
namespace EasySourceGenerators.Tests;
partial class SimpleMethodWithParameterClass
{
public partial int SimpleMethodWithParameter(int someIntParameter)
{
return 5;
}
}
""".ReplaceLineEndings("\n").TrimEnd();
Assert.That(generatedCode, Is.EqualTo(expectedCode));
}
}
public partial class SimpleMethodWithParameterClass
{
public partial int SimpleMethodWithParameter(int someIntParameter);
[GeneratesMethod(sameClassMethodName: nameof(SimpleMethodWithParameter))]
private static int SimpleMethodWithParameter_Generator(int someIntParameter)
{
return 5;
}
}