1 // Copyright (C) 2018 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
17 using ExpressionToCodeLib;
\r
18 using KancolleSniffer.Model;
\r
19 using Microsoft.VisualStudio.TestTools.UnitTesting;
\r
21 namespace KancolleSniffer.Test
\r
24 public class AkashiTimerTest
\r
26 private TimeProvider _timeProvider;
\r
27 private ShipInventory _shipInventory;
\r
28 private ShipInfo _shipInfo;
\r
29 private AkashiTimer _akashiTimer;
\r
30 private ShipStatus[] _ships;
\r
32 private class TimeProvider
\r
34 public DateTime DateTime { set; private get; }
\r
36 public DateTime GetTime() => DateTime;
\r
40 public void Initialize()
\r
42 _timeProvider = new TimeProvider();
\r
43 _shipInventory = new ShipInventory();
\r
44 _shipInfo = new ShipInfo(null, _shipInventory, new ItemInventory());
\r
45 _akashiTimer = new AkashiTimer(_shipInfo, new DockInfo(null, null), null, _timeProvider.GetTime);
\r
49 public void SetupFleet()
\r
56 Spec = new ShipSpec {Id = 187, Name = "明石改", ShipType = 19},
\r
59 Slot = new[] {26181, 26501, 37732, 28338}
\r
60 .Select(id => new ItemStatus(id) {Spec = new ItemSpec {Id = 86, Type = 31}})
\r
61 .Concat(new[] {new ItemStatus()}).ToArray()
\r
66 Spec = new ShipSpec {Id = 237, Name = "電改", ShipType = 2},
\r
69 Slot = Enumerable.Repeat(new ItemStatus(), 5).ToArray()
\r
72 foreach (var ship in _ships)
\r
73 _shipInventory[ship.Id] = ship;
\r
74 _shipInfo.Fleets[0].Deck = new[] {17160, 1, -1, -1, -1, -1};
\r
82 _timeProvider.DateTime = new DateTime(2018, 1, 1, 0, 0, 0);
\r
83 _akashiTimer.Port();
\r
85 () => _akashiTimer.GetPresetDeckTimer(new DateTime(2018, 1, 1, 0, 1, 0)) == TimeSpan.FromMinutes(19),
\r
93 public void WithdrawShip()
\r
96 _timeProvider.DateTime = new DateTime(2018, 1, 1, 0, 2, 0);
\r
97 _shipInfo.Fleets[0].Deck = new[] {17160, -1, -1, -1, -1, -1};
\r
98 _akashiTimer.InspectChange("api_id=1&api_ship_idx=0&api_ship_id=-1");
\r
100 () => _akashiTimer.GetPresetDeckTimer(new DateTime(2018, 1, 1, 0, 3, 0)) == TimeSpan.FromMinutes(19));
\r
104 /// 随伴艦一括解除でリセットしない
\r
107 public void WithdrawAccompanyingShips()
\r
110 _timeProvider.DateTime = new DateTime(2018, 1, 1, 0, 2, 0);
\r
111 _shipInfo.Fleets[0].Deck = new[] {17160, -1, -1, -1, -1, -1};
\r
112 _akashiTimer.InspectChange("api_id=1&api_ship_idx=0&api_ship_id=-2");
\r
114 () => _akashiTimer.GetPresetDeckTimer(new DateTime(2018, 1, 1, 0, 3, 0)) == TimeSpan.FromMinutes(17));
\r