mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 15:46:29 +01:00
259 lines
8 KiB
C#
259 lines
8 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"" : {
|
|
""co2saving"" : ""Einsparung: 1,95 kg CO2 und 3,00 EUR bei einer Strecke von 10 KM""
|
|
}
|
|
}");
|
|
|
|
var bookingFinshed = response.shareejson.Create();
|
|
|
|
Assert.That(
|
|
bookingFinshed.Co2Saving,
|
|
Is.EqualTo("Einsparung: 1,95 kg CO2 und 3,00 EUR bei einer Strecke von 10 KM"));
|
|
|
|
}
|
|
/// <summary>
|
|
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
|
/// </summary>
|
|
[Test]
|
|
public void TestCreateMiniSurvey()
|
|
{
|
|
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
|
{
|
|
""shareejson"" : {
|
|
""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"" : {
|
|
}
|
|
}
|
|
|
|
");
|
|
|
|
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"" : {
|
|
},
|
|
}
|
|
}
|
|
|
|
");
|
|
|
|
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"" : {
|
|
""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"" : {
|
|
""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));
|
|
}
|
|
|
|
}
|
|
}
|