mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 23:56:26 +01:00
124 lines
5.7 KiB
C#
124 lines
5.7 KiB
C#
using NUnit.Framework;
|
|
using System;
|
|
using TINK.Repository.Request;
|
|
|
|
namespace TestTINKLib.Fixtures.ObjectTests.Model.Repository.Request
|
|
{
|
|
[TestFixture]
|
|
public class TestRequestBuilderLoggedIn
|
|
{
|
|
[Test]
|
|
public void TestUpateLockingStateGeolocationIsNull()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.UpateLockingState("12", lock_state.locked, null, 15.03),
|
|
Is.EqualTo("request=booking_update&bike=12&lock_state=locked&voltage=15.03&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestUpateLockingStateGeolocationIsNullBatteryPercentageIsNAN()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.UpateLockingState("12", lock_state.locked, null, double.NaN),
|
|
Is.EqualTo("request=booking_update&bike=12&lock_state=locked&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestUpateLockingStateGeolocation_AccuraycyNull()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.UpateLockingState("12", lock_state.locked, new LocationDto.Builder { Latitude = 21, Longitude = 17, Age = new TimeSpan(0, 0, 0, 0, 70) }.Build(), 12),
|
|
Is.EqualTo("request=booking_update&bike=12&gps=21,17&gps_age=0.07&lock_state=locked&voltage=12&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestUpateLockingStateGeolocation_AccuraycyNullBatteryPercentageIsNAN()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.UpateLockingState("12", lock_state.locked, new LocationDto.Builder { Latitude = 21, Longitude = 17, Age = new TimeSpan(0, 0, 0, 0, 70) }.Build(), double.NaN),
|
|
Is.EqualTo("request=booking_update&bike=12&gps=21,17&gps_age=0.07&lock_state=locked&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestUpateLockingStateGeolocation()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.UpateLockingState("12", lock_state.locked, new LocationDto.Builder { Latitude = 21, Longitude = 17, Accuracy = 5.7, Age = new TimeSpan(0, 0, 0, 0, 70) }.Build(), 98),
|
|
Is.EqualTo("request=booking_update&bike=12&gps=21,17&gps_accuracy=5.7&gps_age=0.07&lock_state=locked&voltage=98&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoReturnGeolocationIsNull()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.DoReturn("12", null, null),
|
|
Is.EqualTo("request=booking_update&bike=12&authcookie=MySessionCookieMyMeranctIt&state=available&lock_state=locked"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoReturnGeolocation_AccuraycyNull()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.DoReturn(
|
|
"12",
|
|
new LocationDto.Builder { Latitude = 21, Longitude = 17, Age = new TimeSpan(0, 0, 0, 0, 70) }.Build(),
|
|
null),
|
|
Is.EqualTo("request=booking_update&bike=12&authcookie=MySessionCookieMyMeranctIt&state=available&gps=21,17&gps_age=0.07&lock_state=locked"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoReturnGeolocation()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.DoReturn(
|
|
"12",
|
|
new LocationDto.Builder { Latitude = 21, Longitude = 17, Accuracy = 5.7, Age = new TimeSpan(0, 0, 0, 0, 70) }.Build(),
|
|
null),
|
|
Is.EqualTo("request=booking_update&bike=12&authcookie=MySessionCookieMyMeranctIt&state=available&gps=21,17&gps_accuracy=5.7&gps_age=0.07&lock_state=locked"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoSubmitFeedback_Ok()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.DoSubmitFeedback("Radl22"),
|
|
Is.EqualTo("request=user_feedback&bike=Radl22&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoSubmitFeedback_BikeBroken()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.DoSubmitFeedback("Cycle33", isBikeBroken: true),
|
|
Is.EqualTo("request=user_feedback&bike=Cycle33&bike_broken=1&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoSubmitFeedback_Message()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.DoSubmitFeedback("Mühle", "Uno due tre"),
|
|
Is.EqualTo("request=user_feedback&bike=Mühle&message=Uno+due+tre&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDoSubmitFeedback_ErrorMessage()
|
|
{
|
|
var builder = new RequestBuilderLoggedIn("MyMeranctIt", "MySessionCookie");
|
|
Assert.That(
|
|
builder.DoSubmitFeedback("bike12","Uno due tre", true),
|
|
Is.EqualTo("request=user_feedback&bike=bike12&bike_broken=1&message=Uno+due+tre&authcookie=MySessionCookieMyMeranctIt"));
|
|
}
|
|
}
|
|
}
|