File tree Expand file tree Collapse file tree
CommandForgeGenerator.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #if ENABLE_COMMAND_FORGE_GENERATOR
2+ namespace CommandForgeGenerator . Command
3+ {
4+ public partial class TextCommand : ICommandForgeCommand
5+ {
6+ public const string Type = "text" ;
7+ public readonly CommandId CommandId ;
8+
9+ public readonly string Character ;
10+ public readonly string Body ;
11+
12+
13+ public static TextCommand Create ( int commandId , global ::Newtonsoft . Json . Linq . JToken json )
14+ {
15+
16+ var Character = ( string ) json [ "character" ] ;
17+ var Body = ( string ) json [ "body" ] ;
18+
19+
20+ return new TextCommand ( commandId , Character , Body ) ;
21+ }
22+
23+ public TextCommand ( int commandId , string Character , string Body )
24+ {
25+ CommandId = ( CommandId ) commandId ;
26+
27+ this . Character = Character ;
28+ this . Body = Body ;
29+
30+ }
31+ }
32+ }
33+ #endif
Original file line number Diff line number Diff line change 1+ namespace CommandForgeGenerator . Command ;
2+
3+ // 他の生成結果サンプルコマンドをコンパイルエラーにしないためのコード
4+
5+ public interface ICommandForgeCommand { }
6+ public enum CommandId { }
Original file line number Diff line number Diff line change 1+ using System . IO ;
2+
13namespace CommandForgeGenerator . Tests ;
24
35public class GenerateTestCode
46{
5- public const string TextCommand = """
6- #if ENABLE_COMMAND_FORGE_GENERATOR
7- namespace CommandForgeGenerator.Command
8- {
9- public partial class TextCommand : ICommandForgeCommand
10- {
11- public const string Type = "text";
12- public readonly CommandId CommandId;
13-
14- public readonly string Character;
15- public readonly string Body;
16-
17-
18- public static TextCommand Create(int commandId, global::Newtonsoft.Json.Linq.JToken json)
19- {
20-
21- var Character = (string)json["character"];
22- var Body = (string)json["body"];
23-
24-
25- return new TextCommand(commandId, Character, Body);
26- }
27-
28- public TextCommand(int commandId, string Character, string Body)
29- {
30- CommandId = (CommandId)commandId;
31-
32- this.Character = Character;
33- this.Body = Body;
34-
35- }
36- }
37- }
38- #endif
39- """ ;
7+ // プロジェクトファイルに存在する GenerateSampleTextCommand.cs を取得する
8+ public static string TextCommandStr => File . ReadAllText ( "../../../CommandForgeGenerator.Tests/GenerateSampleTextCommand.cs" ) ;
409}
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public void GenerateTest()
6565 var codeFiles = CodeGenerator . Generate ( commandsSchema ) ;
6666
6767 Assert . Equal ( 16 , codeFiles . Count ) ;
68- Assert . Equal ( GenerateTestCode . TextCommand , codeFiles . FirstOrDefault ( c => c . FileName == "TextCommand.g.cs" ) . Code ) ;
68+ Assert . Equal ( GenerateTestCode . TextCommandStr , codeFiles . FirstOrDefault ( c => c . FileName == "TextCommand.g.cs" ) . Code ) ;
6969
7070 #region Internal
7171
You can’t perform that action at this time.
0 commit comments