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 KancolleSniffer.Model;
\r
20 using KancolleSniffer.View;
\r
21 using Microsoft.VisualStudio.TestTools.UnitTesting;
\r
23 namespace KancolleSniffer.Test
\r
26 public class ShipLabelTest
\r
29 /// 明石タイマー表示中の艦娘の名前を縮める
\r
32 public void TruncateNameForAkashiTimer()
\r
34 var dict = new Dictionary<string, string>
\r
39 {"Bismarck改", "Bismarck"},
\r
40 {"Bismarck twei", "Bismarck"},
\r
41 {"Bismarck drei", "Bismarck"},
\r
42 {"Prinz Eugen", "Prinz Eug"},
\r
43 {"Prinz Eugen改", "Prinz Eug"},
\r
44 {"Graf Zeppelin", "Graf Zep"},
\r
45 {"Graf Zeppelin改", "Graf Zep"},
\r
46 {"Libeccio改", "Libeccio"},
\r
48 TruncateNameSub(dict, ShipNameWidth.AkashiTimer);
\r
55 public void TruncateNameForNDock()
\r
57 var dict = new Dictionary<string, string>
\r
60 {"Graf Zeppelin", "Graf Zeppeli"},
\r
61 {"Graf Zeppelin改", "Graf Zeppeli"},
\r
64 TruncateNameSub(dict, ShipNameWidth.NDock);
\r
68 /// 一覧ウィンドウの要修復一覧の艦娘の名前を縮める
\r
71 public void TruncateNameForRepairListFull()
\r
73 var dict = new Dictionary<string, string>
\r
75 {"Graf Zeppelin", "Graf Zeppelin"},
\r
76 {"Graf Zeppelin改", "Graf Zeppelin"},
\r
79 TruncateNameSub(dict, ShipNameWidth.RepairListFull);
\r
83 /// メインパネルの艦娘の名前を縮める
\r
86 public void TruncateNameForMainPanel()
\r
88 var dict = new Dictionary<string, string>
\r
90 {"Commandant Teste", "Commandant Tes"}
\r
92 TruncateNameSub(dict, ShipNameWidth.MainPanel);
\r
96 public void TruncateNameForShipList()
\r
98 var dict = new Dictionary<string, string>
\r
100 {"Commandant Test", "Commandant T"},
\r
101 {"Graf Zeppelin改", "Graf Zeppelin"}
\r
103 TruncateNameSub(dict, ShipNameWidth.ShipList);
\r
106 private void TruncateNameSub(Dictionary<string, string> dict, ShipNameWidth width)
\r
108 var label = new ShipLabel {Parent = new Panel()};
\r
109 ShipLabel.ScaleFactor = new SizeF(1,1);
\r
110 foreach (var entry in dict)
\r
112 label.SetName(entry.Key, width);
\r
113 PAssert.That(() => label.Text == entry.Value, entry.Key);
\r
121 public void SetName()
\r
123 var label = new ShipLabel {Parent = new Panel()};
\r
124 ShipLabel.ScaleFactor = new SizeF(1, 1);
\r
125 label.SetName(new ShipStatus
\r
127 Spec = new ShipSpec {Name = "綾波改二"},
\r
130 ShipNameWidth.AkashiTimer);
\r
131 PAssert.That(() => label.Text == "[避]綾波改二");
\r
132 label.SetName(new ShipStatus
\r
134 Spec = new ShipSpec {Name = "朝潮改二丁"},
\r
137 ShipNameWidth.AkashiTimer);
\r
138 PAssert.That(() => label.Text == "[避]朝潮改二");
\r
145 public void RoundOffFractionOfPercent()
\r
147 var label = new ShipLabel {Parent = new Panel()};
\r
148 label.SetHp(104, 105);
\r
149 label.ToggleHpPercent();
\r
150 PAssert.That(() => label.Text == "99%");
\r