mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 13:57:28 +02:00
Version 3.0.371
This commit is contained in:
parent
bdb2dec1c1
commit
6d22dbf40b
145 changed files with 2289 additions and 764 deletions
|
@ -0,0 +1,93 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
|
||||
namespace TestShareeLib.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestBatteryMutable
|
||||
{
|
||||
[Test]
|
||||
public void TestCurrentChargeBars()
|
||||
{
|
||||
var battery = new BatteryMutable(new Battery.Builder {
|
||||
MaxChargeBars = 5,
|
||||
CurrentChargeBars = 1,
|
||||
CurrentChargePercent = 20.0
|
||||
}.Build());
|
||||
|
||||
battery.CurrentChargeBars = 4;
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargeBars,
|
||||
Is.EqualTo(4));
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargePercent,
|
||||
Is.EqualTo(80.0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCurrentChargeBarsNull()
|
||||
{
|
||||
var battery = new BatteryMutable(new Battery.Builder
|
||||
{
|
||||
MaxChargeBars = 5,
|
||||
CurrentChargeBars = 1,
|
||||
CurrentChargePercent = 20.0
|
||||
}.Build());
|
||||
|
||||
battery.CurrentChargeBars = null;
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargePercent,
|
||||
Is.EqualTo(double.NaN));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCurrentChargeBarsInvalidStateZero()
|
||||
{
|
||||
var battery = new BatteryMutable(new Battery.Builder
|
||||
{
|
||||
MaxChargeBars = 0, // Could lead to division by zero if not handled correctly.
|
||||
CurrentChargeBars = null,
|
||||
CurrentChargePercent = 20.0
|
||||
}.Build());
|
||||
|
||||
battery.CurrentChargeBars = 4;
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargePercent,
|
||||
Is.EqualTo(20.0));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestCurrentChargeBarsInvalidStateNull()
|
||||
{
|
||||
var battery = new BatteryMutable(new Battery.Builder
|
||||
{
|
||||
MaxChargeBars = null,
|
||||
CurrentChargeBars = null,
|
||||
CurrentChargePercent = 20.0
|
||||
}.Build());
|
||||
|
||||
battery.CurrentChargeBars = 4;
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargePercent,
|
||||
Is.EqualTo(20.0));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue