mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 10:36:30 +01:00
108 lines
2.8 KiB
C#
108 lines
2.8 KiB
C#
using System;
|
|
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using TINK.Model.Device;
|
|
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 TestGetStationsSmartDeviceManufacturer()
|
|
{
|
|
var sd = Substitute.For<ISmartDevice>();
|
|
sd.Manufacturer.Returns("Färphone");
|
|
|
|
Assert.AreEqual(
|
|
"request=stations_available&authcookie=123&user_device_manufacturer=F%C3%A4rphone",
|
|
new RequestBuilder("123", null /*UI language */, sd).GetStations());
|
|
}
|
|
|
|
[Test]
|
|
public void TestGetStationsLangOes()
|
|
{
|
|
Assert.That(
|
|
new RequestBuilder(
|
|
"MärchantId",
|
|
"öe" /* this non exisiting language id verifies urlencoding */).GetStations(),
|
|
Is.EqualTo("request=stations_available&authcookie=M%C3%A4rchantId&lang=%C3%B6e"));
|
|
}
|
|
|
|
[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));
|
|
}
|
|
}
|
|
}
|