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