1 // Copyright (C) 2017 Kazuhiro Fujieda <fujieda@users.osdn.me>
\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
7 // http://www.apache.org/licenses/LICENSE-2.0
\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
16 using ExpressionToCodeLib;
\r
17 using Microsoft.VisualStudio.TestTools.UnitTesting;
\r
19 namespace KancolleSniffer.Test
\r
22 public class BattleTest
\r
24 private ItemInfo _itemInfo;
\r
25 private ShipInfo _shipInfo;
\r
26 private BattleInfo _battleInfo;
\r
28 private string[] ReadAllLines(string log)
\r
30 using (var logfile = SnifferTest.OpenLogFile(log))
\r
31 return logfile.ReadToEnd().Split(new [] {"\r\n"}, StringSplitOptions.None);
\r
35 public void Initialize()
\r
37 _itemInfo = new ItemInfo();
\r
38 _shipInfo = new ShipInfo(_itemInfo);
\r
39 _battleInfo = new BattleInfo(_shipInfo, _itemInfo);
\r
46 public void CauseRepairGoddessByDoubleAttack()
\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
62 public void AttackedByBattleShipInMidnight()
\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