OSDN Git Service

基地空襲戦の制空状況が次の戦闘に引き継がれるのを直す
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer.Test / BattleLogProcessorTest.cs
index d2cfd55..fd9f6db 100644 (file)
@@ -1,5 +1,21 @@
-using System.Linq;\r
+// 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.Collections.Generic;\r
+using System.Linq;\r
 using ExpressionToCodeLib;\r
+using KancolleSniffer.Log;\r
 using Microsoft.VisualStudio.TestTools.UnitTesting;\r
 \r
 namespace KancolleSniffer.Test\r
@@ -7,6 +23,13 @@ namespace KancolleSniffer.Test
     [TestClass]\r
     public class BattleLogProcessorTest\r
     {\r
+        [TestInitialize]\r
+        public void Initialize()\r
+        {\r
+            ExpressionToCodeConfiguration.GlobalAssertionConfiguration = ExpressionToCodeConfiguration\r
+                .GlobalAssertionConfiguration.WithPrintedListLengthLimit(200).WithMaximumValueLength(1000);\r
+        }\r
+\r
         [TestMethod]\r
         public void NormalLog()\r
         {\r
@@ -19,10 +42,10 @@ namespace KancolleSniffer.Test
             input[15] = "綾波改二(Lv148)";\r
             input[16] = "20/37";\r
             input[37] = "制空権確保";\r
-            var result = BattleLogProcessor.Process(input).ToArray();\r
+            var result = new BattleLogProcessor().Process(input);\r
             PAssert.That(() => result[5] == "T字有利");\r
-            PAssert.That(() => result[23] == "龍鳳改(Lv97)・夕立改(Lv148)");\r
-            PAssert.That(() => result[38] == "確保");\r
+            PAssert.That(() => result[37] == "確保");\r
+            PAssert.That(() => result[38] == "龍鳳改(Lv97)・夕立改(Lv148)");\r
         }\r
 \r
         [TestMethod]\r
@@ -33,12 +56,60 @@ namespace KancolleSniffer.Test
             input[11] = "龍鳳改(Lv97)・夕立改(Lv148)";\r
             input[12] = "3/48・5/36";\r
             input[37] = "航空劣勢";\r
-            var result = BattleLogProcessor.Process(input).ToArray();\r
+            var result = new BattleLogProcessor().Process(input);\r
             PAssert.That(() => result[6] == "第四警戒");\r
-            PAssert.That(() => result[23] == "龍鳳改(Lv97)・夕立改(Lv148)");\r
-            PAssert.That(() => result[38] == "劣勢");\r
+            PAssert.That(() => result[37] == "劣勢");\r
+            PAssert.That(() => result[38] == "龍鳳改(Lv97)・夕立改(Lv148)");\r
+\r
+        }\r
+\r
+        [TestMethod]\r
+        public void CombinedUnbalanceLog()\r
+        {\r
+            var input = Enumerable.Repeat("", 38).ToArray();\r
+            input[11] = "龍鳳改(Lv97)・";\r
+            input[12] = "3/48・";\r
+            input[13] = "・夕立改(Lv148)";\r
+            input[14] = "・5/36";\r
+            var result = new BattleLogProcessor().Process(input);\r
+            PAssert.That(() => result[38] == "龍鳳改(Lv97)・夕立改(Lv148)");\r
+        }\r
+\r
+        [TestMethod]\r
+        public void NormalLogWithKana()\r
+        {\r
+            var input = Enumerable.Repeat("", 38).ToArray();\r
+            input[11] = "Luigi Torelli(ルイージ・トレッリ)(Lv7)";\r
+            input[12] = "2/11";\r
+            var result = new BattleLogProcessor().Process(input);\r
+            PAssert.That(() => result[11] == "Luigi Torelli(Lv7)");\r
+            PAssert.That(() => result[38] == "Luigi Torelli(Lv7)");\r
         }\r
-    }\r
 \r
+        [TestMethod]\r
+        public void Ship7BattleLog()\r
+        {\r
+            var input = new[]\r
+            {\r
+                "2017-11-20 20:59:39", "台湾沖/ルソン島沖", "1", "出撃", "S", "反航戦", "単横陣", "梯形陣", "深海潜水艦部隊 通商破壊Aライン", "", "",\r
+                "あきつ丸改(Lv81)", "40/40", "那智改二(Lv151)", "63/63", "Roma改(Lv99)", "92/92", "阿武隈改二(Lv98)", "40/45",\r
+                "霞改二(Lv96)", "31/31", "潮改二(Lv94)", "33/33", "龍驤改二(Lv99)", "50/50", "潜水カ級(flagship)", "0/37",\r
+                "潜水カ級(flagship)", "0/37", "潜水カ級(elite)", "0/27", "潜水カ級(elite)", "0/27", "", "", "", "", "590", "0",\r
+                "制空権確保"\r
+            };\r
+            var result = new BattleLogProcessor().Process(input);\r
+            PAssert.That(() => result[21] == "潮改二(Lv94)・龍驤改二(Lv99)" &&\r
+                               result[22] == "33/33・50/50");\r
+            PAssert.That(() => result.Length == 40);\r
+        }\r
 \r
+        [TestMethod]\r
+        public void AddMapNumber()\r
+        {\r
+            var input = Enumerable.Repeat("", 38).ToArray();\r
+            input[1] = "サーモン海域";\r
+            var result = new BattleLogProcessor(new Dictionary<string, string> {{"サーモン海域", "5-4"}}).Process(input);\r
+            PAssert.That(() => result[39] == "5-4");\r
+        }\r
+    }\r
 }
\ No newline at end of file