sharee.bike-App/TestShareeLib/Model/Bikes/BikeInfoNS/DriveNS/BatteryNS/TestBattery.cs
2023-02-28 16:03:56 +01:00

49 lines
1.5 KiB
C#

using NUnit.Framework;
using TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
namespace TestShareeLib.Model.BikeInfo.DriveNS.BatteryNS
{
[TestFixture]
public class TestBattery
{
[Test]
public void TestSetCurrentChargePercent() => Assert.That(
new Battery.Builder { CurrentChargePercent = 20 }.Build().CurrentChargePercent,
Is.EqualTo(20.0));
[Test]
public void TestSetCurrentChargePercentOutOfRange() => Assert.That(
new Battery.Builder { CurrentChargePercent = 101 }.Build().CurrentChargePercent,
Is.NaN);
[Test]
public void TestSetCurrentChargeBars() => Assert.That(
new Battery.Builder { CurrentChargeBars = 21, MaxChargeBars = 22 }.Build().CurrentChargeBars,
Is.EqualTo(21));
[Test]
public void TestSetCurrentChargeBarsOutOfRange() => Assert.That(
new Battery.Builder { CurrentChargeBars = -1, MaxChargeBars = 22 }.Build().CurrentChargeBars,
Is.Null);
[Test]
public void TestSetMaxChargeBars() => Assert.That(
new Battery.Builder { MaxChargeBars = 23 }.Build().MaxChargeBars,
Is.EqualTo(23));
[Test]
public void TestSetMaxChargeBarsOutOfRange() => Assert.That(
new Battery.Builder { MaxChargeBars = -1 }.Build().MaxChargeBars,
Is.Null);
[Test]
public void TestSetCurrentChargeBarsNoMaxValueSet() => Assert.That(
new Battery.Builder { CurrentChargeBars = 21 }.Build().CurrentChargeBars,
Is.Null);
[Test]
public void TestSetCurrentChargeBars_CurrentValueTooLarge() => Assert.That(
new Battery.Builder { CurrentChargeBars = 25, MaxChargeBars = 22 }.Build().CurrentChargeBars,
Is.Null);
}
}