sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/Connector/Request/TestRequestBuilderLoggedIn.cs
2021-07-12 21:31:46 +02:00

112 lines
3.7 KiB
C#

using NUnit.Framework;
using System;
using TINK.Repository.Exception;
using TINK.Repository.Request;
namespace TestTINKLib.Fixtures.ObjectTests.Connector.Request
{
[TestFixture]
public class TestRequestBuilderLoggedIn
{
[Test]
public void TestDoAuthorize()
{
Assert.Throws <CallNotRequiredException>(() =>new RequestBuilderLoggedIn("123", "456").DoAuthorization("abc@cde", "+?", "789"));
}
[Test]
public void TestDoAuthout()
{
Assert.AreEqual(
"request=authout&authcookie=456123",
new RequestBuilderLoggedIn ("123", "456").DoAuthout());
}
[Test]
public void TestGetBikesAvailable()
{
Assert.AreEqual(
"request=bikes_available&system=all&authcookie=456123",
new RequestBuilderLoggedIn("123", "456").GetBikesAvailable());
}
[Test]
public void TestGetBikesAvailable_Null()
{
Assert.Throws<ArgumentException>(() =>
new RequestBuilderLoggedIn("123", null).GetBikesAvailable());
Assert.Throws<ArgumentException>(() =>
new RequestBuilderLoggedIn("123", string.Empty).GetBikesAvailable());
}
[Test]
public void TestGetBikesOccupied()
{
Assert.AreEqual(
"request=user_bikes_occupied&system=all&genkey=1&authcookie=456123",
new RequestBuilderLoggedIn("123", "456").GetBikesOccupied());
}
[Test]
public void TestGetBikesOccupied_Null()
{
Assert.Throws<ArgumentException>(() =>
new RequestBuilderLoggedIn("123", null).GetBikesOccupied());
Assert.Throws<ArgumentException>(() =>
new RequestBuilderLoggedIn("123", "").GetBikesOccupied());
}
[Test]
public void TestGetStations()
{
Assert.AreEqual(
"request=stations_available&authcookie=456123",
new RequestBuilderLoggedIn("123", "456").GetStations());
}
[Test]
public void TestGetStations_Null()
{
Assert.Throws<ArgumentException>(() =>
new RequestBuilderLoggedIn("123", string.Empty).GetStations());
Assert.Throws<ArgumentException>(() =>
new RequestBuilderLoggedIn("123", null).GetStations());
}
[Test]
public void TestDoReserve()
{
Assert.AreEqual(
"request=booking_request&bike=42&authcookie=456123",
new RequestBuilderLoggedIn("123", "456").DoReserve("42"));
}
[Test]
public void TestDoCancelReservation()
{
Assert.AreEqual(
"request=booking_cancel&bike=42&authcookie=456123",
new RequestBuilderLoggedIn("123", "456").DoCancelReservation("42"));
}
[Test]
public void TestDoBook()
{
Assert.AreEqual(
"request=booking_update&bike=42&authcookie=456123&Ilockit_GUID=0000f00d-1212-efde-1523-785fef13d123&state=occupied&lock_state=unlocked&voltage=33.21",
new RequestBuilderLoggedIn("123", "456").DoBook("42", new Guid("0000f00d-1212-efde-1523-785fef13d123"),33.21));
}
[Test]
public void TestDoBookNoBatery()
{
Assert.AreEqual(
"request=booking_update&bike=42&authcookie=456123&Ilockit_GUID=0000f00d-1212-efde-1523-785fef13d123&state=occupied&lock_state=unlocked",
new RequestBuilderLoggedIn("123", "456").DoBook("42", new Guid("0000f00d-1212-efde-1523-785fef13d123"), double.NaN));
}
}
}