mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-16 15:16:34 +01:00
161 lines
5.7 KiB
C#
161 lines
5.7 KiB
C#
using NUnit.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using TINK.Repository.Exception;
|
|
using TINK.Repository.Request;
|
|
|
|
namespace TestShareeLib.Repository.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));
|
|
}
|
|
|
|
[Test]
|
|
public void TestBookAndStartOpening()
|
|
{
|
|
Assert.That(
|
|
new RequestBuilderLoggedIn("123", "456").BookAndStartOpening("42"),
|
|
Is.EqualTo("request=booking_request&bike=42&authcookie=456123&state=occupied&lock_state=unlocking"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestReturnAndStartClosing()
|
|
{
|
|
Assert.That(
|
|
new RequestBuilderLoggedIn("123", "456").ReturnAndStartClosing("42", null),
|
|
Is.EqualTo("request=booking_update&bike=42&authcookie=456123&state=available&lock_state=locking"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoSubmitMiniSurvey()
|
|
{
|
|
Assert.That(
|
|
new RequestBuilderLoggedIn("Merchy", "Keksi").DoSubmitMiniSurvey(new Dictionary<string, string> { { "q1", "opt5" }, { "q2", "opt4" }, { "q3", "der Freitext" } }),
|
|
Is.EqualTo("request=user_minianswer&q1=opt5&q2=opt4&q3=der+Freitext&authcookie=KeksiMerchy"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoSubmitMiniSurveyNull()
|
|
{
|
|
Assert.That(
|
|
new RequestBuilderLoggedIn("Merchy", "Keksi").DoSubmitMiniSurvey(null),
|
|
Is.EqualTo("request=user_minianswer&authcookie=KeksiMerchy"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoSubmitMiniSurveyEmptyDict()
|
|
{
|
|
Assert.That(
|
|
new RequestBuilderLoggedIn("Merchy", "Keksi").DoSubmitMiniSurvey(new Dictionary<string, string>()),
|
|
Is.EqualTo("request=user_minianswer&authcookie=KeksiMerchy"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoSubmitMiniSurveyFilterInvalidEntries()
|
|
{
|
|
Assert.That(
|
|
new RequestBuilderLoggedIn("Merchy", "Keksi").DoSubmitMiniSurvey(new Dictionary<string, string> { { "q1", "opt5" }, { "", "opt99" }, { "q99", "" }, { "q2", "opt4" }, { "q3", "der Freitext" } }),
|
|
Is.EqualTo("request=user_minianswer&q1=opt5&q2=opt4&q3=der+Freitext&authcookie=KeksiMerchy"));
|
|
}
|
|
}
|
|
}
|