sharee.bike-App/TestShareeLib/Model/TestBikeCollectionFilter.cs

89 lines
2.8 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
2021-05-13 20:09:46 +02:00
using System.Collections.Generic;
2022-08-30 15:42:25 +02:00
using NUnit.Framework;
2021-05-13 20:09:46 +02:00
using TINK.Model;
2022-08-30 15:42:25 +02:00
using TINK.Model.Bikes;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
2021-05-13 20:09:46 +02:00
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
2022-09-06 16:08:19 +02:00
[TestFixture]
public class TestBikeCollectionFilter
{
[Test]
public void TestGetAtStation()
{
var coll = new BikeCollection(
new Dictionary<string, TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo>
{
{"3", new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("7", LockModel.ILockIt), new Drive(), "3" /* Stadion id */) },
{"7", new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt), new Drive(), "12" /* Stadion id */) },
{"12", new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt), new Drive(), "12" /* Stadion id */) }
});
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.AreEqual(
0,
BikeCollectionFilter.GetAtStation(null, "12").Count);
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.AreEqual(
0,
coll.GetAtStation(null).Count);
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.AreEqual(
0,
coll.GetAtStation("22").Count);
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.AreEqual(
1,
coll.GetAtStation("3").Count);
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.AreEqual(
2,
coll.GetAtStation("12").Count);
}
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestGetLockIt_Null()
{
Assert.That(
BikeCollectionFilter.GetLockIt(null).Count,
Is.EqualTo(0));
}
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestGetLockIt_NoLockIt()
{
// Holds no LockIt bikes
var coll = new BikeCollection(
new Dictionary<string, TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo>
{
{"7", new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt), new Drive(), "12" /* Stadion id */) },
{"12", new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt), new Drive(), "12" /* Stadion id */) }
});
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.AreEqual(
0,
coll.GetLockIt().Count);
}
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestGetLockIt()
{
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
// Holds no LockIt bike with matching station number.
var coll = new BikeCollection(
new Dictionary<string, TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo>
{
{"7", new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt), new Drive(), "12" /* Stadion id */) },
{"11", new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt), new Drive(), 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "12" /* Stadion id */) },
{"12", new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt), new Drive(), "12" /* Stadion id */) }
});
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.AreEqual(
1,
coll.GetLockIt().Count);
}
}
2021-05-13 20:09:46 +02:00
}