OSDN Git Service

バージョン10.8の準備
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer.Test / ShipLabelTest.cs
1 // Copyright (C) 2016 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.Collections.Generic;\r
16 using System.Drawing;\r
17 using System.Windows.Forms;\r
18 using ExpressionToCodeLib;\r
19 using Microsoft.VisualStudio.TestTools.UnitTesting;\r
20 \r
21 namespace KancolleSniffer.Test\r
22 {\r
23     [TestClass]\r
24     public class ShipLabelTest\r
25     {\r
26         /// <summary>\r
27         /// 明石タイマー表示中の艦娘の名前を縮める\r
28         /// </summary>\r
29         [TestMethod]\r
30         public void TruncateNameForAkashiTimer()\r
31         {\r
32             var dict = new Dictionary<string, string>\r
33             {\r
34                 {"夕立改二", "夕立改二"},\r
35                 {"千代田航改", "千代田航"},\r
36                 {"千代田航改二", "千代田航"},\r
37                 {"Bismarck改", "Bismarck"},\r
38                 {"Bismarck twei", "Bismarck"},\r
39                 {"Bismarck drei", "Bismarck"},\r
40                 {"Prinz Eugen", "Prinz Eug"},\r
41                 {"Prinz Eugen改", "Prinz Eug"},\r
42                 {"Graf Zeppelin", "Graf Zep"},\r
43                 {"Graf Zeppelin改", "Graf Zep"},\r
44                 {"Libeccio改", "Libeccio"},\r
45             };\r
46             TruncateNameSub(dict, ShipNameWidth.AkashiTimer);\r
47         }\r
48 \r
49         /// <summary>\r
50         /// 入渠中の艦娘名の名前を縮める\r
51         /// </summary>\r
52         [TestMethod]\r
53         public void TruncateNameForNDock()\r
54         {\r
55             var dict = new Dictionary<string, string>\r
56             {\r
57                 {"千歳航改二", "千歳航改二"},\r
58                 {"Graf Zeppelin", "Graf Zeppeli"},\r
59                 {"Graf Zeppelin改", "Graf Zeppeli"},\r
60                 {"千代田航改二", "千代田航改"}\r
61             };\r
62             TruncateNameSub(dict, ShipNameWidth.NDock);\r
63         }\r
64 \r
65         /// <summary>\r
66         /// 一覧ウィンドウの要修復一覧の艦娘の名前を縮める\r
67         /// </summary>\r
68         [TestMethod]\r
69         public void TruncateNameForRepairListFull()\r
70         {\r
71             var dict = new Dictionary<string, string>\r
72             {\r
73                 {"Graf Zeppelin", "Graf Zeppelin"},\r
74                 {"Graf Zeppelin改", "Graf Zeppelin"},\r
75                 {"千代田航改二", "千代田航改"}\r
76             };\r
77             TruncateNameSub(dict, ShipNameWidth.RepairListFull);\r
78         }\r
79 \r
80         /// <summary>\r
81         /// メインパネルの艦娘の名前を縮める\r
82         /// </summary>\r
83         [TestMethod]\r
84         public void TruncateNameForMainPanel()\r
85         {\r
86             var dict = new Dictionary<string, string>\r
87             {\r
88                 {"Commandant Teste", "Commandant Tes"}\r
89             };\r
90             TruncateNameSub(dict, ShipNameWidth.MainPanel);\r
91         }\r
92 \r
93         [TestMethod]\r
94         public void TruncateNameForShipList()\r
95         {\r
96             var dict = new Dictionary<string, string>\r
97             {\r
98                 {"Commandant Test", "Commandant T"},\r
99                 {"Graf Zeppelin改", "Graf Zeppelin"}\r
100             };\r
101             TruncateNameSub(dict, ShipNameWidth.ShipList);\r
102         }\r
103 \r
104         private void TruncateNameSub(Dictionary<string, string> dict, ShipNameWidth width)\r
105         {\r
106             var label = new ShipLabel {Parent = new Panel()};\r
107             ShipLabel.ScaleFactor = new SizeF(1,1);\r
108             foreach (var entry in dict)\r
109             {\r
110                 label.SetName(entry.Key, width);\r
111                 PAssert.That(() => label.Text == entry.Value, entry.Key);\r
112             }\r
113         }\r
114 \r
115         /// <summary>\r
116         /// prefixを加える\r
117         /// </summary>\r
118         [TestMethod]\r
119         public void SetName()\r
120         {\r
121             var label = new ShipLabel {Parent = new Panel()};\r
122             ShipLabel.ScaleFactor = new SizeF(1, 1);\r
123             label.SetName(new ShipStatus\r
124                 {\r
125                     Spec = new ShipSpec {Name = "綾波改二"},\r
126                     Escaped = true\r
127                 },\r
128                 ShipNameWidth.AkashiTimer);\r
129             PAssert.That(() => label.Text == "[避]綾波改二");\r
130             label.SetName(new ShipStatus\r
131                 {\r
132                     Spec = new ShipSpec {Name = "朝潮改二丁"},\r
133                     Escaped = true\r
134                 },\r
135                 ShipNameWidth.AkashiTimer);\r
136             PAssert.That(() => label.Text == "[避]朝潮改二");\r
137         }\r
138 \r
139         /// <summary>\r
140         /// %表示の小数部を切り捨てる\r
141         /// </summary>\r
142         [TestMethod]\r
143         public void RoundOffFractionOfPercent()\r
144         {\r
145             var label = new ShipLabel {Parent = new Panel()};\r
146             label.SetHp(104, 105);\r
147             label.ToggleHpPercent();\r
148             PAssert.That(() => label.Text == "99%");\r
149         }\r
150     }\r
151 }