sharee.bike-App/TestShareeLib/Repository/Request/TestRequestBuilder.cs

94 lines
2.4 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
using NUnit.Framework;
2021-07-12 21:31:46 +02:00
using TINK.Repository.Exception;
using TINK.Repository.Request;
2021-08-01 17:24:15 +02:00
namespace TestShareeLib.Repository.Request
2021-07-12 21:31:46 +02:00
{
2022-09-06 16:08:19 +02:00
[TestFixture]
public class TestRequestBuilder
{
[Test]
public void TestDoAuthorize()
{
Assert.AreEqual(
"request=authorization&merchant_id=123&user_id=abc%40cde&user_pw=%2B%3F&hw_id=789",
new RequestBuilder("123", null /*UI language */).DoAuthorization("abc@cde", "+?", "789"));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestDoAuthorizeLangfr()
{
Assert.That(
new RequestBuilder("123", "fr" /*UI language */).DoAuthorization("abc@cde", "+?", "789"),
Is.EqualTo("request=authorization&merchant_id=123&user_id=abc%40cde&user_pw=%2B%3F&hw_id=789&lang=fr"));
}
[Test]
public void TestDoAuthout()
{
Assert.Throws<CallNotRequiredException>(() =>
new RequestBuilder("123", null /*UI language */).DoAuthout());
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestGetBikesAvailable()
{
Assert.AreEqual(
"request=bikes_available&system=all&authcookie=123",
new RequestBuilder("123", null /*UI language */).GetBikesAvailable());
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestGetBikesAvailableLangUk()
{
Assert.That(
new RequestBuilder("123", "uk").GetBikesAvailable(),
Is.EqualTo("request=bikes_available&system=all&authcookie=123&lang=uk"));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestGetBikesOccupied()
{
Assert.Throws<NotSupportedException>(() =>
new RequestBuilder("123", null /*UI language */).GetBikesOccupied());
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestGetStations()
{
Assert.AreEqual(
"request=stations_available&authcookie=123",
new RequestBuilder("123", null /*UI language */).GetStations());
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestGetStationsLangDe()
{
Assert.That(
new RequestBuilder("123", "de").GetStations(),
Is.EqualTo("request=stations_available&authcookie=123&lang=de"));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestDoReserve()
{
Assert.Throws<NotSupportedException>(() =>
new RequestBuilder("123", null /*UI language */).DoReserve("42"));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestDoCancelReservation()
{
Assert.Throws<NotSupportedException>(() =>
new RequestBuilder("123", null /*UI language */).DoCancelReservation("42"));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestDoSubmitFeedback()
{
Assert.Throws<NotSupportedException>(() =>
new RequestBuilder("123", null /*UI language */).DoSubmitFeedback("bike3", 3, "Hi", false));
}
}
2021-07-12 21:31:46 +02:00
}