--- /dev/null
+// Copyright (C) 2018 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+using System.Drawing;\r
+using ExpressionToCodeLib;\r
+using KancolleSniffer.View;\r
+using Microsoft.VisualStudio.TestTools.UnitTesting;\r
+\r
+namespace KancolleSniffer.Test\r
+{\r
+ using Sniffer = SnifferTest.TestingSniffer;\r
+\r
+ [TestClass]\r
+ public class FleetPanelTest\r
+ {\r
+ /// <summary>\r
+ /// 編成で艦隊をまたがって艦娘を交換する\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void ExchangeFleetMember()\r
+ {\r
+ var sniffer = new Sniffer();\r
+ var panel = new FleetPanel();\r
+ var expected = new FleetPanel.Record\r
+ {\r
+ AircraftSpec = "",\r
+ Color = SystemColors.Control,\r
+ Equip = "",\r
+ Fleet = "",\r
+ Fleet2 = null,\r
+ Id = 756,\r
+ Ship = "島風改 Lv130",\r
+ Ship2 = "燃17 弾21",\r
+ Spec = "砲64.0 潜82.4",\r
+ Spec2 = "雷104.0 夜158.0"\r
+ };\r
+\r
+ SnifferTest.SniffLogFile(sniffer, "deck_002");\r
+ SnifferTest.SniffLogFile(sniffer, "deck_003");\r
+ var table = panel.CreateTable(sniffer);\r
+ PAssert.That(() => ComapreFleetRecord(table[13], expected));\r
+ }\r
+\r
+ private bool ComapreFleetRecord(FleetPanel.Record a, FleetPanel.Record b)\r
+ {\r
+ foreach (var property in typeof(FleetPanel.Record).GetProperties())\r
+ {\r
+ var aVal = property.GetValue(a);\r
+ var bVal = property.GetValue(b);\r
+ if (aVal == null)\r
+ {\r
+ if (bVal == null)\r
+ continue;\r
+ return false;\r
+ }\r
+ if (aVal.Equals(bVal))\r
+ continue;\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ }\r
+}
\ No newline at end of file
{\r
private const int LineHeight = 14;\r
private const int LabelHeight = 12;\r
- private Record[] _table;\r
+ private Record[] _table = new Record[0];\r
private readonly List<FleetLabels> _labelList = new List<FleetLabels>();\r
private readonly List<Panel> _panelList = new List<Panel>();\r
private readonly ResizableToolTip _toolTip = new ResizableToolTip {ShowAlways = true, AutoPopDelay = 10000};\r
\r
- private class Record\r
+ public class Record\r
{\r
public string Fleet { get; set; }\r
public string Fleet2 { get; set; }\r
\r
public void Update(Sniffer sniffer)\r
{\r
- CreateTable(sniffer);\r
+ _table = CreateTable(sniffer);\r
SuspendLayout();\r
CreateLabels();\r
SetRecords();\r
}\r
}\r
\r
- private void CreateTable(Sniffer sniffer)\r
+ public Record[] CreateTable(Sniffer sniffer)\r
{\r
var list = new List<Record>();\r
var fn = new[] {"第一", "第二", "第三", "第四"};\r
}\r
}\r
}\r
- _table = list.ToArray();\r
+ return list.ToArray();\r
}\r
\r
private string RangeString(int[] fp) => fp[0] == fp[1] ? fp[0].ToString() : $"{fp[0]}~{fp[1]}";\r