sharee.bike-App/TestShareeLib/Model/TestBikeCollectionFilter.cs
2023-04-19 12:14:14 +02:00

129 lines
3.5 KiB
C#

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