2023-04-19 12:14:14 +02:00
|
|
|
using NUnit.Framework;
|
2024-04-09 12:53:23 +02:00
|
|
|
using ShareeBike.Model;
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
namespace SharedBusinessLogic.Tests.Model
|
2022-01-22 18:16:10 +01:00
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
[TestFixture]
|
|
|
|
public class TestPosition
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TestEquals()
|
|
|
|
{
|
2023-04-19 12:14:14 +02:00
|
|
|
var positionA = PositionFactory.Create(12, 13);
|
|
|
|
var positionB = PositionFactory.Create(12, 13);
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2023-04-19 12:14:14 +02:00
|
|
|
Assert.That(positionA.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
|
|
|
Assert.That(positionB.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
Assert.That(
|
2023-04-19 12:14:14 +02:00
|
|
|
positionA.Equals(positionB),
|
2022-09-06 16:08:19 +02:00
|
|
|
Is.True);
|
|
|
|
}
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestEqualsNotEquaLong()
|
|
|
|
{
|
2023-04-19 12:14:14 +02:00
|
|
|
var positionA = PositionFactory.Create(12, 13);
|
|
|
|
var positionB = PositionFactory.Create(13, 13);
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2023-04-19 12:14:14 +02:00
|
|
|
Assert.That(positionA.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
|
|
|
Assert.That(positionB.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
Assert.That(
|
2023-04-19 12:14:14 +02:00
|
|
|
positionA.Equals(positionB),
|
2022-09-06 16:08:19 +02:00
|
|
|
Is.False);
|
|
|
|
}
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestEqualsNotEquaLat()
|
|
|
|
{
|
2023-04-19 12:14:14 +02:00
|
|
|
var positionA = PositionFactory.Create(12, 13);
|
|
|
|
var positionB = PositionFactory.Create(12, 12);
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2023-04-19 12:14:14 +02:00
|
|
|
Assert.That(positionA.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
|
|
|
Assert.That(positionB.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
Assert.That(
|
2023-04-19 12:14:14 +02:00
|
|
|
positionA.Equals(positionB),
|
2022-09-06 16:08:19 +02:00
|
|
|
Is.False);
|
|
|
|
}
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestGetIsValid()
|
|
|
|
{
|
|
|
|
Assert.That(
|
|
|
|
Position.GetIsValid(1, 2),
|
|
|
|
Is.True);
|
|
|
|
}
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestGetIsValidInvalidLong()
|
|
|
|
{
|
|
|
|
Assert.That(
|
|
|
|
Position.GetIsValid(double.NaN, 2),
|
|
|
|
Is.False);
|
|
|
|
}
|
2022-01-22 18:16:10 +01:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestGetIsValidInvalidLat()
|
|
|
|
{
|
|
|
|
Assert.That(
|
|
|
|
Position.GetIsValid(2, double.NaN),
|
|
|
|
Is.False);
|
|
|
|
}
|
|
|
|
}
|
2022-01-22 18:16:10 +01:00
|
|
|
}
|