|
| 1 | +using System; |
1 | 2 | using System.IO; |
| 3 | +using System.Linq; |
2 | 4 | using CommandForgeGenerator.Generator.CodeGenerate; |
3 | 5 | using CommandForgeGenerator.Generator.Json; |
4 | 6 | using CommandForgeGenerator.Generator.Semantic; |
@@ -59,184 +61,16 @@ public void JsonParserTest() |
59 | 61 | [Fact] |
60 | 62 | public void GenerateTest() |
61 | 63 | { |
62 | | - var yaml = GetSampleYaml(); |
| 64 | + var yaml = GenerateTestCode.YamlFileStr; |
63 | 65 | var commandsSchema = CommandSemanticsLoader.GetCommandSemantics(yaml); |
64 | 66 | var codeFiles = CodeGenerator.Generate(commandsSchema); |
65 | 67 |
|
66 | | - Assert.Equal(16, codeFiles.Count); |
| 68 | + var file = codeFiles.FirstOrDefault(c => c.FileName == "TextCommand.g.cs").Code; |
67 | 69 |
|
68 | | - #region Internal |
| 70 | + //File.WriteAllText("/Users/katsumi.sato/Desktop/a/TextCommand.g.cs", file); |
69 | 71 |
|
70 | | - string GetSampleYaml() |
71 | | - { |
72 | | - return """ |
73 | | - version: 1 |
74 | | - commands: |
75 | | - - id: text |
76 | | - label: テキスト |
77 | | - description: 台詞を表示 |
78 | | - commandListLabelFormat: "{character}「{body}」" |
79 | | - properties: |
80 | | - character: |
81 | | - type: enum |
82 | | - options: ["キャラA", "キャラB", "キャラC", "キャラD", "先生", "店員"] |
83 | | - required: true |
84 | | - body: |
85 | | - type: string |
86 | | - multiline: true |
87 | | - required: true |
88 | | - |
89 | | - - id: emote |
90 | | - label: エモート |
91 | | - description: 立ち絵・表情切替 |
92 | | - commandListLabelFormat: "EMOTE: {character}, {emotion}" |
93 | | - properties: |
94 | | - character: |
95 | | - type: enum |
96 | | - options: ["キャラA", "キャラB", "キャラC", "キャラD", "先生", "店員"] |
97 | | - required: true |
98 | | - emotion: |
99 | | - type: enum |
100 | | - options: ["通常", "笑顔", "驚き", "怒り", "悲しみ", "困惑", "照れ", "恐怖", "喜び", "真剣"] |
101 | | - required: true |
102 | | - |
103 | | - - id: wait |
104 | | - label: 待機 |
105 | | - description: 指定秒数だけウェイト |
106 | | - commandListLabelFormat: "WAIT: {seconds}" |
107 | | - defaultBackgroundColor: '#57e317' |
108 | | - properties: |
109 | | - seconds: |
110 | | - type: number |
111 | | - default: 0.5 |
112 | | - constraints: |
113 | | - min: 0 |
114 | | - |
115 | | - - id: bgm |
116 | | - label: BGM |
117 | | - description: 背景音楽を変更 |
118 | | - commandListLabelFormat: "BGM: {track}, volume={volume}" |
119 | | - properties: |
120 | | - track: |
121 | | - type: enum |
122 | | - options: ["なし", "日常", "緊張", "悲しい", "楽しい", "神秘的", "アクション", "ロマンティック", "エンディング"] |
123 | | - required: true |
124 | | - volume: |
125 | | - type: number |
126 | | - default: 1.0 |
127 | | - constraints: |
128 | | - min: 0 |
129 | | - max: 1.0 |
130 | | - |
131 | | - - id: sound |
132 | | - label: 効果音 |
133 | | - description: 効果音を再生 |
134 | | - commandListLabelFormat: "SOUND: {effect}, volume={volume}" |
135 | | - properties: |
136 | | - effect: |
137 | | - type: enum |
138 | | - options: ["ドア", "足音", "衝撃", "爆発", "鐘", "拍手", "警報", "雨", "雷", "風"] |
139 | | - required: true |
140 | | - volume: |
141 | | - type: number |
142 | | - default: 1.0 |
143 | | - constraints: |
144 | | - min: 0 |
145 | | - max: 1.0 |
146 | | - |
147 | | - - id: background |
148 | | - label: 背景 |
149 | | - description: 背景画像を変更 |
150 | | - commandListLabelFormat: "BG: {scene}, effect={transition}" |
151 | | - properties: |
152 | | - scene: |
153 | | - type: enum |
154 | | - options: ["教室", "廊下", "体育館", "屋上", "公園", "駅", "カフェ", "自宅", "図書館", "商店街"] |
155 | | - required: true |
156 | | - transition: |
157 | | - type: enum |
158 | | - options: ["なし", "フェード", "ワイプ", "クロスフェード", "フラッシュ"] |
159 | | - default: "なし" |
160 | | - |
161 | | - - id: camera |
162 | | - label: カメラ |
163 | | - description: カメラワークを指定 |
164 | | - commandListLabelFormat: "CAMERA: {action}, target={target}" |
165 | | - properties: |
166 | | - action: |
167 | | - type: enum |
168 | | - options: ["ズームイン", "ズームアウト", "パン左", "パン右", "シェイク", "フォーカス", "リセット"] |
169 | | - required: true |
170 | | - target: |
171 | | - type: enum |
172 | | - options: ["全体", "キャラA", "キャラB", "キャラC", "キャラD", "先生", "店員", "背景"] |
173 | | - default: "全体" |
174 | | - |
175 | | - - id: choice |
176 | | - label: 選択肢 |
177 | | - description: 選択肢を表示 |
178 | | - commandListLabelFormat: "CHOICE: {options}" |
179 | | - properties: |
180 | | - options: |
181 | | - type: string |
182 | | - multiline: true |
183 | | - description: "選択肢を1行に1つずつ記述" |
184 | | - required: true |
185 | | - timeout: |
186 | | - type: number |
187 | | - default: 0 |
188 | | - description: "自動選択までの秒数(0で無制限)" |
189 | | - |
190 | | - - id: action |
191 | | - label: アクション |
192 | | - description: キャラクターのアクションを実行 |
193 | | - commandListLabelFormat: "ACTION: {character}, {action}" |
194 | | - properties: |
195 | | - character: |
196 | | - type: enum |
197 | | - options: ["キャラA", "キャラB", "キャラC", "キャラD", "先生", "店員"] |
198 | | - required: true |
199 | | - action: |
200 | | - type: enum |
201 | | - options: ["歩く", "走る", "座る", "立つ", "ジャンプ", "踊る", "倒れる", "手を振る", "指さす", "抱きしめる"] |
202 | | - required: true |
203 | | - direction: |
204 | | - type: enum |
205 | | - options: ["左", "右", "上", "下", "中央"] |
206 | | - default: "中央" |
207 | | - |
208 | | - - id: narration |
209 | | - label: ナレーション |
210 | | - description: ナレーションテキストを表示 |
211 | | - commandListLabelFormat: "NARRATION: {text}" |
212 | | - properties: |
213 | | - text: |
214 | | - type: string |
215 | | - multiline: true |
216 | | - required: true |
217 | | - style: |
218 | | - type: enum |
219 | | - options: ["通常", "強調", "小さく", "斜体", "点滅"] |
220 | | - default: "通常" |
221 | | - |
222 | | - - id: branch |
223 | | - label: 分岐 |
224 | | - description: 他のコマンドを参照する分岐 |
225 | | - commandListLabelFormat: "BRANCH: Target {targetCommand}" |
226 | | - defaultBackgroundColor: "#f9f0ff" |
227 | | - properties: |
228 | | - targetCommand: |
229 | | - type: command |
230 | | - required: true |
231 | | - commandTypes: ["text", "narration"] # Only allow text and narration commands |
232 | | - condition: |
233 | | - type: string |
234 | | - required: true |
235 | | - multiline: true |
236 | | - """; |
237 | | - } |
238 | 72 |
|
239 | | - #endregion |
240 | | - |
| 73 | + Assert.Equal(17, codeFiles.Count); |
| 74 | + Assert.Equal(GenerateTestCode.TextCommandStr, codeFiles.FirstOrDefault(c => c.FileName == "TextCommand.g.cs").Code); |
241 | 75 | } |
242 | 76 | } |
0 commit comments