-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.cs
More file actions
76 lines (67 loc) · 2.18 KB
/
Test.cs
File metadata and controls
76 lines (67 loc) · 2.18 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
69
70
71
72
73
74
75
76
using System;
using System.IO;
using System.Linq;
using CommandForgeGenerator.Generator.CodeGenerate;
using CommandForgeGenerator.Generator.Json;
using CommandForgeGenerator.Generator.Semantic;
using UnityEngine;
using Xunit;
namespace CommandForgeGenerator.Tests;
public class Test
{
[Fact]
public void JsonTokenizerTest()
{
var json = """
{
"hoge": "fuga",
"piyo": [
"puyo",
"poyo"
]
}
""";
Token[] answer =
[
new(TokenType.LBrace, "{"),
new(TokenType.String, "hoge"),
new(TokenType.Colon, ":"),
new(TokenType.String, "fuga"),
new(TokenType.Comma, ","),
new(TokenType.String, "piyo"),
new(TokenType.Colon, ":"),
new(TokenType.LSquare, "["),
new(TokenType.String, "puyo"),
new(TokenType.Comma, ","),
new(TokenType.String, "poyo"),
new(TokenType.RSquare, "]"),
new(TokenType.RBrace, "}")
];
var tokens = JsonTokenizer.GetTokens(json);
Assert.Equivalent(tokens, answer, true);
}
[Fact]
public void JsonParserTest()
{
var json = """
{
"hoge": "fuga",
"piyo": [
"puyo",
"poyo"
]
}
""";
}
[Fact]
public void GenerateTest()
{
var yaml = GenerateTestCode.YamlFileStr;
var commandsSchema = CommandSemanticsLoader.GetCommandSemantics(yaml);
var codeFiles = CodeGenerator.Generate(commandsSchema);
var file = codeFiles.FirstOrDefault(c => c.FileName == "TextCommand.g.cs").Code;
//File.WriteAllText("/Users/katsumi.sato/Desktop/a/TextCommand.g.cs", file);
Assert.Equal(17, codeFiles.Count);
Assert.Equal(GenerateTestCode.TextCommandStr, codeFiles.FirstOrDefault(c => c.FileName == "TextCommand.g.cs").Code);
}
}