mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-07-08 12:36:31 +02:00
Version 3.0.381
This commit is contained in:
parent
f963c0a219
commit
3a363acf3a
1525 changed files with 60589 additions and 125098 deletions
|
@ -0,0 +1,49 @@
|
|||
using NUnit.Framework;
|
||||
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
|
||||
namespace SharedBusinessLogic.Tests.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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
using NUnit.Framework;
|
||||
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
|
||||
namespace SharedBusinessLogic.Tests.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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS.EngineNS;
|
||||
using DriveType = ShareeBike.Model.Bikes.BikeInfoNS.DriveNS.DriveType;
|
||||
|
||||
namespace SharedBusinessLogic.Tests.Model.BikeInfo.DriveNS
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestDriveMutable
|
||||
{
|
||||
[Test]
|
||||
public void TestCtorNoArgs()
|
||||
{
|
||||
var drive = new DriveMutable();
|
||||
Assert.That(
|
||||
drive.Type,
|
||||
Is.EqualTo(DriveType.SoleHumanPowered));
|
||||
|
||||
Assert.That(
|
||||
drive.Engine,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
drive.Battery,
|
||||
Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtor()
|
||||
{
|
||||
var engine = Substitute.For<IEngine>();
|
||||
var battery = Substitute.For<IBattery>();
|
||||
|
||||
engine.Manufacturer.Returns("Bosch");
|
||||
battery.CurrentChargePercent.Returns(97);
|
||||
|
||||
var drive = new DriveMutable(engine, battery);
|
||||
|
||||
Assert.That(
|
||||
drive.Engine.Manufacturer,
|
||||
Is.EqualTo("Bosch"));
|
||||
|
||||
Assert.That(
|
||||
drive.Battery.CurrentChargePercent,
|
||||
Is.EqualTo(97));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue