sharee.bike-App/SharedBusinessLogic.Tests/Model/TestBikeCollectionFilter.cs
2024-04-09 12:53:23 +02:00

121 lines
3.7 KiB
C#

using System;
using System.Collections.Generic;
using NUnit.Framework;
using ShareeBike.Model;
using ShareeBike.Model.Bikes;
using ShareeBike.Model.Bikes.BikeInfoNS.BC;
using ShareeBike.Model.Bikes.BikeInfoNS.BikeNS;
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS;
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.Bike
{
[TestFixture]
public class TestBikeCollectionFilter
{
[Test]
public void TestGetAtStation()
{
var coll = new BikeCollection(
new Dictionary<string, BikeInfo>
{
{"3", new ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("7", LockModel.ILockIt),
new DriveMutable(),
DataSource.Copri,
17, /* Lock id */
new Guid(),
"3" /* Station id */) },
{"7", new ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt),
new DriveMutable(),
DataSource.Copri,
17, /* Lock id */
new Guid(),
"12" /* Station id */) },
{"12",
new ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt),
new DriveMutable(),
DataSource.Copri,
17, /* Lock id */
new Guid(),
"12" /* Station id */) }
});
Assert.That(
BikeCollectionFilter.GetAtStation(null, "12").Count, Is.EqualTo(0));
Assert.That(
coll.GetAtStation(null).Count, Is.EqualTo(0));
Assert.That(
coll.GetAtStation("22").Count, Is.EqualTo(0));
Assert.That(
coll.GetAtStation("3").Count, Is.EqualTo(1));
Assert.That(
coll.GetAtStation("12").Count, Is.EqualTo(2));
}
[Test]
public void TestGetLockIt_Null()
{
Assert.That(
BikeCollectionFilter.GetLockIt(null).Count,
Is.EqualTo(0));
}
[Test]
public void TestGetLockIt_NoLockIt()
{
// Holds no LockIt bikes
var coll = new BikeCollection(
new Dictionary<string, BikeInfo>
{
{"7", new ShareeBike.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt),
new DriveMutable(),
DataSource.Copri,
"12", /* Station id */
new ShareeBike.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()) },
{"12", new ShareeBike.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt),
new DriveMutable(),
DataSource.Copri,
"12", /* Station id */
new ShareeBike.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()) }
});
Assert.That(
coll.GetLockIt().Count, Is.EqualTo(0));
}
[Test]
public void TestGetLockIt()
{
// Holds no LockIt bike with matching station number.
var coll = new BikeCollection(
new Dictionary<string, BikeInfo>
{
{"7", new ShareeBike.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt),
new DriveMutable(),
DataSource.Copri,
"12", /* Station id */
new ShareeBike.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()) },
{"11", new ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt),
new DriveMutable(),
DataSource.Copri,
5200544,
new Guid("00000000-0000-0000-0000-000000000001"),
"12" /* Station id */) },
{"12", new ShareeBike.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt),
new DriveMutable(),
DataSource.Copri,
"12", /* Station id */
new ShareeBike.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()) }
});
Assert.That(
coll.GetLockIt().Count, Is.EqualTo(1));
}
}
}