mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-19 16:46:26 +01:00
271 lines
8.1 KiB
C#
271 lines
8.1 KiB
C#
using Newtonsoft.Json;
|
|
using NUnit.Framework;
|
|
using TINK.Model.Connector.Updater;
|
|
using TINK.Repository.Response;
|
|
|
|
|
|
namespace TestShareeLib.Model.Connector.Updater
|
|
{
|
|
[TestFixture]
|
|
public class TestBookingFinishedModelFactory
|
|
{
|
|
/// <summary>
|
|
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
|
/// </summary>
|
|
[Test]
|
|
public void TestCreateMiniSurvey_Co2Saving()
|
|
{
|
|
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
|
{
|
|
""shareejson"" : {
|
|
""bike_returned"" : {
|
|
""co2saving"" : ""1,95 kg CO2""
|
|
}
|
|
}
|
|
}");
|
|
|
|
var bookingFinshed = response.shareejson.Create();
|
|
|
|
Assert.That(
|
|
bookingFinshed.Co2Saving,
|
|
Is.EqualTo("1,95 kg CO2"));
|
|
|
|
}
|
|
/// <summary>
|
|
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
|
/// </summary>
|
|
[Test]
|
|
public void TestCreateMiniSurvey()
|
|
{
|
|
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
|
{
|
|
""shareejson"" : {
|
|
""bike_returned"" : {
|
|
},
|
|
""user_miniquery"" : {
|
|
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
|
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
|
""questions"" : {
|
|
""q3"" : {
|
|
""quest_text"" : ""3. Haben Sie Anmerkungen oder Anregungen?"",
|
|
""type"" : ""text"",
|
|
""query"" : {
|
|
""opt1"" : """"
|
|
}
|
|
},
|
|
""q1"" : {
|
|
""type"" : ""check_one"",
|
|
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
|
""query"" : {
|
|
""opt2"" : ""b. Kinderbeförderung"",
|
|
""opt5"" : ""e. Ausprobieren"",
|
|
""opt4"" : ""d. Freizeit"",
|
|
""opt1"" : ""a. Einkauf"",
|
|
""opt3"" : ""c. Lastentransport"",
|
|
""opt6"" : ""f. Sonstiges""
|
|
}
|
|
},
|
|
""q2"" : {
|
|
""type"" : ""check_one"",
|
|
""quest_text"" : ""2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?"",
|
|
""query"" : {
|
|
""opt6"" : ""f. Keines (ich hätte die Fahrt sonst nicht gemacht)"",
|
|
""opt3"" : ""c. Bus oder Bahn"",
|
|
""opt1"" : ""a. Auto"",
|
|
""opt2"" : ""b. Motorrad oder Motorroller"",
|
|
""opt7"" : ""g. Sonstige"",
|
|
""opt4"" : ""d. Eigenes Fahrrad"",
|
|
""opt5"" : ""e. Zu Fuß""
|
|
}
|
|
}
|
|
},
|
|
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
|
},
|
|
}
|
|
}
|
|
|
|
");
|
|
|
|
var bookingFinished = response.shareejson.Create();
|
|
|
|
Assert.That(
|
|
bookingFinished,
|
|
Is.Not.Null);
|
|
|
|
Assert.That(
|
|
bookingFinished.MiniSurvey.Title,
|
|
Is.EqualTo("Bitte unterstützen Sie unsere Begleitforschung"));
|
|
|
|
Assert.That(
|
|
bookingFinished.MiniSurvey.Subtitle,
|
|
Is.EqualTo("Ihre drei Antworten werden anonym gespeichert."));
|
|
|
|
Assert.That(
|
|
bookingFinished.MiniSurvey.Footer,
|
|
Is.EqualTo("Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"));
|
|
|
|
Assert.That(
|
|
bookingFinished.MiniSurvey.Questions.Count,
|
|
Is.EqualTo(3));
|
|
}
|
|
|
|
/// <summary>
|
|
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
|
/// </summary>
|
|
[Test]
|
|
public void TestCreateMiniSurvey_Null()
|
|
{
|
|
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
|
{
|
|
""shareejson"" : {
|
|
""bike_returned"" : {
|
|
},
|
|
}
|
|
}
|
|
|
|
");
|
|
|
|
var bookingFinshed = response.shareejson.Create();
|
|
|
|
Assert.That(
|
|
bookingFinshed,
|
|
Is.Not.Null);
|
|
|
|
Assert.That(
|
|
bookingFinshed.MiniSurvey.Questions.Count,
|
|
Is.EqualTo(0));
|
|
|
|
Assert.That(
|
|
bookingFinshed.MiniSurvey.Title,
|
|
Is.Null);
|
|
|
|
Assert.That(
|
|
bookingFinshed.MiniSurvey.Subtitle,
|
|
Is.Null);
|
|
|
|
Assert.That(
|
|
bookingFinshed.MiniSurvey.Footer,
|
|
Is.Null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
|
/// </summary>
|
|
[Test]
|
|
public void TestCreateMiniSurvey_EmptyQuery()
|
|
{
|
|
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
|
{
|
|
""shareejson"" : {
|
|
""user_miniquery"" : {
|
|
},
|
|
""bike_returned"" : {
|
|
},
|
|
}
|
|
}
|
|
|
|
");
|
|
|
|
var bookingFinished = response.shareejson.Create();
|
|
|
|
Assert.That(
|
|
bookingFinished,
|
|
Is.Not.Null);
|
|
|
|
Assert.That(
|
|
bookingFinished.MiniSurvey.Title,
|
|
Is.Null);
|
|
|
|
Assert.That(
|
|
bookingFinished.MiniSurvey.Subtitle,
|
|
Is.Null);
|
|
|
|
Assert.That(
|
|
bookingFinished.MiniSurvey.Footer,
|
|
Is.Null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
|
/// </summary>
|
|
[Test]
|
|
public void TestCreateMiniSurvey_InvalidQuestion_KeyNull()
|
|
{
|
|
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
|
{
|
|
""shareejson"" : {
|
|
""bike_returned"" : {
|
|
},
|
|
""user_miniquery"" : {
|
|
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
|
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
|
""questions"" : {
|
|
"""" : {
|
|
""type"" : ""check_one"",
|
|
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
|
""query"" : {
|
|
""opt2"" : ""b. Kinderbeförderung"",
|
|
""opt5"" : ""e. Ausprobieren"",
|
|
""opt4"" : ""d. Freizeit"",
|
|
""opt1"" : ""a. Einkauf"",
|
|
""opt3"" : ""c. Lastentransport"",
|
|
""opt6"" : ""f. Sonstiges""
|
|
}
|
|
},
|
|
},
|
|
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
|
},
|
|
}
|
|
}
|
|
|
|
");
|
|
|
|
var bookingFinised = response.shareejson.Create();
|
|
|
|
Assert.That(
|
|
bookingFinised,
|
|
Is.Not.Null);
|
|
|
|
Assert.That(
|
|
bookingFinised.MiniSurvey.Questions.Count,
|
|
Is.EqualTo(0));
|
|
}
|
|
|
|
/// <summary>
|
|
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
|
/// </summary>
|
|
[Test]
|
|
public void TestCreateMiniSurvey_InvalidQuestion_ValueNull()
|
|
{
|
|
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
|
{
|
|
""shareejson"" : {
|
|
""bike_returned"" : {
|
|
},
|
|
""user_miniquery"" : {
|
|
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
|
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
|
""questions"" : {
|
|
""q1"" : {
|
|
},
|
|
},
|
|
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
|
},
|
|
}
|
|
}
|
|
|
|
");
|
|
|
|
var bookingFinished = response.shareejson.Create();
|
|
|
|
Assert.That(
|
|
bookingFinished,
|
|
Is.Not.Null);
|
|
|
|
Assert.That(
|
|
bookingFinished.MiniSurvey.Questions.Count,
|
|
Is.EqualTo(0));
|
|
}
|
|
|
|
}
|
|
}
|