OSDN Git Service

エラーログに戦闘前の装備を出力する
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer.Test / BattleTest.cs
1 // Copyright (C) 2017 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
2 //\r
3 // Licensed under the Apache License, Version 2.0 (the "License");\r
4 // you may not use this file except in compliance with the License.\r
5 // You may obtain a copy of the License at\r
6 //\r
7 //    http://www.apache.org/licenses/LICENSE-2.0\r
8 //\r
9 // Unless required by applicable law or agreed to in writing, software\r
10 // distributed under the License is distributed on an "AS IS" BASIS,\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 // See the License for the specific language governing permissions and\r
13 // limitations under the License.\r
14 \r
15 using System;\r
16 using ExpressionToCodeLib;\r
17 using Microsoft.VisualStudio.TestTools.UnitTesting;\r
18 \r
19 namespace KancolleSniffer.Test\r
20 {\r
21     [TestClass]\r
22     public class BattleTest\r
23     {\r
24         private ItemInfo _itemInfo;\r
25         private ShipInfo _shipInfo;\r
26         private BattleInfo _battleInfo;\r
27 \r
28         private string[] ReadAllLines(string log)\r
29         {\r
30             using (var logfile = SnifferTest.OpenLogFile(log))\r
31                 return logfile.ReadToEnd().Split(new [] {"\r\n"}, StringSplitOptions.None);\r
32         }\r
33 \r
34         [TestInitialize]\r
35         public void Initialize()\r
36         {\r
37             _itemInfo = new ItemInfo();\r
38             _shipInfo = new ShipInfo(_itemInfo);\r
39             _battleInfo = new BattleInfo(_shipInfo, _itemInfo);\r
40         }\r
41 \r
42         [TestMethod]\r
43         public void Damecon()\r
44         {\r
45             var logs = ReadAllLines("damecon_001");\r
46             var items = JsonParser.Parse("[[[],[],[],[],[43]]]");\r
47             dynamic battle = JsonParser.Parse(logs[2]);\r
48             _shipInfo.InjectShips(battle, items);\r
49             _battleInfo.InspectBattle(battle, logs[0]);\r
50             dynamic result = JsonParser.Parse(logs[5]);\r
51             _battleInfo.InspectBattleResult(result);\r
52             PAssert.That(() => _shipInfo.GetShipStatuses(2)[4].NowHp == 31);\r
53         }\r
54     }\r
55 }