OSDN Git Service

新兵装開発資材輸送を船団護衛せよ!のカウンターを実装する
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer.Test / RepairShipCountTest.cs
1 // Copyright (C) 2019 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 KancolleSniffer.Model;\r
16 using KancolleSniffer.View.MainWindow;\r
17 using Microsoft.VisualStudio.TestTools.UnitTesting;\r
18 \r
19 namespace KancolleSniffer.Test\r
20 {\r
21     [TestClass]\r
22     public class RepairShipCountTest\r
23     {\r
24         [TestMethod]\r
25         public void TestCreateRepairShipCountString()\r
26         {\r
27             Assert.AreEqual("なし", new RepairShipCount(new ShipStatus[0]).ToString());\r
28 \r
29             const int max = 31;\r
30             const int minor = 30;\r
31             const int small = (int)(max * 0.75);\r
32             const int half = (int)(max * 0.5);\r
33             const int badly = (int)(max * 0.25);\r
34 \r
35             var repairList = new[]\r
36             {\r
37                 new ShipStatus {NowHp = minor, MaxHp = max},\r
38                 new ShipStatus {NowHp = minor, MaxHp = max},\r
39                 new ShipStatus {NowHp = minor, MaxHp = max},\r
40                 new ShipStatus {NowHp = minor, MaxHp = max}\r
41             };\r
42             Assert.AreEqual("軽微 4", new RepairShipCount(repairList).ToString());\r
43 \r
44             repairList[0].NowHp = small;\r
45             Assert.AreEqual("軽微 3\r\n小破 1\r\n 計 4",\r
46                 new RepairShipCount(repairList).ToString());\r
47 \r
48             repairList[1].NowHp = half;\r
49             Assert.AreEqual("軽微 2\r\n小破 1\r\n 計 3\r\n中破 1\r\n 計 1",\r
50                 new RepairShipCount(repairList).ToString());\r
51 \r
52             repairList[2].NowHp = badly;\r
53             Assert.AreEqual("軽微 1\r\n小破 1\r\n 計 2\r\n中破 1\r\n大破 1\r\n 計 2",\r
54                 new RepairShipCount(repairList).ToString());\r
55 \r
56             repairList[3].NowHp = small;\r
57             Assert.AreEqual("小破 2\r\n 計 2\r\n中破 1\r\n大破 1\r\n 計 2",\r
58                 new RepairShipCount(repairList).ToString());\r
59 \r
60             repairList[1].NowHp = badly;\r
61             Assert.AreEqual("小破 2\r\n大破 2",\r
62                 new RepairShipCount(repairList).ToString());\r
63 \r
64             repairList[0].NowHp = half;\r
65             repairList[3].NowHp = half;\r
66             repairList[1].NowHp = badly;\r
67             Assert.AreEqual("中破 2\r\n大破 2\r\n 計 4",\r
68                 new RepairShipCount(repairList).ToString());\r
69 \r
70             repairList[0].NowHp = badly;\r
71             repairList[3].NowHp = badly;\r
72             Assert.AreEqual("大破 4",\r
73                 new RepairShipCount(repairList).ToString());\r
74         }\r
75     }\r
76 }