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         /// <summary>\r
43         /// 連撃を受けて女神が発動する\r
44         /// </summary>\r
45         [TestMethod]\r
46         public void CauseRepairGoddessByDoubleAttack()\r
47         {\r
48             var logs = ReadAllLines("damecon_001");\r
49             var items = JsonParser.Parse("[[[],[],[],[],[43]]]");\r
50             dynamic battle = JsonParser.Parse(logs[2]);\r
51             _shipInfo.InjectShips(battle, items);\r
52             _battleInfo.InspectBattle(logs[0], logs[1], battle);\r
53             dynamic result = JsonParser.Parse(logs[5]);\r
54             _battleInfo.InspectBattleResult(result);\r
55             PAssert.That(() => _shipInfo.GetShipStatuses(2)[4].NowHp == 31);\r
56         }\r
57 \r
58         /// <summary>\r
59         /// 夜戦で戦艦の攻撃を受ける\r
60         /// </summary>\r
61         [TestMethod]\r
62         public void AttackedByBattleShipInMidnight()\r
63         {\r
64             var logs = ReadAllLines("midnight_002");\r
65             var battle = JsonParser.Parse(logs[3]);\r
66             _shipInfo.InjectShips(battle, JsonParser.Parse(logs[0]));\r
67             _battleInfo.InspectBattle(logs[1], logs[2], battle);\r
68             _battleInfo.InspectBattleResult(JsonParser.Parse(logs[6]));\r
69             PAssert.That(() => _shipInfo.GetShipStatuses(0)[3].NowHp == 12);\r
70         }\r
71     }\r
72 }