1 // Copyright (C) 2019 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 ExpressionToCodeLib;
\r
16 using KancolleSniffer.Model;
\r
17 using Microsoft.VisualStudio.TestTools.UnitTesting;
\r
18 // ReSharper disable CompareOfFloatsByEqualityOperator
\r
20 namespace KancolleSniffer.Test
\r
23 public class ChargeStatusTest
\r
25 private readonly Fleet _fleet = new Fleet(null, 6, null);
\r
28 public void NoShips()
\r
30 var stat = _fleet.ChargeStatus;
\r
31 PAssert.That(() => stat.Fuel == 0 && stat.Bull == 0);
\r
32 PAssert.That(() => stat.Empty);
\r
36 public void FullFlagshipOnly()
\r
38 var fs =_fleet.Ships[0];
\r
40 fs.Spec.FuelMax = 9;
\r
42 fs.Spec.BullMax = 9;
\r
43 var stat = _fleet.ChargeStatus;
\r
44 PAssert.That(() => stat.Fuel == 0 && stat.FuelRatio == 1);
\r
45 PAssert.That(() => stat.Bull == 0 && stat.BullRatio == 1);
\r
49 public void FlagshipOnly()
\r
51 var fs = _fleet.Ships[0];
\r
53 fs.Spec.FuelMax = 9;
\r
55 fs.Spec.BullMax = 9;
\r
56 var stat = _fleet.ChargeStatus;
\r
57 PAssert.That(() => stat.Fuel == 2 && stat.FuelRatio == 3 / 9.0);
\r
58 PAssert.That(() => stat.Bull == 4 && stat.BullRatio == 0.0);
\r
62 public void FullFlagshipAndFullOther()
\r
64 var fs = _fleet.Ships[0];
\r
66 fs.Spec.FuelMax = 9;
\r
68 fs.Spec.BullMax = 9;
\r
69 var other = _fleet.Ships[1];
\r
71 other.Spec.FuelMax = 9;
\r
73 other.Spec.BullMax = 9;
\r
74 var stat = _fleet.ChargeStatus;
\r
75 PAssert.That(() => stat.Fuel == 5 && stat.FuelRatio == 1);
\r
76 PAssert.That(() => stat.Bull == 5 && stat.BullRatio == 1);
\r
80 public void FullFlagshipAndOther()
\r
82 var fs = _fleet.Ships[0];
\r
84 fs.Spec.FuelMax = 9;
\r
86 fs.Spec.BullMax = 9;
\r
87 var other = _fleet.Ships[1];
\r
89 other.Spec.FuelMax = 9;
\r
91 other.Spec.BullMax = 9;
\r
92 var stat = _fleet.ChargeStatus;
\r
93 PAssert.That(() => stat.Fuel == 6 && stat.FuelRatio == 7 / 9.0);
\r
94 PAssert.That(() => stat.Bull == 7 && stat.BullRatio == 3 / 9.0);
\r
98 public void FullFlagshipAndOthers()
\r
100 var fs = _fleet.Ships[0];
\r
102 fs.Spec.FuelMax = 9;
\r
104 fs.Spec.BullMax = 9;
\r
105 var second = _fleet.Ships[1];
\r
107 second.Spec.FuelMax = 9;
\r
109 second.Spec.BullMax = 9;
\r
110 var third = _fleet.Ships[2];
\r
112 third.Spec.FuelMax = 9;
\r
114 third.Spec.BullMax = 9;
\r
115 var stat = _fleet.ChargeStatus;
\r
116 PAssert.That(() => stat.Fuel == 7 && stat.FuelRatio == 3 / 9.0);
\r
117 PAssert.That(() => stat.Bull == 9 && stat.BullRatio == 0.0);
\r