1 // Copyright (C) 2016 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
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
21 namespace KancolleSniffer.Test
\r
24 public class ShipLabelTest
\r
27 /// 明石タイマー表示中の艦娘の名前を縮める
\r
30 public void TruncateNameForAkashiTimer()
\r
32 var dict = new Dictionary<string, string>
\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
46 TruncateNameSub(dict, ShipNameWidth.AkashiTimer);
\r
53 public void TruncateNameForNDock()
\r
55 var dict = new Dictionary<string, string>
\r
58 {"Graf Zeppelin", "Graf Zeppeli"},
\r
59 {"Graf Zeppelin改", "Graf Zeppeli"},
\r
62 TruncateNameSub(dict, ShipNameWidth.NDock);
\r
66 /// 一覧ウィンドウの要修復一覧の艦娘の名前を縮める
\r
69 public void TruncateNameForRepairListFull()
\r
71 var dict = new Dictionary<string, string>
\r
73 {"Graf Zeppelin", "Graf Zeppelin"},
\r
74 {"Graf Zeppelin改", "Graf Zeppelin"},
\r
77 TruncateNameSub(dict, ShipNameWidth.RepairListFull);
\r
81 /// メインパネルの艦娘の名前を縮める
\r
84 public void TruncateNameForMainPanel()
\r
86 var dict = new Dictionary<string, string>
\r
88 {"Commandant Teste", "Commandant Tes"}
\r
90 TruncateNameSub(dict, ShipNameWidth.MainPanel);
\r
94 public void TruncateNameForShipList()
\r
96 var dict = new Dictionary<string, string>
\r
98 {"Commandant Test", "Commandant T"},
\r
99 {"Graf Zeppelin改", "Graf Zeppelin"}
\r
101 TruncateNameSub(dict, ShipNameWidth.ShipList);
\r
104 private void TruncateNameSub(Dictionary<string, string> dict, ShipNameWidth width)
\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
110 label.SetName(entry.Key, width);
\r
111 PAssert.That(() => label.Text == entry.Value, entry.Key);
\r
119 public void SetName()
\r
121 var label = new ShipLabel {Parent = new Panel()};
\r
122 ShipLabel.ScaleFactor = new SizeF(1, 1);
\r
123 label.SetName(new ShipStatus
\r
125 Spec = new ShipSpec {Name = "綾波改二"},
\r
128 ShipNameWidth.AkashiTimer);
\r
129 PAssert.That(() => label.Text == "[避]綾波改二");
\r
130 label.SetName(new ShipStatus
\r
132 Spec = new ShipSpec {Name = "朝潮改二丁"},
\r
135 ShipNameWidth.AkashiTimer);
\r
136 PAssert.That(() => label.Text == "[避]朝潮改二");
\r
143 public void RoundOffFractionOfPercent()
\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