mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-24 13:46:30 +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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using NSubstitute;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
|
@ -12,7 +12,7 @@ namespace TestShareeLib.Model.BikeInfo.DriveNS
|
|||
[Test]
|
||||
public void TestCtorNoArgs()
|
||||
{
|
||||
var drive = new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive();
|
||||
var drive = new DriveMutable();
|
||||
Assert.That(
|
||||
drive.Type,
|
||||
Is.EqualTo(DriveType.SoleHumanPowered));
|
||||
|
@ -35,7 +35,7 @@ namespace TestShareeLib.Model.BikeInfo.DriveNS
|
|||
engine.Manufacturer.Returns("Bosch");
|
||||
battery.CurrentChargePercent.Returns(97);
|
||||
|
||||
var drive = new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(engine, battery);
|
||||
var drive = new DriveMutable(engine, battery);
|
||||
|
||||
Assert.That(
|
||||
drive.Engine.Manufacturer,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue