mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 03:27:29 +02:00
Mini survey added.
Minor fiexes.
This commit is contained in:
parent
ddfea49ea6
commit
e321764119
73 changed files with 1628 additions and 185 deletions
70
TestShareeLib/Repository/Request/TestRequestBuilder.cs
Normal file
70
TestShareeLib/Repository/Request/TestRequestBuilder.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
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").DoAuthorization("abc@cde", "+?", "789"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoAuthout()
|
||||
{
|
||||
Assert.Throws<CallNotRequiredException>(() =>
|
||||
new RequestBuilder("123").DoAuthout());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetBikesAvailable()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=bikes_available&system=all&authcookie=123",
|
||||
new RequestBuilder("123").GetBikesAvailable());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetBikesOccupied()
|
||||
{
|
||||
Assert.Throws< NotSupportedException>(() =>
|
||||
new RequestBuilder("123").GetBikesOccupied());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetStations()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=stations_available&authcookie=123",
|
||||
new RequestBuilder("123").GetStations());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoReserve()
|
||||
{
|
||||
Assert.Throws<NotSupportedException>(() =>
|
||||
new RequestBuilder("123").DoReserve("42"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoCancelReservation()
|
||||
{
|
||||
Assert.Throws<NotSupportedException>(() =>
|
||||
new RequestBuilder("123").DoCancelReservation("42"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoSubmitFeedback()
|
||||
{
|
||||
Assert.Throws<NotSupportedException>(() =>
|
||||
new RequestBuilder("123").DoSubmitFeedback("bike3", "Hi", false));
|
||||
}
|
||||
}
|
||||
}
|
145
TestShareeLib/Repository/Request/TestRequestBuilderLoggedIn.cs
Normal file
145
TestShareeLib/Repository/Request/TestRequestBuilderLoggedIn.cs
Normal file
|
@ -0,0 +1,145 @@
|
|||
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 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"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue