sharee.bike-App/TestShareeLib/Repository/Request/TestRequestBuilder.cs
Anja Müller-Meißner 0468955d49 Version 3.0.338
2022-09-08 09:55:14 +02:00

93 lines
2.4 KiB
C#

using System;
using NUnit.Framework;
using TINK.Repository.Exception;
using TINK.Repository.Request;
namespace TestShareeLib.Repository.Request
{
[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"));
}
[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());
}
[Test]
public void TestGetBikesAvailable()
{
Assert.AreEqual(
"request=bikes_available&system=all&authcookie=123",
new RequestBuilder("123", null /*UI language */).GetBikesAvailable());
}
[Test]
public void TestGetBikesAvailableLangUk()
{
Assert.That(
new RequestBuilder("123", "uk").GetBikesAvailable(),
Is.EqualTo("request=bikes_available&system=all&authcookie=123&lang=uk"));
}
[Test]
public void TestGetBikesOccupied()
{
Assert.Throws<NotSupportedException>(() =>
new RequestBuilder("123", null /*UI language */).GetBikesOccupied());
}
[Test]
public void TestGetStations()
{
Assert.AreEqual(
"request=stations_available&authcookie=123",
new RequestBuilder("123", null /*UI language */).GetStations());
}
[Test]
public void TestGetStationsLangDe()
{
Assert.That(
new RequestBuilder("123", "de").GetStations(),
Is.EqualTo("request=stations_available&authcookie=123&lang=de"));
}
[Test]
public void TestDoReserve()
{
Assert.Throws<NotSupportedException>(() =>
new RequestBuilder("123", null /*UI language */).DoReserve("42"));
}
[Test]
public void TestDoCancelReservation()
{
Assert.Throws<NotSupportedException>(() =>
new RequestBuilder("123", null /*UI language */).DoCancelReservation("42"));
}
[Test]
public void TestDoSubmitFeedback()
{
Assert.Throws<NotSupportedException>(() =>
new RequestBuilder("123", null /*UI language */).DoSubmitFeedback("bike3", 3, "Hi", false));
}
}
}