mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 10:36:30 +01:00
e321764119
Minor fiexes.
153 lines
5.5 KiB
C#
153 lines
5.5 KiB
C#
using Newtonsoft.Json;
|
|
using NUnit.Framework;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization;
|
|
using TINK.Repository.Response;
|
|
|
|
namespace TestShareeLib.Repository.Response
|
|
{
|
|
[TestFixture]
|
|
public class TestMiniSurvey
|
|
{
|
|
[DataContract]
|
|
public class MiniSurveyTestContainer
|
|
{
|
|
[DataMember]
|
|
public MiniSurveyResponse user_miniquery { get; set;}
|
|
}
|
|
|
|
[Test]
|
|
public void TestCtor()
|
|
{
|
|
var mini = JsonConvert.DeserializeObject<MiniSurveyTestContainer>(@"{
|
|
""user_miniquery"" : {
|
|
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
|
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert."",
|
|
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
|
""questions"" : {
|
|
""q1"" : {
|
|
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
|
""type"" : ""check_one"",
|
|
""query"" : {
|
|
""opt5"" : ""e. Ausprobieren"",
|
|
""opt3"" : ""c. Lastentransport"",
|
|
""opt6"" : ""f. Sonstiges"",
|
|
""opt1"" : ""a. Einkauf"",
|
|
""opt4"" : ""d. Freizeit"",
|
|
""opt2"" : ""b. Kinderbeförderung""
|
|
}
|
|
},
|
|
""q2"" : {
|
|
""type"" : ""check_one"",
|
|
""quest_text"" : ""2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?"",
|
|
""query"" : {
|
|
""opt1"" : ""a. Auto"",
|
|
""opt7"" : ""g. Sonstige"",
|
|
""opt2"" : ""b. Motorrad oder Motorroller"",
|
|
""opt4"" : ""d. Eigenes Fahrrad"",
|
|
""opt6"" : ""f. Keines (ich hätte die Fahrt sonst nicht gemacht)"",
|
|
""opt5"" : ""e. Zu Fuß"",
|
|
""opt3"" : ""c. Bus oder Bahn""
|
|
},
|
|
},
|
|
""q3"" : {
|
|
""type"" : ""text"",
|
|
""quest_text"" : ""3. Haben Sie Anmerkungen oder Anregungen?"",
|
|
""query"" : {
|
|
""opt1"" : """"
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}");
|
|
|
|
Assert.That(
|
|
mini.user_miniquery.title,
|
|
Is.EqualTo("Bitte unterstützen Sie unsere Begleitforschung"));
|
|
|
|
Assert.That(
|
|
mini.user_miniquery.subtitle,
|
|
Is.EqualTo("Ihre drei Antworten werden anonym gespeichert."));
|
|
|
|
Assert.That(
|
|
mini.user_miniquery.subtitle,
|
|
Is.EqualTo("Ihre drei Antworten werden anonym gespeichert."));
|
|
|
|
Assert.That(
|
|
mini.user_miniquery.questions.Count,
|
|
Is.EqualTo(3));
|
|
|
|
Assert.That(
|
|
mini.user_miniquery.questions.Count,
|
|
Is.EqualTo(3));
|
|
|
|
// Verify first question.
|
|
var query = mini.user_miniquery.questions.OrderBy(x => x.Key).ToArray()[0];
|
|
|
|
Assert.That(
|
|
query.Value.quest_text,
|
|
Is.EqualTo("1. Was war der Hauptzweck dieser Ausleihe?"));
|
|
|
|
Assert.That(
|
|
query.Value.type,
|
|
Is.EqualTo("check_one"));
|
|
|
|
Assert.That(
|
|
query.Value.query.Count,
|
|
Is.EqualTo(6));
|
|
|
|
var answer = query.Value.query.OrderBy(x => x.Key).ToArray()[0];
|
|
|
|
Assert.That(
|
|
answer.Value,
|
|
Is.EqualTo("a. Einkauf"));
|
|
|
|
answer = query.Value.query.OrderBy(x => x.Key).ToArray()[2];
|
|
Assert.That(
|
|
answer.Value,
|
|
Is.EqualTo("c. Lastentransport"));
|
|
|
|
// Verify second question.
|
|
query = mini.user_miniquery.questions.OrderBy(x => x.Key).ToArray()[1];
|
|
|
|
Assert.That(
|
|
query.Value.quest_text,
|
|
Is.EqualTo("2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?"));
|
|
|
|
Assert.That(
|
|
query.Value.type,
|
|
Is.EqualTo("check_one"));
|
|
|
|
Assert.That(
|
|
query.Value.query.Count,
|
|
Is.EqualTo(7));
|
|
|
|
answer = query.Value.query.OrderBy(x => x.Key).ToArray()[1];
|
|
|
|
Assert.That(
|
|
answer.Value,
|
|
Is.EqualTo("b. Motorrad oder Motorroller"));
|
|
|
|
// Verify thired question.
|
|
query = mini.user_miniquery.questions.OrderBy(x => x.Key).ToArray()[2];
|
|
|
|
Assert.That(
|
|
query.Value.quest_text,
|
|
Is.EqualTo("3. Haben Sie Anmerkungen oder Anregungen?"));
|
|
|
|
Assert.That(
|
|
query.Value.type,
|
|
Is.EqualTo("text"));
|
|
|
|
Assert.That(
|
|
query.Value.query.Count,
|
|
Is.EqualTo(1));
|
|
|
|
answer = query.Value.query.OrderBy(x => x.Key).ToArray()[0];
|
|
|
|
Assert.That(
|
|
answer.Value,
|
|
Is.EqualTo(""));
|
|
}
|
|
}
|
|
}
|