-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCallStatementTests.cs
More file actions
37 lines (29 loc) · 1.17 KB
/
Copy pathCallStatementTests.cs
File metadata and controls
37 lines (29 loc) · 1.17 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
using System.Text;
using Cutout.Tests.Extensions;
namespace Cutout.Tests;
public static partial class CallTemplates
{
public sealed record Product(string Title);
private const string CallExample1 = "Some text before {{ call Case2(product.Title) }}";
[Template(CallExample1)]
public static partial void Case1(this StringBuilder builder, Product product);
private const string CallExample2 = "The product title is {{ title }}";
[Template(CallExample2)]
public static partial void Case2(this StringBuilder builder, string title);
}
public sealed class CallStatementTests
{
[Fact(DisplayName = "A call statement can used")]
public void Case1()
{
var builder = new StringBuilder();
builder.Case1(new CallTemplates.Product("Awesome Shoes"));
Assert.Equal("Some text before The product title is Awesome Shoes", builder.ToString());
}
[Fact(DisplayName = "Case1 produces the expected source")]
public Task Case1a() =>
"""
[Template("Some text before {{ call Case2(product) }}")]
public static partial void Test(this StringBuilder builder, string product);
""".VerifyTemplate();
}