From 9e2bfeca3a444d6b7b522a7f067a19bb40373856 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Mon, 18 Nov 2019 21:40:54 +0100 Subject: [PATCH 01/25] Add dropdown item and builder --- .../Builders/SurveyCheckboxItemBuilder.cs | 4 +- .../Builders/SurveyDropdownItemBuilder.cs | 78 +++++++++++++++++++ .../Builders/SurveyInputItemBuilder.cs | 4 +- .../Builders/SurveyPageBuilder.cs | 23 +++++- .../Builders/SurveyRadiogroupItemBuilder.cs | 4 +- .../Elements/SurveyDropdownItem.cs | 18 +++++ src/SurveyExtensions/Elements/SurveyItem.cs | 2 +- .../Factory/BulderFactory.cs | 45 ++++++++++- .../GeneralBuilderTests.cs | 4 +- test/SurveyExtensionsTests/JsonTests.cs | 1 + 10 files changed, 168 insertions(+), 15 deletions(-) create mode 100644 src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs create mode 100644 src/SurveyExtensions/Elements/SurveyDropdownItem.cs diff --git a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs index dba5f06..ed92a60 100644 --- a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs @@ -44,13 +44,13 @@ public SurveyCheckboxItemBuilder IsNotRequired() public SurveyCheckboxItemBuilder IsVisible() { - _item.IsVisible = true; + _item.Visible = true; return this; } public SurveyCheckboxItemBuilder IsNotVisible() { - _item.IsVisible = false; + _item.Visible = false; return this; } diff --git a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs new file mode 100644 index 0000000..e476d10 --- /dev/null +++ b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs @@ -0,0 +1,78 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + + public class SurveyDropdownItemBuilder : + SurveyItemBuilderBase, + IBuilder where TEntity : new() + { + public SurveyDropdownItemBuilder() + { + _item.Type = "dropdown"; + } + + public SurveyDropdownItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + + public SurveyDropdownItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyDropdownItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyDropdownItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyDropdownItemBuilder IsNotRequired() + { + _item.IsRequired = false; + return this; + } + + public SurveyDropdownItemBuilder IsVisible() + { + _item.Visible = true; + return this; + } + + public SurveyDropdownItemBuilder IsNotVisible() + { + _item.Visible = false; + return this; + } + + public SurveyDropdownItemBuilder SetChoicesOrder(SurveyChoicesOrderEnum order) + { + string enumName = Enum.GetName(typeof(SurveyChoicesOrderEnum), order); + if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); + return this; + } + + public SurveyDropdownItemBuilder HasOtherChoice(string choiceText) + { + _item.HasOther = true; + _item.OtherText = choiceText; + return this; + } + + public SurveyDropdownItemBuilder AddChoice(string choiceValue, string choiceText) + { + _item.Choices.Add(new SurveyChoice() { Value = choiceValue, Text = choiceText }); + return this; + } + + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs index d2ddfa1..94c62fc 100644 --- a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs @@ -45,13 +45,13 @@ public SurveyInputItemBuilder IsNotRequired() public SurveyInputItemBuilder IsVisible() { - _item.IsVisible = true; + _item.Visible = true; return this; } public SurveyInputItemBuilder IsNotVisible() { - _item.IsVisible = false; + _item.Visible = false; return this; } diff --git a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs index eaacf7d..a5b48b1 100644 --- a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs @@ -53,7 +53,7 @@ public SurveyPageBuilder AddCheckboxInput(Expression x.HasTitle(title)); } - public SurveyPageBuilder AddRadiogroupInput(Expression> expression, Action> radiogroupBuilder) + public SurveyPageBuilder AddRadiogroup(Expression> expression, Action> radiogroupBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); @@ -64,10 +64,27 @@ public SurveyPageBuilder AddRadiogroupInput(Expression AddRadiogroupInput(Expression> expression, string title) + public SurveyPageBuilder AddRadiogroup(Expression> expression, string title) { - return AddRadiogroupInput(expression, x => x.HasTitle(title)); + return AddRadiogroup(expression, x => x.HasTitle(title)); } + + public SurveyPageBuilder AddDropdown(Expression> expression, Action> radiogroupBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new SurveyDropdownItemBuilder(); + radiogroupBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public SurveyPageBuilder AddDropdown(Expression> expression, string title) + { + return AddRadiogroup(expression, x => x.HasTitle(title)); + } + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs index bec2f53..1256a8b 100644 --- a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs @@ -44,13 +44,13 @@ public SurveyRadiogroupItemBuilder IsNotRequired() public SurveyRadiogroupItemBuilder IsVisible() { - _item.IsVisible = true; + _item.Visible = true; return this; } public SurveyRadiogroupItemBuilder IsNotVisible() { - _item.IsVisible = false; + _item.Visible = false; return this; } diff --git a/src/SurveyExtensions/Elements/SurveyDropdownItem.cs b/src/SurveyExtensions/Elements/SurveyDropdownItem.cs new file mode 100644 index 0000000..17b8c9d --- /dev/null +++ b/src/SurveyExtensions/Elements/SurveyDropdownItem.cs @@ -0,0 +1,18 @@ +namespace SurveyExtensions.Elements +{ + using System.Collections.Generic; + + public class SurveyDropdownItem : SurveyPageElement + { + + public string ChoicesOrder { get; set; } + + public IList Choices { get; set; } = new List(); + + + public bool HasOther { get; set; } = false; + public string OtherText { get; set; } + + public string OptionCaption { get; set; } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyItem.cs b/src/SurveyExtensions/Elements/SurveyItem.cs index eaa9f82..b24cddf 100644 --- a/src/SurveyExtensions/Elements/SurveyItem.cs +++ b/src/SurveyExtensions/Elements/SurveyItem.cs @@ -3,7 +3,7 @@ public class SurveyItem { public string Name { get; set; } - public bool IsVisible { get; set; } = true; + public bool Visible { get; set; } = true; public bool IsRequired { get; set; } = false; } diff --git a/test/SurveyExtensionsTests/Factory/BulderFactory.cs b/test/SurveyExtensionsTests/Factory/BulderFactory.cs index 1292772..cdcb373 100644 --- a/test/SurveyExtensionsTests/Factory/BulderFactory.cs +++ b/test/SurveyExtensionsTests/Factory/BulderFactory.cs @@ -60,7 +60,7 @@ public static void Get_1Page_3Radiogroup(SurveyBuilder builder, { builder.AddPage(pageName, page => - page.AddRadiogroupInput(x => x.ContactData, + page.AddRadiogroup(x => x.ContactData, b => b .HasTitle("Radiogroup 1 Title (asc)") .AddChoice("RG1Val1", "Choice 1") @@ -71,7 +71,7 @@ public static void Get_1Page_3Radiogroup(SurveyBuilder builder, .HasColumnCount(1) .HasOtherChoice("Other choice text") .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) - .AddRadiogroupInput(x => x.ContactData, + .AddRadiogroup(x => x.ContactData, b => b .HasTitle("Radiogroup 2 Title (desc)") .AddChoice("RG2Val1", "Choice 1") @@ -80,7 +80,7 @@ public static void Get_1Page_3Radiogroup(SurveyBuilder builder, .AddChoice("RG2Val4", "Choice 4") .AddChoice("RG2Val5", "Choice 5") .HasColumnCount(2)) - .AddRadiogroupInput(x => x.ContactData, + .AddRadiogroup(x => x.ContactData, b => b .HasTitle("Radiogroup 3 Title (random)") .AddChoice("RG3Val1", "Choice 1") @@ -92,5 +92,44 @@ public static void Get_1Page_3Radiogroup(SurveyBuilder builder, .SetChoicesOrder(SurveyChoicesOrderEnum.random)) ); } + + public static void Get_1Page_3Dropdown(SurveyBuilder builder, + string pageName) + { + builder.AddPage(pageName, + page => + page.AddDropdown(x => x.ContactData, + b => b + .HasTitle("Dropdown 1 Title (asc)") + .HasDescription("Dropdown 1 description") + .AddChoice("DD1Val1", "Choice 1") + .AddChoice("DD1Val2", "Choice 2") + .AddChoice("DD1Val3", "Choice 3") + .AddChoice("DD1Val4", "Choice 4") + .AddChoice("DD1Val5", "Choice 5") + .HasOtherChoice("Other choice text") + .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) + .AddDropdown(x => x.ContactData, + b => b + .HasTitle("Dropdown 2 Title (desc)") + .HasDescription("Dropdown 2 description") + .AddChoice("DD2Val1", "Choice 1") + .AddChoice("DD2Val2", "Choice 2") + .AddChoice("DD2Val3", "Choice 3") + .AddChoice("DD2Val4", "Choice 4") + .AddChoice("DD2Val5", "Choice 5") + .SetChoicesOrder(SurveyChoicesOrderEnum.desc)) + .AddDropdown(x => x.ContactData, + b => b + .HasTitle("Dropdown 3 Title (random)") + .HasDescription("Dropdown 3 description") + .AddChoice("DD3Val1", "Choice 1") + .AddChoice("DD3Val2", "Choice 2") + .AddChoice("DD3Val3", "Choice 3") + .AddChoice("DD3Val4", "Choice 4") + .AddChoice("DD3Val5", "Choice 5") + .SetChoicesOrder(SurveyChoicesOrderEnum.random)) + ); + } } } diff --git a/test/SurveyExtensionsTests/GeneralBuilderTests.cs b/test/SurveyExtensionsTests/GeneralBuilderTests.cs index f15c8b0..f89d714 100644 --- a/test/SurveyExtensionsTests/GeneralBuilderTests.cs +++ b/test/SurveyExtensionsTests/GeneralBuilderTests.cs @@ -46,9 +46,9 @@ public void TestBuilders() Factory.BulderFactory.Get_1Page_3Checkbox(companyBuilder, "Checkbox Page"); Factory.BulderFactory.Get_1Page_3Radiogroup(companyBuilder, "Radiogroup Page"); - + Factory.BulderFactory.Get_1Page_3Dropdown(companyBuilder, "DropDown Page"); var myBuildedElements = companyBuilder.Build(); - myBuildedElements.Pages.Count.Should().Be(2); + myBuildedElements.Pages.Count.Should().Be(3); } } } diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 86414fd..9b749cf 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -21,6 +21,7 @@ public void TestSerialization() Factory.BulderFactory.Get_1Page_3Checkbox(companyBuilder, "Checkbox Page"); Factory.BulderFactory.Get_1Page_3Radiogroup(companyBuilder, "Radiogroup Page"); + Factory.BulderFactory.Get_1Page_3Dropdown(companyBuilder, "Dropdown Page"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); From 5cb17fc52db31a8caec10b8fea1901fc6f0cefbf Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Mon, 18 Nov 2019 21:49:46 +0100 Subject: [PATCH 02/25] Moved item type asignement from builders to entities --- src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs | 4 ---- src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs | 5 ----- src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs | 6 ------ .../Builders/SurveyRadiogroupItemBuilder.cs | 5 ----- src/SurveyExtensions/Elements/SurveyCheckboxItem.cs | 6 +++++- src/SurveyExtensions/Elements/SurveyDropdownItem.cs | 7 ++++++- src/SurveyExtensions/Elements/SurveyInputItem.cs | 7 ++++++- src/SurveyExtensions/Elements/SurveyRadiogroupItem.cs | 7 ++++++- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs index ed92a60..2976e9f 100644 --- a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs @@ -7,10 +7,6 @@ public class SurveyCheckboxItemBuilder : SurveyItemBuilderBase, IBuilder where TEntity : new() { - public SurveyCheckboxItemBuilder() - { - _item.Type = "checkbox"; - } public SurveyCheckboxItemBuilder HasName(string value) { diff --git a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs index e476d10..ce6dd70 100644 --- a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs @@ -7,11 +7,6 @@ public class SurveyDropdownItemBuilder : SurveyItemBuilderBase, IBuilder where TEntity : new() { - public SurveyDropdownItemBuilder() - { - _item.Type = "dropdown"; - } - public SurveyDropdownItemBuilder HasName(string value) { _item.Name = value; diff --git a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs index 94c62fc..cdb798d 100644 --- a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs @@ -7,12 +7,6 @@ public class SurveyInputItemBuilder : SurveyItemBuilderBase, IBuilder where TEntity : new() { - public SurveyInputItemBuilder() - { - _item.Type = "text"; - _item.InputType = "text"; - } - public SurveyInputItemBuilder HasName(string value) { _item.Name = value; diff --git a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs index 1256a8b..3fb851d 100644 --- a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs @@ -7,11 +7,6 @@ public class SurveyRadiogroupItemBuilder : SurveyItemBuilderBase, IBuilder where TEntity : new() { - public SurveyRadiogroupItemBuilder() - { - _item.Type = "radiogroup"; - } - public SurveyRadiogroupItemBuilder HasName(string value) { _item.Name = value; diff --git a/src/SurveyExtensions/Elements/SurveyCheckboxItem.cs b/src/SurveyExtensions/Elements/SurveyCheckboxItem.cs index 6306505..5e123a7 100644 --- a/src/SurveyExtensions/Elements/SurveyCheckboxItem.cs +++ b/src/SurveyExtensions/Elements/SurveyCheckboxItem.cs @@ -4,7 +4,11 @@ public class SurveyCheckboxItem : SurveyPageElement { - + public SurveyCheckboxItem() + { + Type = "checkbox"; + } + public string ChoicesOrder { get; set; } public int ColCount { get; set; } diff --git a/src/SurveyExtensions/Elements/SurveyDropdownItem.cs b/src/SurveyExtensions/Elements/SurveyDropdownItem.cs index 17b8c9d..4620737 100644 --- a/src/SurveyExtensions/Elements/SurveyDropdownItem.cs +++ b/src/SurveyExtensions/Elements/SurveyDropdownItem.cs @@ -4,7 +4,12 @@ public class SurveyDropdownItem : SurveyPageElement { - + + public SurveyDropdownItem() + { + Type = "dropdown"; + } + public string ChoicesOrder { get; set; } public IList Choices { get; set; } = new List(); diff --git a/src/SurveyExtensions/Elements/SurveyInputItem.cs b/src/SurveyExtensions/Elements/SurveyInputItem.cs index 71c2576..2800e68 100644 --- a/src/SurveyExtensions/Elements/SurveyInputItem.cs +++ b/src/SurveyExtensions/Elements/SurveyInputItem.cs @@ -2,7 +2,12 @@ { public class SurveyInputItem : SurveyPageElement { - + public SurveyInputItem() + { + Type = "text"; + InputType = "text"; + } + public string PlaceHolder { get; set; } public string InputType { get; set; } } diff --git a/src/SurveyExtensions/Elements/SurveyRadiogroupItem.cs b/src/SurveyExtensions/Elements/SurveyRadiogroupItem.cs index 5ee6fac..e9fcaf2 100644 --- a/src/SurveyExtensions/Elements/SurveyRadiogroupItem.cs +++ b/src/SurveyExtensions/Elements/SurveyRadiogroupItem.cs @@ -4,7 +4,12 @@ public class SurveyRadiogroupItem : SurveyPageElement { - + + public SurveyRadiogroupItem() + { + Type = "radiogroup"; + } + public string ChoicesOrder { get; set; } public int ColCount { get; set; } public bool HasOther { get; set; } From adb8a9712896ab40042db71cdefee3f55ae62946 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Mon, 18 Nov 2019 22:17:35 +0100 Subject: [PATCH 03/25] Added Comment item and builder --- .../Builders/SurveyCheckboxItemBuilder.cs | 6 ++ .../Builders/SurveyCommentItemBuilder.cs | 70 +++++++++++++++++++ .../Builders/SurveyDropdownItemBuilder.cs | 7 ++ .../Builders/SurveyInputItemBuilder.cs | 6 ++ .../Builders/SurveyPageBuilder.cs | 18 +++++ .../Builders/SurveyRadiogroupItemBuilder.cs | 7 ++ .../{ => ChoiceItems}/SurveyCheckboxItem.cs | 2 +- .../{ => ChoiceItems}/SurveyChoice.cs | 2 +- .../SurveyChoicesOrderEnum.cs | 2 +- .../{ => ChoiceItems}/SurveyDropdownItem.cs | 2 +- .../{ => ChoiceItems}/SurveyRadiogroupItem.cs | 2 +- .../Elements/SurveyCommentItem.cs | 13 ++++ src/SurveyExtensions/Elements/SurveyItem.cs | 1 + .../Factory/BulderFactory.cs | 5 +- test/SurveyExtensionsTests/JsonTests.cs | 10 ++- 15 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs rename src/SurveyExtensions/Elements/{ => ChoiceItems}/SurveyCheckboxItem.cs (92%) rename src/SurveyExtensions/Elements/{ => ChoiceItems}/SurveyChoice.cs (72%) rename src/SurveyExtensions/Elements/{ => ChoiceItems}/SurveyChoicesOrderEnum.cs (68%) rename src/SurveyExtensions/Elements/{ => ChoiceItems}/SurveyDropdownItem.cs (90%) rename src/SurveyExtensions/Elements/{ => ChoiceItems}/SurveyRadiogroupItem.cs (90%) create mode 100644 src/SurveyExtensions/Elements/SurveyCommentItem.cs diff --git a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs index 2976e9f..73437dc 100644 --- a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs @@ -2,6 +2,7 @@ { using System; using Elements; + using SurveyExtensions.Elements.ChoiceItems; public class SurveyCheckboxItemBuilder : SurveyItemBuilderBase, @@ -89,5 +90,10 @@ public SurveyCheckboxItemBuilder AddChoice(string choiceValue, string c return this; } + public SurveyCheckboxItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs new file mode 100644 index 0000000..7e204d2 --- /dev/null +++ b/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs @@ -0,0 +1,70 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + + public class SurveyCommentItemBuilder : + SurveyItemBuilderBase, + IBuilder where TEntity : new() + { + public SurveyCommentItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + + public SurveyCommentItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyCommentItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyCommentItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyCommentItemBuilder IsNotRequired() + { + _item.IsRequired = false; + return this; + } + + public SurveyCommentItemBuilder IsVisible() + { + _item.Visible = true; + return this; + } + + public SurveyCommentItemBuilder IsNotVisible() + { + _item.Visible = false; + return this; + } + + public SurveyCommentItemBuilder HasPlaceHolder(string placeholder) + { + _item.PlaceHolder = placeholder; + return this; + } + + public SurveyCommentItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public SurveyCommentItemBuilder HasRows(int rows) + { + _item.Rows = rows; + return this; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs index ce6dd70..3ac8cd5 100644 --- a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs @@ -2,6 +2,7 @@ { using System; using Elements; + using SurveyExtensions.Elements.ChoiceItems; public class SurveyDropdownItemBuilder : SurveyItemBuilderBase, @@ -69,5 +70,11 @@ public SurveyDropdownItemBuilder AddChoice(string choiceValue, string c return this; } + public SurveyDropdownItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + } } \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs index cdb798d..81d9098 100644 --- a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs @@ -61,5 +61,11 @@ public SurveyInputItemBuilder HasPlaceHolder(string placeholder) _item.PlaceHolder = placeholder; return this; } + + public SurveyInputItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs index a5b48b1..8774ce9 100644 --- a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs @@ -36,6 +36,24 @@ public SurveyPageBuilder AddSingleInput(Expression AddCommentInput(Expression> expression, Action> inputBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new SurveyCommentItemBuilder(); + inputBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public SurveyPageBuilder AddCommentInput(Expression> expression, string title, string placeholder, int rows) + { + return AddCommentInput(expression, + x => x.HasTitle(title) + .HasPlaceHolder(placeholder) + .HasRows(7)); + } public SurveyPageBuilder AddCheckboxInput(Expression> expression, Action> checkboxBuilder) { diff --git a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs index 3fb851d..0937e99 100644 --- a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs @@ -2,6 +2,7 @@ { using System; using Elements; + using SurveyExtensions.Elements.ChoiceItems; public class SurveyRadiogroupItemBuilder : SurveyItemBuilderBase, @@ -74,5 +75,11 @@ public SurveyRadiogroupItemBuilder AddChoice(string choiceValue, string _item.Choices.Add(new SurveyChoice() { Value = choiceValue, Text = choiceText }); return this; } + + public SurveyRadiogroupItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyCheckboxItem.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyCheckboxItem.cs similarity index 92% rename from src/SurveyExtensions/Elements/SurveyCheckboxItem.cs rename to src/SurveyExtensions/Elements/ChoiceItems/SurveyCheckboxItem.cs index 5e123a7..cce5efa 100644 --- a/src/SurveyExtensions/Elements/SurveyCheckboxItem.cs +++ b/src/SurveyExtensions/Elements/ChoiceItems/SurveyCheckboxItem.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements +namespace SurveyExtensions.Elements.ChoiceItems { using System.Collections.Generic; diff --git a/src/SurveyExtensions/Elements/SurveyChoice.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoice.cs similarity index 72% rename from src/SurveyExtensions/Elements/SurveyChoice.cs rename to src/SurveyExtensions/Elements/ChoiceItems/SurveyChoice.cs index 3ea9a10..6ad52c1 100644 --- a/src/SurveyExtensions/Elements/SurveyChoice.cs +++ b/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoice.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements +namespace SurveyExtensions.Elements.ChoiceItems { public class SurveyChoice { diff --git a/src/SurveyExtensions/Elements/SurveyChoicesOrderEnum.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoicesOrderEnum.cs similarity index 68% rename from src/SurveyExtensions/Elements/SurveyChoicesOrderEnum.cs rename to src/SurveyExtensions/Elements/ChoiceItems/SurveyChoicesOrderEnum.cs index f6e83a2..4ae59ce 100644 --- a/src/SurveyExtensions/Elements/SurveyChoicesOrderEnum.cs +++ b/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoicesOrderEnum.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements +namespace SurveyExtensions.Elements.ChoiceItems { public enum SurveyChoicesOrderEnum { diff --git a/src/SurveyExtensions/Elements/SurveyDropdownItem.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyDropdownItem.cs similarity index 90% rename from src/SurveyExtensions/Elements/SurveyDropdownItem.cs rename to src/SurveyExtensions/Elements/ChoiceItems/SurveyDropdownItem.cs index 4620737..1dda3c1 100644 --- a/src/SurveyExtensions/Elements/SurveyDropdownItem.cs +++ b/src/SurveyExtensions/Elements/ChoiceItems/SurveyDropdownItem.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements +namespace SurveyExtensions.Elements.ChoiceItems { using System.Collections.Generic; diff --git a/src/SurveyExtensions/Elements/SurveyRadiogroupItem.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyRadiogroupItem.cs similarity index 90% rename from src/SurveyExtensions/Elements/SurveyRadiogroupItem.cs rename to src/SurveyExtensions/Elements/ChoiceItems/SurveyRadiogroupItem.cs index e9fcaf2..6415549 100644 --- a/src/SurveyExtensions/Elements/SurveyRadiogroupItem.cs +++ b/src/SurveyExtensions/Elements/ChoiceItems/SurveyRadiogroupItem.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements +namespace SurveyExtensions.Elements.ChoiceItems { using System.Collections.Generic; diff --git a/src/SurveyExtensions/Elements/SurveyCommentItem.cs b/src/SurveyExtensions/Elements/SurveyCommentItem.cs new file mode 100644 index 0000000..96b170e --- /dev/null +++ b/src/SurveyExtensions/Elements/SurveyCommentItem.cs @@ -0,0 +1,13 @@ +namespace SurveyExtensions.Elements +{ + public class SurveyCommentItem : SurveyPageElement + { + public SurveyCommentItem() + { + Type = "comment"; + } + + public string PlaceHolder { get; set; } + public int Rows { get; set; } = 4; + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyItem.cs b/src/SurveyExtensions/Elements/SurveyItem.cs index b24cddf..8a061f6 100644 --- a/src/SurveyExtensions/Elements/SurveyItem.cs +++ b/src/SurveyExtensions/Elements/SurveyItem.cs @@ -5,6 +5,7 @@ public class SurveyItem public string Name { get; set; } public bool Visible { get; set; } = true; public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; } } \ No newline at end of file diff --git a/test/SurveyExtensionsTests/Factory/BulderFactory.cs b/test/SurveyExtensionsTests/Factory/BulderFactory.cs index cdcb373..94d7804 100644 --- a/test/SurveyExtensionsTests/Factory/BulderFactory.cs +++ b/test/SurveyExtensionsTests/Factory/BulderFactory.cs @@ -1,11 +1,8 @@ namespace SurveyExtensionsTests.Factory { using SurveyExtensions.Builders; - using SurveyExtensions.Elements; + using SurveyExtensions.Elements.ChoiceItems; using SurveyExtensionsTests.Dtos; - using System; - using System.Collections.Generic; - using System.Text; public static class BulderFactory diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 9b749cf..a8b85ae 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -17,7 +17,15 @@ public void TestSerialization() { SurveyBuilder companyBuilder = new SurveyBuilder(); - companyBuilder.AddPage("Page1",p => p.AddSingleInput(c => c.DocumentId, "Put Here your DNI", "Document Id Card", SurveyInputType.Text)); + companyBuilder.AddPage("Page1", + p => p.AddSingleInput(c => c.DocumentId, "Put Here your DNI", "Document Id Card", SurveyInputType.Text) + .AddCommentInput(c => c.ContactData, "Datos de contacto", "entra los datos de contacto", 7) + .AddCommentInput(c => c.ContactData, + i => i.HasTitle("Datos de contacto 2") + .HasPlaceHolder("placeholder 2") + .HasRows(14) + .ContinueInSameLine()) + ); Factory.BulderFactory.Get_1Page_3Checkbox(companyBuilder, "Checkbox Page"); Factory.BulderFactory.Get_1Page_3Radiogroup(companyBuilder, "Radiogroup Page"); From af59b52f47c738f2a40835327c0a0431dde0f2a1 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Mon, 18 Nov 2019 22:45:32 +0100 Subject: [PATCH 04/25] Refactor Item builders: Added SurveyItemBuilderBase, which includes all common properties assignment to Elements --- .../Builders/SurveyCheckboxItemBuilder.cs | 50 +----------------- .../Builders/SurveyCommentItemBuilder.cs | 50 +----------------- .../Builders/SurveyDropdownItemBuilder.cs | 51 +------------------ .../Builders/SurveyInputItemBuilder.cs | 50 +----------------- .../Builders/SurveyItemBuilderBase.cs | 38 +++++++++++++- .../Builders/SurveyRadiogroupItemBuilder.cs | 50 +----------------- 6 files changed, 42 insertions(+), 247 deletions(-) diff --git a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs index 73437dc..d319902 100644 --- a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs @@ -5,52 +5,9 @@ using SurveyExtensions.Elements.ChoiceItems; public class SurveyCheckboxItemBuilder : - SurveyItemBuilderBase, + SurveyItemBuilderBase>, IBuilder where TEntity : new() { - - public SurveyCheckboxItemBuilder HasName(string value) - { - _item.Name = value; - return this; - } - - public SurveyCheckboxItemBuilder HasTitle(string value) - { - _item.Title = value; - return this; - } - - public SurveyCheckboxItemBuilder HasDescription(string value) - { - _item.Description = value; - return this; - } - - public SurveyCheckboxItemBuilder IsRequired() - { - _item.IsRequired = true; - return this; - } - - public SurveyCheckboxItemBuilder IsNotRequired() - { - _item.IsRequired = false; - return this; - } - - public SurveyCheckboxItemBuilder IsVisible() - { - _item.Visible = true; - return this; - } - - public SurveyCheckboxItemBuilder IsNotVisible() - { - _item.Visible = false; - return this; - } - public SurveyCheckboxItemBuilder HasColumnCount(int value) { _item.ColCount = value; @@ -90,10 +47,5 @@ public SurveyCheckboxItemBuilder AddChoice(string choiceValue, string c return this; } - public SurveyCheckboxItemBuilder ContinueInSameLine() - { - _item.StartWithNewLine = false; - return this; - } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs index 7e204d2..94899bb 100644 --- a/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs @@ -4,63 +4,15 @@ using Elements; public class SurveyCommentItemBuilder : - SurveyItemBuilderBase, + SurveyItemBuilderBase>, IBuilder where TEntity : new() { - public SurveyCommentItemBuilder HasName(string value) - { - _item.Name = value; - return this; - } - - public SurveyCommentItemBuilder HasTitle(string value) - { - _item.Title = value; - return this; - } - - public SurveyCommentItemBuilder HasDescription(string value) - { - _item.Description = value; - return this; - } - - public SurveyCommentItemBuilder IsRequired() - { - _item.IsRequired = true; - return this; - } - - public SurveyCommentItemBuilder IsNotRequired() - { - _item.IsRequired = false; - return this; - } - - public SurveyCommentItemBuilder IsVisible() - { - _item.Visible = true; - return this; - } - - public SurveyCommentItemBuilder IsNotVisible() - { - _item.Visible = false; - return this; - } - public SurveyCommentItemBuilder HasPlaceHolder(string placeholder) { _item.PlaceHolder = placeholder; return this; } - public SurveyCommentItemBuilder ContinueInSameLine() - { - _item.StartWithNewLine = false; - return this; - } - public SurveyCommentItemBuilder HasRows(int rows) { _item.Rows = rows; diff --git a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs index 3ac8cd5..7f37c58 100644 --- a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs @@ -5,51 +5,9 @@ using SurveyExtensions.Elements.ChoiceItems; public class SurveyDropdownItemBuilder : - SurveyItemBuilderBase, + SurveyItemBuilderBase>, IBuilder where TEntity : new() { - public SurveyDropdownItemBuilder HasName(string value) - { - _item.Name = value; - return this; - } - - public SurveyDropdownItemBuilder HasTitle(string value) - { - _item.Title = value; - return this; - } - - public SurveyDropdownItemBuilder HasDescription(string value) - { - _item.Description = value; - return this; - } - - public SurveyDropdownItemBuilder IsRequired() - { - _item.IsRequired = true; - return this; - } - - public SurveyDropdownItemBuilder IsNotRequired() - { - _item.IsRequired = false; - return this; - } - - public SurveyDropdownItemBuilder IsVisible() - { - _item.Visible = true; - return this; - } - - public SurveyDropdownItemBuilder IsNotVisible() - { - _item.Visible = false; - return this; - } - public SurveyDropdownItemBuilder SetChoicesOrder(SurveyChoicesOrderEnum order) { string enumName = Enum.GetName(typeof(SurveyChoicesOrderEnum), order); @@ -69,12 +27,5 @@ public SurveyDropdownItemBuilder AddChoice(string choiceValue, string c _item.Choices.Add(new SurveyChoice() { Value = choiceValue, Text = choiceText }); return this; } - - public SurveyDropdownItemBuilder ContinueInSameLine() - { - _item.StartWithNewLine = false; - return this; - } - } } \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs index 81d9098..1d1ea8f 100644 --- a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs @@ -4,51 +4,9 @@ using Elements; public class SurveyInputItemBuilder : - SurveyItemBuilderBase, + SurveyItemBuilderBase>, IBuilder where TEntity : new() { - public SurveyInputItemBuilder HasName(string value) - { - _item.Name = value; - return this; - } - - public SurveyInputItemBuilder HasTitle(string value) - { - _item.Title = value; - return this; - } - - public SurveyInputItemBuilder HasDescription(string value) - { - _item.Description = value; - return this; - } - - public SurveyInputItemBuilder IsRequired() - { - _item.IsRequired = true; - return this; - } - - public SurveyInputItemBuilder IsNotRequired() - { - _item.IsRequired = false; - return this; - } - - public SurveyInputItemBuilder IsVisible() - { - _item.Visible = true; - return this; - } - - public SurveyInputItemBuilder IsNotVisible() - { - _item.Visible = false; - return this; - } - public SurveyInputItemBuilder SetInputType(SurveyInputType inputType) { string enumName = Enum.GetName(typeof(SurveyInputType) ,inputType); @@ -61,11 +19,5 @@ public SurveyInputItemBuilder HasPlaceHolder(string placeholder) _item.PlaceHolder = placeholder; return this; } - - public SurveyInputItemBuilder ContinueInSameLine() - { - _item.StartWithNewLine = false; - return this; - } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs b/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs index fb40798..ba29dfb 100644 --- a/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs +++ b/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs @@ -3,12 +3,48 @@ using System; using Elements; - public class SurveyItemBuilderBase : IBuilder + public class SurveyItemBuilderBase : IBuilder where TEntity : new() where TItem : SurveyPageElement + where TBuilder : SurveyItemBuilderBase { protected TItem _item = (TItem)(Activator.CreateInstance(typeof(TItem))); + public SurveyItemBuilderBase HasName(string value) + { + _item.Name = value; + return (TBuilder)this; + } + + public SurveyItemBuilderBase HasTitle(string value) + { + _item.Title = value; + return (TBuilder)this; + } + + public SurveyItemBuilderBase HasDescription(string value) + { + _item.Description = value; + return (TBuilder)this; + } + + public SurveyItemBuilderBase IsRequired() + { + _item.IsRequired = true; + return (TBuilder)this; + } + + public SurveyItemBuilderBase IsNotVisible() + { + _item.Visible = false; + return (TBuilder)this; + } + + public SurveyItemBuilderBase ContinueInSameLine() + { + _item.StartWithNewLine = false; + return (TBuilder)this; + } public SurveyItem Build() { return _item; diff --git a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs index 0937e99..5301910 100644 --- a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs @@ -5,51 +5,9 @@ using SurveyExtensions.Elements.ChoiceItems; public class SurveyRadiogroupItemBuilder : - SurveyItemBuilderBase, + SurveyItemBuilderBase>, IBuilder where TEntity : new() { - public SurveyRadiogroupItemBuilder HasName(string value) - { - _item.Name = value; - return this; - } - - public SurveyRadiogroupItemBuilder HasTitle(string value) - { - _item.Title = value; - return this; - } - - public SurveyRadiogroupItemBuilder HasDescription(string value) - { - _item.Description = value; - return this; - } - - public SurveyRadiogroupItemBuilder IsRequired() - { - _item.IsRequired = true; - return this; - } - - public SurveyRadiogroupItemBuilder IsNotRequired() - { - _item.IsRequired = false; - return this; - } - - public SurveyRadiogroupItemBuilder IsVisible() - { - _item.Visible = true; - return this; - } - - public SurveyRadiogroupItemBuilder IsNotVisible() - { - _item.Visible = false; - return this; - } - public SurveyRadiogroupItemBuilder HasColumnCount(int value) { _item.ColCount = value; @@ -75,11 +33,5 @@ public SurveyRadiogroupItemBuilder AddChoice(string choiceValue, string _item.Choices.Add(new SurveyChoice() { Value = choiceValue, Text = choiceText }); return this; } - - public SurveyRadiogroupItemBuilder ContinueInSameLine() - { - _item.StartWithNewLine = false; - return this; - } } } \ No newline at end of file From a6516b2e35ed34b4b7a9d6b21152aeb2f2f1f161 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Mon, 18 Nov 2019 23:05:11 +0100 Subject: [PATCH 05/25] Moved all common logic back to builders. BuilderItemBase did not work --- .../Builders/SurveyCheckboxItemBuilder.cs | 38 ++++++++++++++++++- .../Builders/SurveyCommentItemBuilder.cs | 38 ++++++++++++++++++- .../Builders/SurveyDropdownItemBuilder.cs | 38 ++++++++++++++++++- .../Builders/SurveyInputItemBuilder.cs | 37 +++++++++++++++++- .../Builders/SurveyItemBuilderBase.cs | 38 +------------------ .../Builders/SurveyRadiogroupItemBuilder.cs | 38 ++++++++++++++++++- 6 files changed, 185 insertions(+), 42 deletions(-) diff --git a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs index d319902..5e3c8f9 100644 --- a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs @@ -5,9 +5,45 @@ using SurveyExtensions.Elements.ChoiceItems; public class SurveyCheckboxItemBuilder : - SurveyItemBuilderBase>, + SurveyItemBuilderBase, IBuilder where TEntity : new() { + + public SurveyCheckboxItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SurveyCheckboxItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyCheckboxItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyCheckboxItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyCheckboxItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyCheckboxItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + public SurveyCheckboxItemBuilder HasColumnCount(int value) { _item.ColCount = value; diff --git a/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs index 94899bb..c0a9b55 100644 --- a/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs @@ -4,9 +4,45 @@ using Elements; public class SurveyCommentItemBuilder : - SurveyItemBuilderBase>, + SurveyItemBuilderBase, IBuilder where TEntity : new() { + + public SurveyCommentItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SurveyCommentItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyCommentItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyCommentItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyCommentItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyCommentItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + public SurveyCommentItemBuilder HasPlaceHolder(string placeholder) { _item.PlaceHolder = placeholder; diff --git a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs index 7f37c58..a83e47c 100644 --- a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs @@ -5,9 +5,45 @@ using SurveyExtensions.Elements.ChoiceItems; public class SurveyDropdownItemBuilder : - SurveyItemBuilderBase>, + SurveyItemBuilderBase, IBuilder where TEntity : new() { + + public SurveyDropdownItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SurveyDropdownItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyDropdownItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyDropdownItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyDropdownItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyDropdownItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + public SurveyDropdownItemBuilder SetChoicesOrder(SurveyChoicesOrderEnum order) { string enumName = Enum.GetName(typeof(SurveyChoicesOrderEnum), order); diff --git a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs index 1d1ea8f..85297c4 100644 --- a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs @@ -4,9 +4,44 @@ using Elements; public class SurveyInputItemBuilder : - SurveyItemBuilderBase>, + SurveyItemBuilderBase, IBuilder where TEntity : new() { + public SurveyInputItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SurveyInputItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyInputItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyInputItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyInputItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyInputItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + public SurveyInputItemBuilder SetInputType(SurveyInputType inputType) { string enumName = Enum.GetName(typeof(SurveyInputType) ,inputType); diff --git a/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs b/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs index ba29dfb..840da24 100644 --- a/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs +++ b/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs @@ -3,48 +3,12 @@ using System; using Elements; - public class SurveyItemBuilderBase : IBuilder + public abstract class SurveyItemBuilderBase : IBuilder where TEntity : new() where TItem : SurveyPageElement - where TBuilder : SurveyItemBuilderBase { protected TItem _item = (TItem)(Activator.CreateInstance(typeof(TItem))); - public SurveyItemBuilderBase HasName(string value) - { - _item.Name = value; - return (TBuilder)this; - } - - public SurveyItemBuilderBase HasTitle(string value) - { - _item.Title = value; - return (TBuilder)this; - } - - public SurveyItemBuilderBase HasDescription(string value) - { - _item.Description = value; - return (TBuilder)this; - } - - public SurveyItemBuilderBase IsRequired() - { - _item.IsRequired = true; - return (TBuilder)this; - } - - public SurveyItemBuilderBase IsNotVisible() - { - _item.Visible = false; - return (TBuilder)this; - } - - public SurveyItemBuilderBase ContinueInSameLine() - { - _item.StartWithNewLine = false; - return (TBuilder)this; - } public SurveyItem Build() { return _item; diff --git a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs index 5301910..5de23e5 100644 --- a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs @@ -5,9 +5,45 @@ using SurveyExtensions.Elements.ChoiceItems; public class SurveyRadiogroupItemBuilder : - SurveyItemBuilderBase>, + SurveyItemBuilderBase, IBuilder where TEntity : new() { + + public SurveyRadiogroupItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SurveyRadiogroupItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyRadiogroupItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyRadiogroupItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyRadiogroupItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyRadiogroupItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + public SurveyRadiogroupItemBuilder HasColumnCount(int value) { _item.ColCount = value; From dbeba591a49eca04b7a9883f2700f953baa31f91 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Mon, 18 Nov 2019 23:34:31 +0100 Subject: [PATCH 06/25] added rating ite, element and builder --- .../Builders/SurveyPageBuilder.cs | 30 ++++++- .../Builders/SurveyRatinItemBuilder.cs | 83 +++++++++++++++++++ .../Elements/ChoiceItems/SurveyRatingItem.cs | 23 +++++ test/SurveyExtensionsTests/JsonTests.cs | 11 +++ 4 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 src/SurveyExtensions/Builders/SurveyRatinItemBuilder.cs create mode 100644 src/SurveyExtensions/Elements/ChoiceItems/SurveyRatingItem.cs diff --git a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs index 8774ce9..161ac89 100644 --- a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs @@ -36,12 +36,12 @@ public SurveyPageBuilder AddSingleInput(Expression AddCommentInput(Expression> expression, Action> inputBuilder) + public SurveyPageBuilder AddCommentInput(Expression> expression, Action> commentBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); var builder = new SurveyCommentItemBuilder(); - inputBuilder.Invoke(builder); + commentBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; @@ -87,12 +87,12 @@ public SurveyPageBuilder AddRadiogroup(Expression x.HasTitle(title)); } - public SurveyPageBuilder AddDropdown(Expression> expression, Action> radiogroupBuilder) + public SurveyPageBuilder AddDropdown(Expression> expression, Action> dropDownBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); var builder = new SurveyDropdownItemBuilder(); - radiogroupBuilder.Invoke(builder); + dropDownBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; @@ -103,6 +103,28 @@ public SurveyPageBuilder AddDropdown(Expression x.HasTitle(title)); } + public SurveyPageBuilder AddRating(Expression> expression, Action> ratingBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new SurveyRatinItemBuilder(); + ratingBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public SurveyPageBuilder AddRating(Expression> expression, + string title, string description, int rateMin, int rateMax, int rateStep) + { + return AddRating(expression, + x => x.HasTitle(title) + .HasDescription(description) + .HasRateMin(rateMin) + .HasRateMax(rateMax) + .HasRateStep(rateStep)); + } + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Builders/SurveyRatinItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyRatinItemBuilder.cs new file mode 100644 index 0000000..20907cd --- /dev/null +++ b/src/SurveyExtensions/Builders/SurveyRatinItemBuilder.cs @@ -0,0 +1,83 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.ChoiceItems; + + public class SurveyRatinItemBuilder : + SurveyItemBuilderBase, + IBuilder where TEntity : new() + { + + public SurveyRatinItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SurveyRatinItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyRatinItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyRatinItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyRatinItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyRatinItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public SurveyRatinItemBuilder HasRateMin(int value) + { + _item.RateMin = value; + return this; + } + + public SurveyRatinItemBuilder HasRateMax(int value) + { + _item.RateMax = value; + return this; + } + + public SurveyRatinItemBuilder HasRateStep(int value) + { + _item.RateStep = value; + return this; + } + + public SurveyRatinItemBuilder AddRateValue(string value, string text) + { + _item.RateValues.Add(new SurveyChoice() { Value = value, Text = text}); + return this; + } + + public SurveyRatinItemBuilder HasMinRateDescription(string value) + { + _item.MinRateDescription = value; + return this; + } + + public SurveyRatinItemBuilder HasMaxRateDescription(string value) + { + _item.MaxRateDescription = value; + return this; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyRatingItem.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyRatingItem.cs new file mode 100644 index 0000000..4d36206 --- /dev/null +++ b/src/SurveyExtensions/Elements/ChoiceItems/SurveyRatingItem.cs @@ -0,0 +1,23 @@ +namespace SurveyExtensions.Elements.ChoiceItems +{ + using System.Collections.Generic; + + public class SurveyRatingItem : SurveyPageElement + { + + public SurveyRatingItem() + { + Type = "rating"; + } + + public int RateMin { get; set; } = 1; + public int RateMax { get; set; } = 5; + public int RateStep { get; set; } = 1; + + public IList RateValues { get; set; } = new List(); + + public string MinRateDescription { get; set; } + + public string MaxRateDescription { get; set; } + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index a8b85ae..d44f573 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -25,6 +25,17 @@ public void TestSerialization() .HasPlaceHolder("placeholder 2") .HasRows(14) .ContinueInSameLine()) + .AddRating(c=>c.IsLegalPerson, "Rating with values", "", 1, 10, 1) + .AddRating(c => c.IsLegalPerson, + i=> i.HasTitle("Rating with options") + .AddRateValue("RTVal1", "Val 1") + .AddRateValue("RTVal2", "Val 2") + .AddRateValue("RTVal3", "Val 3") + .AddRateValue("RTVal4", "Val 4") + .AddRateValue("RTVal5", "Val 5") + .AddRateValue("RTVal6", "Val 6") + .AddRateValue("RTVal7", "Val 7") + .AddRateValue("RTVal8", "Val 8")) ); Factory.BulderFactory.Get_1Page_3Checkbox(companyBuilder, "Checkbox Page"); From 9938d35842de5e5dd360c55e6f3e648f40caf66b Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Fri, 22 Nov 2019 09:57:29 +0100 Subject: [PATCH 07/25] Refactored tests. Now every test is separated --- .../Factory/BulderFactory.cs | 50 ++++++++----- .../GeneralBuilderTests.cs | 11 --- test/SurveyExtensionsTests/JsonTests.cs | 71 ++++++++++++++++--- 3 files changed, 96 insertions(+), 36 deletions(-) diff --git a/test/SurveyExtensionsTests/Factory/BulderFactory.cs b/test/SurveyExtensionsTests/Factory/BulderFactory.cs index 94d7804..a50f101 100644 --- a/test/SurveyExtensionsTests/Factory/BulderFactory.cs +++ b/test/SurveyExtensionsTests/Factory/BulderFactory.cs @@ -7,25 +7,32 @@ public static class BulderFactory { - public static void Get_1Page_3Checkbox(SurveyBuilder builder, - string pageName) + public static void Get_1Page_CheckboxWithAllWithNoneSortedAscending + (SurveyBuilder builder,string pageName) { builder.AddPage(pageName, - page => - page.AddCheckboxInput(x => x.ContactData, - b => b - .HasTitle("Choice 1 Title (asc) - All - None") - .AddChoice("CB1Val1", "Choice 1") - .AddChoice("CB1Val2", "Choice 2") - .AddChoice("CB1Val3", "Choice 3") - .AddChoice("CB1Val4", "Choice 4") - .AddChoice("CB1Val5", "Choice 5") - .HasColumnCount(1) - .HasOtherChoice("Other choice text") - .HasSelectAllChoice("Select All") - .HasSelectNoneChoice("Select none") - .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) - .AddCheckboxInput(x => x.ContactData, + page => + page.AddCheckboxInput(x => x.ContactData, + b => b + .HasTitle("Choice 1 Title (asc) - All - None") + .AddChoice("CB1Val1", "Choice 1") + .AddChoice("CB1Val2", "Choice 2") + .AddChoice("CB1Val3", "Choice 3") + .AddChoice("CB1Val4", "Choice 4") + .AddChoice("CB1Val5", "Choice 5") + .HasColumnCount(1) + .HasOtherChoice("Other choice text") + .HasSelectAllChoice("Select All") + .HasSelectNoneChoice("Select none") + .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) + ); + } + + public static void Get_1Page_CheckboxWithAllSortedDescending + (SurveyBuilder builder, string pageName) + { + builder.AddPage(pageName, + page =>page.AddCheckboxInput(x => x.ContactData, b => b .HasTitle("Choice 2 Title (desc) - All") .AddChoice("CB2Val1", "Choice 1") @@ -37,6 +44,15 @@ public static void Get_1Page_3Checkbox(SurveyBuilder builder, .HasOtherChoice("Other choice text") .HasSelectAllChoice("Select All") .SetChoicesOrder(SurveyChoicesOrderEnum.desc)) + ); + } + + public static void Get_1Page_CheckboxWithNoneSortedRandom + (SurveyBuilder builder, string pageName) + { + builder.AddPage(pageName, + page => + page .AddCheckboxInput(x => x.ContactData, b => b .HasTitle("Choice 3 Title (random) - None") diff --git a/test/SurveyExtensionsTests/GeneralBuilderTests.cs b/test/SurveyExtensionsTests/GeneralBuilderTests.cs index f89d714..e465bc3 100644 --- a/test/SurveyExtensionsTests/GeneralBuilderTests.cs +++ b/test/SurveyExtensionsTests/GeneralBuilderTests.cs @@ -39,16 +39,5 @@ public void TestSingleInput() myBuildedElements.Pages.Count.Should().Be(3); } - [Fact] - public void TestBuilders() - { - SurveyBuilder companyBuilder = new SurveyBuilder(); - - Factory.BulderFactory.Get_1Page_3Checkbox(companyBuilder, "Checkbox Page"); - Factory.BulderFactory.Get_1Page_3Radiogroup(companyBuilder, "Radiogroup Page"); - Factory.BulderFactory.Get_1Page_3Dropdown(companyBuilder, "DropDown Page"); - var myBuildedElements = companyBuilder.Build(); - myBuildedElements.Pages.Count.Should().Be(3); - } } } diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index d44f573..fd7f12e 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -13,21 +13,48 @@ namespace SurveyExtensionsTests public class JsonTests { [Fact] - public void TestSerialization() + public void SingleTextInputTest() { SurveyBuilder companyBuilder = new SurveyBuilder(); companyBuilder.AddPage("Page1", p => p.AddSingleInput(c => c.DocumentId, "Put Here your DNI", "Document Id Card", SurveyInputType.Text) - .AddCommentInput(c => c.ContactData, "Datos de contacto", "entra los datos de contacto", 7) - .AddCommentInput(c => c.ContactData, + ); + + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.test1); + } + + [Fact] + public void CommentTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + + companyBuilder.AddPage("Page1", + p => p.AddCommentInput(c => c.ContactData, "Datos de contacto", "entra los datos de contacto", 7) + .AddCommentInput(c => c.ContactData, i => i.HasTitle("Datos de contacto 2") .HasPlaceHolder("placeholder 2") .HasRows(14) .ContinueInSameLine()) - .AddRating(c=>c.IsLegalPerson, "Rating with values", "", 1, 10, 1) + ); + + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.test1); + } + + [Fact] + public void RatingTests() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + + companyBuilder.AddPage("Page1", + p => p + .AddRating(c => c.IsLegalPerson, "Rating with values", "", 1, 10, 1) .AddRating(c => c.IsLegalPerson, - i=> i.HasTitle("Rating with options") + i => i.HasTitle("Rating with options") .AddRateValue("RTVal1", "Val 1") .AddRateValue("RTVal2", "Val 2") .AddRateValue("RTVal3", "Val 3") @@ -38,13 +65,41 @@ public void TestSerialization() .AddRateValue("RTVal8", "Val 8")) ); - Factory.BulderFactory.Get_1Page_3Checkbox(companyBuilder, "Checkbox Page"); - Factory.BulderFactory.Get_1Page_3Radiogroup(companyBuilder, "Radiogroup Page"); - Factory.BulderFactory.Get_1Page_3Dropdown(companyBuilder, "Dropdown Page"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.test1); + } + + [Fact] + public void CheckboxWithAllWithNoneSortedAscendingTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Checkbox 1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.test1); + } + + [Fact] + public void CheckboxWithAllSortedDescendingTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_CheckboxWithAllSortedDescending(companyBuilder, "Checkbox 2"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.test1); + } + [Fact] + public void CheckboxWithAllWithNoneSortedAscending() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Checkbox 3"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); jsonextracted.Should().Be(jsoncollections.test1); } + + } } From 38e6f25d78cd76d1d605fd11a28799fec3cd28cc Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Fri, 22 Nov 2019 10:30:59 +0100 Subject: [PATCH 08/25] Added resources to validate all different components --- .../Factory/BulderFactory.cs | 48 ++++++-- test/SurveyExtensionsTests/JsonTests.cs | 80 +++++++++++-- .../jsonResults/jsoncollections.Designer.cs | 108 ++++++++++++++++++ .../jsonResults/jsoncollections.resx | 36 ++++++ 4 files changed, 253 insertions(+), 19 deletions(-) diff --git a/test/SurveyExtensionsTests/Factory/BulderFactory.cs b/test/SurveyExtensionsTests/Factory/BulderFactory.cs index a50f101..13d0267 100644 --- a/test/SurveyExtensionsTests/Factory/BulderFactory.cs +++ b/test/SurveyExtensionsTests/Factory/BulderFactory.cs @@ -68,10 +68,10 @@ public static void Get_1Page_CheckboxWithNoneSortedRandom ); } - public static void Get_1Page_3Radiogroup(SurveyBuilder builder, - string pageName) + public static void Get_1Page_RadiogroupAscending(SurveyBuilder builder, + string pageName) { - builder.AddPage(pageName, + builder.AddPage(pageName, page => page.AddRadiogroup(x => x.ContactData, b => b @@ -84,7 +84,15 @@ public static void Get_1Page_3Radiogroup(SurveyBuilder builder, .HasColumnCount(1) .HasOtherChoice("Other choice text") .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) - .AddRadiogroup(x => x.ContactData, + ); + } + + public static void Get_1Page_RadiogroupDescending(SurveyBuilder builder, + string pageName) + { + builder.AddPage(pageName, + page => + page.AddRadiogroup(x => x.ContactData, b => b .HasTitle("Radiogroup 2 Title (desc)") .AddChoice("RG2Val1", "Choice 1") @@ -93,7 +101,15 @@ public static void Get_1Page_3Radiogroup(SurveyBuilder builder, .AddChoice("RG2Val4", "Choice 4") .AddChoice("RG2Val5", "Choice 5") .HasColumnCount(2)) - .AddRadiogroup(x => x.ContactData, + ); + } + + public static void Get_1Page_RadiogroupRandom(SurveyBuilder builder, + string pageName) + { + builder.AddPage(pageName, + page => + page.AddRadiogroup(x => x.ContactData, b => b .HasTitle("Radiogroup 3 Title (random)") .AddChoice("RG3Val1", "Choice 1") @@ -106,7 +122,7 @@ public static void Get_1Page_3Radiogroup(SurveyBuilder builder, ); } - public static void Get_1Page_3Dropdown(SurveyBuilder builder, + public static void Get_1Page_DropdownAscending(SurveyBuilder builder, string pageName) { builder.AddPage(pageName, @@ -122,7 +138,15 @@ public static void Get_1Page_3Dropdown(SurveyBuilder builder, .AddChoice("DD1Val5", "Choice 5") .HasOtherChoice("Other choice text") .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) - .AddDropdown(x => x.ContactData, + ); + } + + public static void Get_1Page_DropdownDescending(SurveyBuilder builder, + string pageName) + { + builder.AddPage(pageName, + page => + page.AddDropdown(x => x.ContactData, b => b .HasTitle("Dropdown 2 Title (desc)") .HasDescription("Dropdown 2 description") @@ -132,7 +156,15 @@ public static void Get_1Page_3Dropdown(SurveyBuilder builder, .AddChoice("DD2Val4", "Choice 4") .AddChoice("DD2Val5", "Choice 5") .SetChoicesOrder(SurveyChoicesOrderEnum.desc)) - .AddDropdown(x => x.ContactData, + ); + } + + public static void Get_1Page_DropdownRandom(SurveyBuilder builder, + string pageName) + { + builder.AddPage(pageName, + page => + page.AddDropdown(x => x.ContactData, b => b .HasTitle("Dropdown 3 Title (random)") .HasDescription("Dropdown 3 description") diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index fd7f12e..b828afa 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -23,7 +23,7 @@ public void SingleTextInputTest() var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.test1); + jsonextracted.Should().Be(jsoncollections.SingleInputTestExtractedJson); } [Fact] @@ -42,7 +42,7 @@ public void CommentTest() var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.test1); + jsonextracted.Should().Be(jsoncollections.CommentTestExtractedJson); } [Fact] @@ -67,39 +67,97 @@ public void RatingTests() var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.test1); + jsonextracted.Should().Be(jsoncollections.RatingTestExtractedJson); } [Fact] - public void CheckboxWithAllWithNoneSortedAscendingTest() + public void Checkbox1TestWithAllWithNoneSortedAscending() { SurveyBuilder companyBuilder = new SurveyBuilder(); - Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Checkbox 1"); + Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.test1); + jsonextracted.Should().Be(jsoncollections.Checkbox1TestExtractedJson); } [Fact] - public void CheckboxWithAllSortedDescendingTest() + public void Checkbox2TestWithAllSortedDescending() { SurveyBuilder companyBuilder = new SurveyBuilder(); - Factory.BulderFactory.Get_1Page_CheckboxWithAllSortedDescending(companyBuilder, "Checkbox 2"); + Factory.BulderFactory.Get_1Page_CheckboxWithAllSortedDescending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.test1); + jsonextracted.Should().Be(jsoncollections.Checkbox2TestExtractedJson); } [Fact] - public void CheckboxWithAllWithNoneSortedAscending() + public void Checkbox3TestWithAllWithNoneSortedAscending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Checkbox 3"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.test1); + jsonextracted.Should().Be(jsoncollections.Checkbox3TestExtractedJson); } + [Fact] + public void Radiogroup1TestAscending() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_RadiogroupAscending(companyBuilder, "Page1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.Radiogroup1TestExtractedJson); + } + + [Fact] + public void Radiogroup2TestDescending() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_RadiogroupDescending(companyBuilder, "Page1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.Radiogroup2TestExtractedJson); + } + + [Fact] + public void Radiogroup3TestRandom() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_RadiogroupRandom(companyBuilder, "Page1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.Radiogroup3TestExtractedJson); + } + [Fact] + public void Dromdowm1TestAscending() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_RadiogroupRandom(companyBuilder, "Dropdown 1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.Dropdown1TestExtractedJson); + } + + [Fact] + public void Dromdowm2TestDescending() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_DropdownDescending(companyBuilder, "Dropdown 1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.Dropdown2TestExtractedJson); + } + + [Fact] + public void Dromdowm3TestRandom() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_DropdownRandom(companyBuilder, "Dropdown 1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.Dropdown3TestExtractedJson); + } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index ac16845..002bf4d 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -60,6 +60,114 @@ internal jsoncollections() { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":f [rest of string was truncated]";. + /// + internal static string Checkbox1TestExtractedJson { + get { + return ResourceManager.GetString("Checkbox1TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":false,"noneText":null,"type":"checkbox","title":"Choice 2 Title (desc) - All","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWi [rest of string was truncated]";. + /// + internal static string Checkbox2TestExtractedJson { + get { + return ResourceManager.GetString("Checkbox2TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":f [rest of string was truncated]";. + /// + internal static string Checkbox3TestExtractedJson { + get { + return ResourceManager.GetString("Checkbox3TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":false}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// + internal static string CommentTestExtractedJson { + get { + return ResourceManager.GetString("CommentTestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true,"isRequired":false,"s [rest of string was truncated]";. + /// + internal static string Dropdown1TestExtractedJson { + get { + return ResourceManager.GetString("Dropdown1TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true," [rest of string was truncated]";. + /// + internal static string Dropdown2TestExtractedJson { + get { + return ResourceManager.GetString("Dropdown2TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":tr [rest of string was truncated]";. + /// + internal static string Dropdown3TestExtractedJson { + get { + return ResourceManager.GetString("Dropdown3TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false, [rest of string was truncated]";. + /// + internal static string Radiogroup1TestExtractedJson { + get { + return ResourceManager.GetString("Radiogroup1TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 2 Title (desc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNew [rest of string was truncated]";. + /// + internal static string Radiogroup2TestExtractedJson { + get { + return ResourceManager.GetString("Radiogroup2TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startW [rest of string was truncated]";. + /// + internal static string Radiogroup3TestExtractedJson { + get { + return ResourceManager.GetString("Radiogroup3TestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":"","name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6 [rest of string was truncated]";. + /// + internal static string RatingTestExtractedJson { + get { + return ResourceManager.GetString("RatingTestExtractedJson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"Document Id Card","inputType":"text","type":"text","title":"Put Here your DNI","description":null,"name":"DocumentId","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// + internal static string SingleInputTestExtractedJson { + get { + return ResourceManager.GetString("SingleInputTestExtractedJson", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"name":"Page1","elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","isRequired":false,"name":"DocumentId"}]}]}. /// diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index 78c9fdd..f6a3a7b 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -117,6 +117,42 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":false,"noneText":null,"type":"checkbox","title":"Choice 2 Title (desc) - All","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Checkbox 3","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":false}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 2 Title (desc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":"","name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6","text":"Val 6"},{"value":"RTVal7","text":"Val 7"},{"value":"RTVal8","text":"Val 8"}],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with options","description":null,"name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"placeHolder":"Document Id Card","inputType":"text","type":"text","title":"Put Here your DNI","description":null,"name":"DocumentId","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"name":"Page1","elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","isRequired":false,"name":"DocumentId"}]}]} From ea0b270854ca3852523e76237bf4ffb7cd76fa3d Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Fri, 22 Nov 2019 11:00:04 +0100 Subject: [PATCH 09/25] Added image picker with individual unit tests --- .../Builders/SurveyImagePickerItemBuilder.cs | 74 +++++++++++++++++++ .../Builders/SurveyPageBuilder.cs | 17 +++++ .../ChoiceItems/SurveyImagePickerChoice.cs | 8 ++ .../ChoiceItems/SurveyImagePickerItem.cs | 19 +++++ .../Factory/BulderFactory.cs | 51 +++++++++++++ test/SurveyExtensionsTests/JsonTests.cs | 36 ++++++++- .../jsonResults/jsoncollections.Designer.cs | 33 ++++++++- .../jsonResults/jsoncollections.resx | 15 +++- 8 files changed, 244 insertions(+), 9 deletions(-) create mode 100644 src/SurveyExtensions/Builders/SurveyImagePickerItemBuilder.cs create mode 100644 src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerChoice.cs create mode 100644 src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerItem.cs diff --git a/src/SurveyExtensions/Builders/SurveyImagePickerItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyImagePickerItemBuilder.cs new file mode 100644 index 0000000..6c18c4a --- /dev/null +++ b/src/SurveyExtensions/Builders/SurveyImagePickerItemBuilder.cs @@ -0,0 +1,74 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.ChoiceItems; + + public class SurveyImagePickerItemBuilder : + SurveyItemBuilderBase, + IBuilder where TEntity : new() + { + + public SurveyImagePickerItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SurveyImagePickerItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyImagePickerItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyImagePickerItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyImagePickerItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyImagePickerItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public SurveyImagePickerItemBuilder HasColumnCount(int value) + { + _item.ColCount = value; + return this; + } + + public SurveyImagePickerItemBuilder SetChoicesOrder(SurveyChoicesOrderEnum order) + { + string enumName = Enum.GetName(typeof(SurveyChoicesOrderEnum), order); + if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); + return this; + } + + + public SurveyImagePickerItemBuilder AddChoice(string choiceValue, string choiceText, string imageLink) + { + _item.Choices.Add( + new SurveyImagePickerChoice() + { + Value = choiceValue, + Text = choiceText, + ImageLink = imageLink, + }); + return this; + } + + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs index 161ac89..d6a2af0 100644 --- a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs @@ -125,6 +125,23 @@ public SurveyPageBuilder AddRating(Expression AddImagePickerInput(Expression> expression, Action> imagePickerBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new SurveyImagePickerItemBuilder(); + imagePickerBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public SurveyPageBuilder AddImagePickerInput(Expression> expression, string title) + { + return AddImagePickerInput(expression, x => x.HasTitle(title)); + } + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerChoice.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerChoice.cs new file mode 100644 index 0000000..fd2f1ca --- /dev/null +++ b/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerChoice.cs @@ -0,0 +1,8 @@ +namespace SurveyExtensions.Elements.ChoiceItems +{ + public class SurveyImagePickerChoice : SurveyChoice + { + + public string ImageLink { get; set; } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerItem.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerItem.cs new file mode 100644 index 0000000..2593dfd --- /dev/null +++ b/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerItem.cs @@ -0,0 +1,19 @@ +namespace SurveyExtensions.Elements.ChoiceItems +{ + using System.Collections.Generic; + + public class SurveyImagePickerItem : SurveyPageElement + { + public SurveyImagePickerItem() + { + Type = "imagepicker"; + } + + public string ChoicesOrder { get; set; } + + public int ColCount { get; set; } = 0; + + public IList Choices { get; set; } = new List(); + + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/Factory/BulderFactory.cs b/test/SurveyExtensionsTests/Factory/BulderFactory.cs index 13d0267..921d221 100644 --- a/test/SurveyExtensionsTests/Factory/BulderFactory.cs +++ b/test/SurveyExtensionsTests/Factory/BulderFactory.cs @@ -176,5 +176,56 @@ public static void Get_1Page_DropdownRandom(SurveyBuilder builder, .SetChoicesOrder(SurveyChoicesOrderEnum.random)) ); } + + public static void Get_1Page_ImagePickerAscending(SurveyBuilder builder, + string pageName) + { + builder.AddPage(pageName, + page => + page.AddImagePickerInput(x => x.ContactData, + b => b + .HasTitle("Image Picker 1 Title (asc)") + .AddChoice("IP1Val1", "Lion", "https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg") + .AddChoice("IP1Val2", "Giraffe", "https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg") + .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") + .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") + .HasColumnCount(0) + .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) + ); + } + + public static void Get_1Page_ImagePickerDescending(SurveyBuilder builder, + string pageName) + { + builder.AddPage(pageName, + page => + page.AddImagePickerInput(x => x.ContactData, + b => b + .HasTitle("Image Picker 1 Title (asc)") + .AddChoice("IP1Val1", "Lion", "https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg") + .AddChoice("IP1Val2", "Giraffe", "https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg") + .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") + .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") + .HasColumnCount(2) + .SetChoicesOrder(SurveyChoicesOrderEnum.desc)) + ); + } + + public static void Get_1Page_ImagePickerRandom(SurveyBuilder builder, + string pageName) + { + builder.AddPage(pageName, + page => + page.AddImagePickerInput(x => x.ContactData, + b => b + .HasTitle("Image Picker 1 Title (asc)") + .AddChoice("IP1Val1", "Lion", "https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg") + .AddChoice("IP1Val2", "Giraffe", "https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg") + .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") + .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") + .HasColumnCount(0) + .SetChoicesOrder(SurveyChoicesOrderEnum.random)) + ); + } } } diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index b828afa..3c2d4e8 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -134,7 +134,7 @@ public void Radiogroup3TestRandom() public void Dromdowm1TestAscending() { SurveyBuilder companyBuilder = new SurveyBuilder(); - Factory.BulderFactory.Get_1Page_RadiogroupRandom(companyBuilder, "Dropdown 1"); + Factory.BulderFactory.Get_1Page_RadiogroupRandom(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); jsonextracted.Should().Be(jsoncollections.Dropdown1TestExtractedJson); @@ -144,7 +144,7 @@ public void Dromdowm1TestAscending() public void Dromdowm2TestDescending() { SurveyBuilder companyBuilder = new SurveyBuilder(); - Factory.BulderFactory.Get_1Page_DropdownDescending(companyBuilder, "Dropdown 1"); + Factory.BulderFactory.Get_1Page_DropdownDescending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); jsonextracted.Should().Be(jsoncollections.Dropdown2TestExtractedJson); @@ -154,10 +154,40 @@ public void Dromdowm2TestDescending() public void Dromdowm3TestRandom() { SurveyBuilder companyBuilder = new SurveyBuilder(); - Factory.BulderFactory.Get_1Page_DropdownRandom(companyBuilder, "Dropdown 1"); + Factory.BulderFactory.Get_1Page_DropdownRandom(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); jsonextracted.Should().Be(jsoncollections.Dropdown3TestExtractedJson); } + + [Fact] + public void ImagePicker1TestAscending() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_ImagePickerAscending(companyBuilder, "Page1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.ImagePicker1TestExtractedResult); + } + + [Fact] + public void ImagePicker2TestDescending() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_ImagePickerDescending(companyBuilder, "Page1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.ImagePicker2TestExtractedResult); + } + + [Fact] + public void ImagePicker3TestRandom() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + Factory.BulderFactory.Get_1Page_ImagePickerRandom(companyBuilder, "Page1"); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.ImagePicker3TestExtractedResult); + } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index 002bf4d..efb3df1 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -97,7 +97,7 @@ internal static string CommentTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true,"isRequired":false,"s [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startW [rest of string was truncated]";. /// internal static string Dropdown1TestExtractedJson { get { @@ -106,7 +106,7 @@ internal static string Dropdown1TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true," [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isReq [rest of string was truncated]";. /// internal static string Dropdown2TestExtractedJson { get { @@ -115,7 +115,7 @@ internal static string Dropdown2TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":tr [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"i [rest of string was truncated]";. /// internal static string Dropdown3TestExtractedJson { get { @@ -123,6 +123,33 @@ internal static string Dropdown3TestExtractedJson { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP [rest of string was truncated]";. + /// + internal static string ImagePicker1TestExtractedResult { + get { + return ResourceManager.GetString("ImagePicker1TestExtractedResult", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"I [rest of string was truncated]";. + /// + internal static string ImagePicker2TestExtractedResult { + get { + return ResourceManager.GetString("ImagePicker2TestExtractedResult", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value": [rest of string was truncated]";. + /// + internal static string ImagePicker3TestExtractedResult { + get { + return ResourceManager.GetString("ImagePicker3TestExtractedResult", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false, [rest of string was truncated]";. /// diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index f6a3a7b..389ad27 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -130,13 +130,22 @@ {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":false}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} - {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} - {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} - {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Dropdown 1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + + {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} From 527a39e94d3bf0d13f551b3a73ca3f5c6f4c407a Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Fri, 22 Nov 2019 23:25:29 +0100 Subject: [PATCH 10/25] Added boolean item and builder --- .../Builders/SurveyBooleanItemBuilder.cs | 64 +++++++++++++++++++ .../Builders/SurveyPageBuilder.cs | 17 ++++- .../Elements/SurveyBooleanItem.cs | 14 ++++ test/SurveyExtensionsTests/JsonTests.cs | 15 +++++ .../jsonResults/jsoncollections.Designer.cs | 9 +++ .../jsonResults/jsoncollections.resx | 3 + 6 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 src/SurveyExtensions/Builders/SurveyBooleanItemBuilder.cs create mode 100644 src/SurveyExtensions/Elements/SurveyBooleanItem.cs diff --git a/src/SurveyExtensions/Builders/SurveyBooleanItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyBooleanItemBuilder.cs new file mode 100644 index 0000000..9ff01eb --- /dev/null +++ b/src/SurveyExtensions/Builders/SurveyBooleanItemBuilder.cs @@ -0,0 +1,64 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + + public class SurveyBooleanItemBuilder : + SurveyItemBuilderBase, + IBuilder where TEntity : new() + { + + public SurveyBooleanItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SurveyBooleanItemBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SurveyBooleanItemBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SurveyBooleanItemBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SurveyBooleanItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyBooleanItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public SurveyBooleanItemBuilder HasLabel(string label) + { + _item.Label = label; + return this; + } + + public SurveyBooleanItemBuilder HasLabelTrue(string labelTrue) + { + _item.LabelTrue = labelTrue; + return this; + } + + public SurveyBooleanItemBuilder HasLabelFalse(string labelFalse) + { + _item.LabelFalse = labelFalse; + return this; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs index d6a2af0..e99cafe 100644 --- a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs @@ -125,7 +125,6 @@ public SurveyPageBuilder AddRating(Expression AddImagePickerInput(Expression> expression, Action> imagePickerBuilder) { TEntity mEntity = new TEntity(); @@ -142,6 +141,22 @@ public SurveyPageBuilder AddImagePickerInput(Expression x.HasTitle(title)); } + public SurveyPageBuilder AddBooleanInput(Expression> expression, Action> booleanBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new SurveyBooleanItemBuilder(); + booleanBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public SurveyPageBuilder AddBooleanInput(Expression> expression, string title, string abel, string labelTrue, string labelNo) + { + return AddImagePickerInput(expression, x => x.HasTitle(title)); + } + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Elements/SurveyBooleanItem.cs b/src/SurveyExtensions/Elements/SurveyBooleanItem.cs new file mode 100644 index 0000000..0a32d23 --- /dev/null +++ b/src/SurveyExtensions/Elements/SurveyBooleanItem.cs @@ -0,0 +1,14 @@ +namespace SurveyExtensions.Elements +{ + public class SurveyBooleanItem : SurveyPageElement + { + public SurveyBooleanItem() + { + Type = "boolean"; + } + + public string Label { get; set; } + public string LabelTrue { get; set; } = "Yes"; + public string LabelFalse { get; set; } = "No"; + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 3c2d4e8..0225a4d 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -189,5 +189,20 @@ public void ImagePicker3TestRandom() var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); jsonextracted.Should().Be(jsoncollections.ImagePicker3TestExtractedResult); } + + [Fact] + public void BooleanTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + companyBuilder.AddPage("Page1", + p => p.AddBooleanInput(c=>c.IsLegalPerson, + l => l.HasLabel("Boolean label") + .HasLabelTrue("True") + .HasLabelFalse("False") + )); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.BooleanTestExtractedResult); + } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index efb3df1..e659d77 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -60,6 +60,15 @@ internal jsoncollections() { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// + internal static string BooleanTestExtractedResult { + get { + return ResourceManager.GetString("BooleanTestExtractedResult", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":f [rest of string was truncated]";. /// diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index 389ad27..dc8cb46 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} From c1f54e57094524d80e975bfabbfa93eb1f230a58 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Fri, 22 Nov 2019 23:48:23 +0100 Subject: [PATCH 11/25] Added html editor item and builder --- .../Builders/SurveyHtmlEditorItemBuilder.cs | 36 +++++++++++++++++++ .../Builders/SurveyPageBuilder.cs | 13 +++++++ .../Elements/SurveyHtmlEditorItem.cs | 12 +++++++ test/SurveyExtensionsTests/JsonTests.cs | 17 +++++++-- .../jsonResults/jsoncollections.Designer.cs | 9 +++++ .../jsonResults/jsoncollections.resx | 3 ++ 6 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/SurveyExtensions/Builders/SurveyHtmlEditorItemBuilder.cs create mode 100644 src/SurveyExtensions/Elements/SurveyHtmlEditorItem.cs diff --git a/src/SurveyExtensions/Builders/SurveyHtmlEditorItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyHtmlEditorItemBuilder.cs new file mode 100644 index 0000000..9ba4b1b --- /dev/null +++ b/src/SurveyExtensions/Builders/SurveyHtmlEditorItemBuilder.cs @@ -0,0 +1,36 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + + public class SurveyHtmlEditorItemBuilder : + SurveyItemBuilderBase, + IBuilder where TEntity : new() + { + + public SurveyHtmlEditorItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + + public SurveyHtmlEditorItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyHtmlEditorItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public SurveyHtmlEditorItemBuilder HasHtml(string html) + { + _item.Html = html; + return this; + } + + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs index e99cafe..f2682c4 100644 --- a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs @@ -157,6 +157,19 @@ public SurveyPageBuilder AddBooleanInput(Expression x.HasTitle(title)); } + + public SurveyPageBuilder AddHtmlEditor(Expression> expression, Action> htmlEditorBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new SurveyHtmlEditorItemBuilder(); + htmlEditorBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Elements/SurveyHtmlEditorItem.cs b/src/SurveyExtensions/Elements/SurveyHtmlEditorItem.cs new file mode 100644 index 0000000..7f971b3 --- /dev/null +++ b/src/SurveyExtensions/Elements/SurveyHtmlEditorItem.cs @@ -0,0 +1,12 @@ +namespace SurveyExtensions.Elements +{ + public class SurveyHtmlEditorItem : SurveyPageElement + { + public SurveyHtmlEditorItem() + { + Type = "html"; + } + + public string Html { get; set; } + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 0225a4d..74b100c 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -194,8 +194,8 @@ public void ImagePicker3TestRandom() public void BooleanTest() { SurveyBuilder companyBuilder = new SurveyBuilder(); - companyBuilder.AddPage("Page1", - p => p.AddBooleanInput(c=>c.IsLegalPerson, + companyBuilder.AddPage("Page1", + p => p.AddBooleanInput(c => c.IsLegalPerson, l => l.HasLabel("Boolean label") .HasLabelTrue("True") .HasLabelFalse("False") @@ -204,5 +204,18 @@ public void BooleanTest() var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); jsonextracted.Should().Be(jsoncollections.BooleanTestExtractedResult); } + + [Fact] + public void HtmlEditornTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + companyBuilder.AddPage("Page1", + p => p.AddHtmlEditor(c => c.ContactData, + l => l.HasHtml("

H1 content

Paragraph

") + )); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.HtmlEditorTestExtractedResult); + } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index e659d77..4405f5c 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -132,6 +132,15 @@ internal static string Dropdown3TestExtractedJson { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// + internal static string HtmlEditorTestExtractedResult { + get { + return ResourceManager.GetString("HtmlEditorTestExtractedResult", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP [rest of string was truncated]";. /// diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index dc8cb46..793e92b 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -141,6 +141,9 @@ {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} From b4a0774d108b1a93a18a6143ceb916a1650d1097 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sat, 23 Nov 2019 00:03:58 +0100 Subject: [PATCH 12/25] Added file item and builder --- .../Builders/SurveyFileItemBuilder.cs | 36 +++++++++++++++++++ .../Builders/SurveyPageBuilder.cs | 10 ++++++ .../Elements/SurveyFileItem.cs | 12 +++++++ test/SurveyExtensionsTests/JsonTests.cs | 23 +++++++++--- .../jsonResults/jsoncollections.Designer.cs | 29 +++++++++------ .../jsonResults/jsoncollections.resx | 13 ++++--- 6 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 src/SurveyExtensions/Builders/SurveyFileItemBuilder.cs create mode 100644 src/SurveyExtensions/Elements/SurveyFileItem.cs diff --git a/src/SurveyExtensions/Builders/SurveyFileItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyFileItemBuilder.cs new file mode 100644 index 0000000..ee13e0f --- /dev/null +++ b/src/SurveyExtensions/Builders/SurveyFileItemBuilder.cs @@ -0,0 +1,36 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + + public class SurveyFileItemBuilder : + SurveyItemBuilderBase, + IBuilder where TEntity : new() + { + + public SurveyFileItemBuilder HasName(string value) + { + _item.Name = value; + return this; + } + + public SurveyFileItemBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SurveyFileItemBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public SurveyFileItemBuilder HasMaxSize(int maxSize) + { + _item.MaxSize = maxSize; + return this; + } + + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs index f2682c4..f498b56 100644 --- a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyPageBuilder.cs @@ -169,6 +169,16 @@ public SurveyPageBuilder AddHtmlEditor(Expression AddFile(Expression> expression, Action> fileBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new SurveyFileItemBuilder(); + fileBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } public SurveyPage Build() { diff --git a/src/SurveyExtensions/Elements/SurveyFileItem.cs b/src/SurveyExtensions/Elements/SurveyFileItem.cs new file mode 100644 index 0000000..82ec60e --- /dev/null +++ b/src/SurveyExtensions/Elements/SurveyFileItem.cs @@ -0,0 +1,12 @@ +namespace SurveyExtensions.Elements +{ + public class SurveyFileItem : SurveyPageElement + { + public SurveyFileItem() + { + Type = "file"; + } + + public int MaxSize { get; set; } = 0; + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 74b100c..372f353 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -167,7 +167,7 @@ public void ImagePicker1TestAscending() Factory.BulderFactory.Get_1Page_ImagePickerAscending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.ImagePicker1TestExtractedResult); + jsonextracted.Should().Be(jsoncollections.ImagePicker1TestExtractedJson); } [Fact] @@ -177,7 +177,7 @@ public void ImagePicker2TestDescending() Factory.BulderFactory.Get_1Page_ImagePickerDescending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.ImagePicker2TestExtractedResult); + jsonextracted.Should().Be(jsoncollections.ImagePicker2TestExtractedJson); } [Fact] @@ -187,7 +187,7 @@ public void ImagePicker3TestRandom() Factory.BulderFactory.Get_1Page_ImagePickerRandom(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.ImagePicker3TestExtractedResult); + jsonextracted.Should().Be(jsoncollections.ImagePicker3TestExtractedJson); } [Fact] @@ -202,7 +202,7 @@ public void BooleanTest() )); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.BooleanTestExtractedResult); + jsonextracted.Should().Be(jsoncollections.BooleanTestExtractedJson); } [Fact] @@ -215,7 +215,20 @@ public void HtmlEditornTest() )); var myBuildedElements = companyBuilder.Build(); var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.HtmlEditorTestExtractedResult); + jsonextracted.Should().Be(jsoncollections.HtmlEditorTestExtractedJson); + } + + [Fact] + public void FileTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + companyBuilder.AddPage("Page1", + p => p.AddFile(c => c.ContactData, + l => l.HasMaxSize(250) + )); + var myBuildedElements = companyBuilder.Build(); + var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + jsonextracted.Should().Be(jsoncollections.FileExtractedJson); } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index 4405f5c..ea46ddb 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -63,9 +63,9 @@ internal jsoncollections() { /// /// Looks up a localized string similar to {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. /// - internal static string BooleanTestExtractedResult { + internal static string BooleanTestExtractedJson { get { - return ResourceManager.GetString("BooleanTestExtractedResult", resourceCulture); + return ResourceManager.GetString("BooleanTestExtractedJson", resourceCulture); } } @@ -132,39 +132,48 @@ internal static string Dropdown3TestExtractedJson { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"maxSize":250,"type":"file","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// + internal static string FileExtractedJson { + get { + return ResourceManager.GetString("FileExtractedJson", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. /// - internal static string HtmlEditorTestExtractedResult { + internal static string HtmlEditorTestExtractedJson { get { - return ResourceManager.GetString("HtmlEditorTestExtractedResult", resourceCulture); + return ResourceManager.GetString("HtmlEditorTestExtractedJson", resourceCulture); } } /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP [rest of string was truncated]";. /// - internal static string ImagePicker1TestExtractedResult { + internal static string ImagePicker1TestExtractedJson { get { - return ResourceManager.GetString("ImagePicker1TestExtractedResult", resourceCulture); + return ResourceManager.GetString("ImagePicker1TestExtractedJson", resourceCulture); } } /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"I [rest of string was truncated]";. /// - internal static string ImagePicker2TestExtractedResult { + internal static string ImagePicker2TestExtractedJson { get { - return ResourceManager.GetString("ImagePicker2TestExtractedResult", resourceCulture); + return ResourceManager.GetString("ImagePicker2TestExtractedJson", resourceCulture); } } /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value": [rest of string was truncated]";. /// - internal static string ImagePicker3TestExtractedResult { + internal static string ImagePicker3TestExtractedJson { get { - return ResourceManager.GetString("ImagePicker3TestExtractedResult", resourceCulture); + return ResourceManager.GetString("ImagePicker3TestExtractedJson", resourceCulture); } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index 793e92b..c0eae56 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -117,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} @@ -141,16 +141,19 @@ {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} - + + {"pages":[{"elements":[{"maxSize":250,"type":"file","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + + {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} - + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} - + {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} - + {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} From 877a769a1077fb8b812f58f6ce95889d53495b47 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sat, 23 Nov 2019 19:19:16 +0100 Subject: [PATCH 13/25] Refactor: Rename items to Questions to match surveyjs naming --- ...emBuilder.cs => BooleanQuestionBuilder.cs} | 24 +++--- ...mBuilder.cs => CheckboxQuestionBuilder.cs} | 34 +++++---- ...emBuilder.cs => CommentQuestionBuilder.cs} | 21 +++--- .../Builders/DropdownQuestionBuilder.cs | 69 +++++++++++++++++ ...eItemBuilder.cs => FileQuestionBuilder.cs} | 13 ++-- ...uilder.cs => HtmlEditorQuestionBuilder.cs} | 13 ++-- ...ilder.cs => ImagePickerQuestionBuilder.cs} | 28 +++---- .../{SurveyPageBuilder.cs => PageBuilder.cs} | 63 ++++++++-------- .../Builders/QuestionBuilderBase.cs | 18 +++++ .../Builders/RadiogroupQuestionBuilder.cs | 75 +++++++++++++++++++ ...temBuilder.cs => RatingQuestionBuilder.cs} | 32 ++++---- .../Builders/SimgleItemQuestionBuilder.cs | 60 +++++++++++++++ .../Builders/SurveyBuilder.cs | 6 +- .../Builders/SurveyDropdownItemBuilder.cs | 67 ----------------- .../Builders/SurveyInputItemBuilder.cs | 58 -------------- .../Builders/SurveyItemBuilderBase.cs | 17 ----- .../Builders/SurveyRadiogroupItemBuilder.cs | 73 ------------------ .../{SurveyChoice.cs => Choice.cs} | 2 +- ...gePickerChoice.cs => ImagePickerChoice.cs} | 2 +- .../ChoiceItems/SurveyChoicesOrderEnum.cs | 10 --- .../ChoiceItems/SurveyImagePickerItem.cs | 19 ----- .../BooleanQuestion.cs} | 6 +- .../CheckboxQuestion.cs} | 9 ++- .../CommentsQuestion.cs} | 6 +- .../DropdownIQuestion.cs} | 9 ++- .../Elements/Questions/FileQuestion.cs | 12 +++ .../Elements/Questions/HtmlEditorQuestion.cs | 12 +++ .../Elements/Questions/ImagePickerQuestion.cs | 20 +++++ .../RadiogroupQuestion.cs} | 9 ++- .../RatingQuestion.cs} | 9 ++- .../SingleInputQuestion.cs} | 6 +- .../Elements/Questions/SurveyQuestion.cs | 15 ++++ .../Elements/SurveyFileItem.cs | 12 --- .../Elements/SurveyHtmlEditorItem.cs | 12 --- .../Elements/SurveyInputType.cs | 10 --- src/SurveyExtensions/Elements/SurveyItem.cs | 3 - src/SurveyExtensions/Elements/SurveyPage.cs | 2 +- .../Elements/SurveyPageElement.cs | 12 --- .../Enums/ChoicesOrderEnum.cs | 10 +++ .../Enums/SingleInputTypesEnum.cs | 10 +++ .../Factory/BulderFactory.cs | 24 +++--- .../GeneralBuilderTests.cs | 11 +-- test/SurveyExtensionsTests/JsonTests.cs | 5 +- 43 files changed, 474 insertions(+), 454 deletions(-) rename src/SurveyExtensions/Builders/{SurveyBooleanItemBuilder.cs => BooleanQuestionBuilder.cs} (52%) rename src/SurveyExtensions/Builders/{SurveyCheckboxItemBuilder.cs => CheckboxQuestionBuilder.cs} (50%) rename src/SurveyExtensions/Builders/{SurveyCommentItemBuilder.cs => CommentQuestionBuilder.cs} (53%) create mode 100644 src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs rename src/SurveyExtensions/Builders/{SurveyFileItemBuilder.cs => FileQuestionBuilder.cs} (54%) rename src/SurveyExtensions/Builders/{SurveyHtmlEditorItemBuilder.cs => HtmlEditorQuestionBuilder.cs} (52%) rename src/SurveyExtensions/Builders/{SurveyImagePickerItemBuilder.cs => ImagePickerQuestionBuilder.cs} (52%) rename src/SurveyExtensions/Builders/{SurveyPageBuilder.cs => PageBuilder.cs} (58%) create mode 100644 src/SurveyExtensions/Builders/QuestionBuilderBase.cs create mode 100644 src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs rename src/SurveyExtensions/Builders/{SurveyRatinItemBuilder.cs => RatingQuestionBuilder.cs} (51%) create mode 100644 src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs delete mode 100644 src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs delete mode 100644 src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs delete mode 100644 src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs delete mode 100644 src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs rename src/SurveyExtensions/Elements/ChoiceItems/{SurveyChoice.cs => Choice.cs} (83%) rename src/SurveyExtensions/Elements/ChoiceItems/{SurveyImagePickerChoice.cs => ImagePickerChoice.cs} (68%) delete mode 100644 src/SurveyExtensions/Elements/ChoiceItems/SurveyChoicesOrderEnum.cs delete mode 100644 src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerItem.cs rename src/SurveyExtensions/Elements/{SurveyBooleanItem.cs => Questions/BooleanQuestion.cs} (62%) rename src/SurveyExtensions/Elements/{ChoiceItems/SurveyCheckboxItem.cs => Questions/CheckboxQuestion.cs} (63%) rename src/SurveyExtensions/Elements/{SurveyCommentItem.cs => Questions/CommentsQuestion.cs} (53%) rename src/SurveyExtensions/Elements/{ChoiceItems/SurveyDropdownItem.cs => Questions/DropdownIQuestion.cs} (54%) create mode 100644 src/SurveyExtensions/Elements/Questions/FileQuestion.cs create mode 100644 src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs create mode 100644 src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs rename src/SurveyExtensions/Elements/{ChoiceItems/SurveyRadiogroupItem.cs => Questions/RadiogroupQuestion.cs} (52%) rename src/SurveyExtensions/Elements/{ChoiceItems/SurveyRatingItem.cs => Questions/RatingQuestion.cs} (58%) rename src/SurveyExtensions/Elements/{SurveyInputItem.cs => Questions/SingleInputQuestion.cs} (57%) create mode 100644 src/SurveyExtensions/Elements/Questions/SurveyQuestion.cs delete mode 100644 src/SurveyExtensions/Elements/SurveyFileItem.cs delete mode 100644 src/SurveyExtensions/Elements/SurveyHtmlEditorItem.cs delete mode 100644 src/SurveyExtensions/Elements/SurveyInputType.cs delete mode 100644 src/SurveyExtensions/Elements/SurveyPageElement.cs create mode 100644 src/SurveyExtensions/Enums/ChoicesOrderEnum.cs create mode 100644 src/SurveyExtensions/Enums/SingleInputTypesEnum.cs diff --git a/src/SurveyExtensions/Builders/SurveyBooleanItemBuilder.cs b/src/SurveyExtensions/Builders/BooleanQuestionBuilder.cs similarity index 52% rename from src/SurveyExtensions/Builders/SurveyBooleanItemBuilder.cs rename to src/SurveyExtensions/Builders/BooleanQuestionBuilder.cs index 9ff01eb..e7fc8b5 100644 --- a/src/SurveyExtensions/Builders/SurveyBooleanItemBuilder.cs +++ b/src/SurveyExtensions/Builders/BooleanQuestionBuilder.cs @@ -1,61 +1,61 @@ namespace SurveyExtensions.Builders { - using System; using Elements; + using SurveyExtensions.Elements.Questions; - public class SurveyBooleanItemBuilder : - SurveyItemBuilderBase, + public class BooleanQuestionBuilder : + QuestionBuilderBase, IBuilder where TEntity : new() { - public SurveyBooleanItemBuilder HasName(string value) + public BooleanQuestionBuilder HasName(string value) { _item.Name = value; return this; } - public SurveyBooleanItemBuilder HasTitle(string value) + public BooleanQuestionBuilder HasTitle(string value) { _item.Title = value; return this; } - public SurveyBooleanItemBuilder HasDescription(string value) + public BooleanQuestionBuilder HasDescription(string value) { _item.Description = value; return this; } - public SurveyBooleanItemBuilder IsRequired() + public BooleanQuestionBuilder IsRequired() { _item.IsRequired = true; return this; } - public SurveyBooleanItemBuilder IsHidden() + public BooleanQuestionBuilder IsHidden() { _item.Visible = false; return this; } - public SurveyBooleanItemBuilder ContinueInSameLine() + public BooleanQuestionBuilder ContinueInSameLine() { _item.StartWithNewLine = false; return this; } - public SurveyBooleanItemBuilder HasLabel(string label) + public BooleanQuestionBuilder HasLabel(string label) { _item.Label = label; return this; } - public SurveyBooleanItemBuilder HasLabelTrue(string labelTrue) + public BooleanQuestionBuilder HasLabelTrue(string labelTrue) { _item.LabelTrue = labelTrue; return this; } - public SurveyBooleanItemBuilder HasLabelFalse(string labelFalse) + public BooleanQuestionBuilder HasLabelFalse(string labelFalse) { _item.LabelFalse = labelFalse; return this; diff --git a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs b/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs similarity index 50% rename from src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs rename to src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs index 5e3c8f9..d8aafbc 100644 --- a/src/SurveyExtensions/Builders/SurveyCheckboxItemBuilder.cs +++ b/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs @@ -3,83 +3,85 @@ using System; using Elements; using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.Questions; + using SurveyExtensions.Enums; - public class SurveyCheckboxItemBuilder : - SurveyItemBuilderBase, + public class CheckboxQuestionBuilder : + QuestionBuilderBase, IBuilder where TEntity : new() { - public SurveyCheckboxItemBuilder HasName(string value) + public CheckboxQuestionBuilder HasName(string value) { _item.Name = value; return this; } - public SurveyCheckboxItemBuilder HasTitle(string value) + public CheckboxQuestionBuilder HasTitle(string value) { _item.Title = value; return this; } - public SurveyCheckboxItemBuilder HasDescription(string value) + public CheckboxQuestionBuilder HasDescription(string value) { _item.Description = value; return this; } - public SurveyCheckboxItemBuilder IsRequired() + public CheckboxQuestionBuilder IsRequired() { _item.IsRequired = true; return this; } - public SurveyCheckboxItemBuilder IsHidden() + public CheckboxQuestionBuilder IsHidden() { _item.Visible = false; return this; } - public SurveyCheckboxItemBuilder ContinueInSameLine() + public CheckboxQuestionBuilder ContinueInSameLine() { _item.StartWithNewLine = false; return this; } - public SurveyCheckboxItemBuilder HasColumnCount(int value) + public CheckboxQuestionBuilder HasColumnCount(int value) { _item.ColCount = value; return this; } - public SurveyCheckboxItemBuilder SetChoicesOrder(SurveyChoicesOrderEnum order) + public CheckboxQuestionBuilder SetChoicesOrder(ChoicesOrderEnum order) { - string enumName = Enum.GetName(typeof(SurveyChoicesOrderEnum), order); + string enumName = Enum.GetName(typeof(ChoicesOrderEnum), order); if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); return this; } - public SurveyCheckboxItemBuilder HasOtherChoice(string choiceText) + public CheckboxQuestionBuilder HasOtherChoice(string choiceText) { _item.OtherText = choiceText; return this; } - public SurveyCheckboxItemBuilder HasSelectAllChoice(string choiceText) + public CheckboxQuestionBuilder HasSelectAllChoice(string choiceText) { _item.HasSelectAll = true; _item.SelectAllText = choiceText; return this; } - public SurveyCheckboxItemBuilder HasSelectNoneChoice(string choiceText) + public CheckboxQuestionBuilder HasSelectNoneChoice(string choiceText) { _item.HasNone = true; _item.NoneText = choiceText; return this; } - public SurveyCheckboxItemBuilder AddChoice(string choiceValue, string choiceText) + public CheckboxQuestionBuilder AddChoice(string choiceValue, string choiceText) { - _item.Choices.Add(new SurveyChoice() { Value = choiceValue, Text = choiceText }); + _item.Choices.Add(new Choice() { Value = choiceValue, Text = choiceText }); return this; } diff --git a/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs b/src/SurveyExtensions/Builders/CommentQuestionBuilder.cs similarity index 53% rename from src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs rename to src/SurveyExtensions/Builders/CommentQuestionBuilder.cs index c0a9b55..032c02e 100644 --- a/src/SurveyExtensions/Builders/SurveyCommentItemBuilder.cs +++ b/src/SurveyExtensions/Builders/CommentQuestionBuilder.cs @@ -2,54 +2,55 @@ { using System; using Elements; + using SurveyExtensions.Elements.Questions; - public class SurveyCommentItemBuilder : - SurveyItemBuilderBase, + public class CommentQuestionBuilder : + QuestionBuilderBase, IBuilder where TEntity : new() { - public SurveyCommentItemBuilder HasName(string value) + public CommentQuestionBuilder HasName(string value) { _item.Name = value; return this; } - public SurveyCommentItemBuilder HasTitle(string value) + public CommentQuestionBuilder HasTitle(string value) { _item.Title = value; return this; } - public SurveyCommentItemBuilder HasDescription(string value) + public CommentQuestionBuilder HasDescription(string value) { _item.Description = value; return this; } - public SurveyCommentItemBuilder IsRequired() + public CommentQuestionBuilder IsRequired() { _item.IsRequired = true; return this; } - public SurveyCommentItemBuilder IsHidden() + public CommentQuestionBuilder IsHidden() { _item.Visible = false; return this; } - public SurveyCommentItemBuilder ContinueInSameLine() + public CommentQuestionBuilder ContinueInSameLine() { _item.StartWithNewLine = false; return this; } - public SurveyCommentItemBuilder HasPlaceHolder(string placeholder) + public CommentQuestionBuilder HasPlaceHolder(string placeholder) { _item.PlaceHolder = placeholder; return this; } - public SurveyCommentItemBuilder HasRows(int rows) + public CommentQuestionBuilder HasRows(int rows) { _item.Rows = rows; return this; diff --git a/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs b/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs new file mode 100644 index 0000000..ca20882 --- /dev/null +++ b/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs @@ -0,0 +1,69 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.Questions; + using SurveyExtensions.Enums; + + public class DropdownQuestionBuilder : + QuestionBuilderBase, + IBuilder where TEntity : new() + { + + public DropdownQuestionBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public DropdownQuestionBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public DropdownQuestionBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public DropdownQuestionBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public DropdownQuestionBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public DropdownQuestionBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public DropdownQuestionBuilder SetChoicesOrder(ChoicesOrderEnum order) + { + string enumName = Enum.GetName(typeof(ChoicesOrderEnum), order); + if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); + return this; + } + + public DropdownQuestionBuilder HasOtherChoice(string choiceText) + { + _item.HasOther = true; + _item.OtherText = choiceText; + return this; + } + + public DropdownQuestionBuilder AddChoice(string choiceValue, string choiceText) + { + _item.Choices.Add(new Choice() { Value = choiceValue, Text = choiceText }); + return this; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyFileItemBuilder.cs b/src/SurveyExtensions/Builders/FileQuestionBuilder.cs similarity index 54% rename from src/SurveyExtensions/Builders/SurveyFileItemBuilder.cs rename to src/SurveyExtensions/Builders/FileQuestionBuilder.cs index ee13e0f..48c02f4 100644 --- a/src/SurveyExtensions/Builders/SurveyFileItemBuilder.cs +++ b/src/SurveyExtensions/Builders/FileQuestionBuilder.cs @@ -2,31 +2,32 @@ { using System; using Elements; + using SurveyExtensions.Elements.Questions; - public class SurveyFileItemBuilder : - SurveyItemBuilderBase, + public class FileQuestionBuilder : + QuestionBuilderBase, IBuilder where TEntity : new() { - public SurveyFileItemBuilder HasName(string value) + public FileQuestionBuilder HasName(string value) { _item.Name = value; return this; } - public SurveyFileItemBuilder IsHidden() + public FileQuestionBuilder IsHidden() { _item.Visible = false; return this; } - public SurveyFileItemBuilder ContinueInSameLine() + public FileQuestionBuilder ContinueInSameLine() { _item.StartWithNewLine = false; return this; } - public SurveyFileItemBuilder HasMaxSize(int maxSize) + public FileQuestionBuilder HasMaxSize(int maxSize) { _item.MaxSize = maxSize; return this; diff --git a/src/SurveyExtensions/Builders/SurveyHtmlEditorItemBuilder.cs b/src/SurveyExtensions/Builders/HtmlEditorQuestionBuilder.cs similarity index 52% rename from src/SurveyExtensions/Builders/SurveyHtmlEditorItemBuilder.cs rename to src/SurveyExtensions/Builders/HtmlEditorQuestionBuilder.cs index 9ba4b1b..760e5e3 100644 --- a/src/SurveyExtensions/Builders/SurveyHtmlEditorItemBuilder.cs +++ b/src/SurveyExtensions/Builders/HtmlEditorQuestionBuilder.cs @@ -2,31 +2,32 @@ { using System; using Elements; + using SurveyExtensions.Elements.Questions; - public class SurveyHtmlEditorItemBuilder : - SurveyItemBuilderBase, + public class HtmlEditorQuestionBuilder : + QuestionBuilderBase, IBuilder where TEntity : new() { - public SurveyHtmlEditorItemBuilder HasName(string value) + public HtmlEditorQuestionBuilder HasName(string value) { _item.Name = value; return this; } - public SurveyHtmlEditorItemBuilder IsHidden() + public HtmlEditorQuestionBuilder IsHidden() { _item.Visible = false; return this; } - public SurveyHtmlEditorItemBuilder ContinueInSameLine() + public HtmlEditorQuestionBuilder ContinueInSameLine() { _item.StartWithNewLine = false; return this; } - public SurveyHtmlEditorItemBuilder HasHtml(string html) + public HtmlEditorQuestionBuilder HasHtml(string html) { _item.Html = html; return this; diff --git a/src/SurveyExtensions/Builders/SurveyImagePickerItemBuilder.cs b/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs similarity index 52% rename from src/SurveyExtensions/Builders/SurveyImagePickerItemBuilder.cs rename to src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs index 6c18c4a..e6cc61b 100644 --- a/src/SurveyExtensions/Builders/SurveyImagePickerItemBuilder.cs +++ b/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs @@ -3,65 +3,67 @@ using System; using Elements; using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.Questions; + using SurveyExtensions.Enums; - public class SurveyImagePickerItemBuilder : - SurveyItemBuilderBase, + public class ImagePickerQuestionBuilder : + QuestionBuilderBase, IBuilder where TEntity : new() { - public SurveyImagePickerItemBuilder HasName(string value) + public ImagePickerQuestionBuilder HasName(string value) { _item.Name = value; return this; } - public SurveyImagePickerItemBuilder HasTitle(string value) + public ImagePickerQuestionBuilder HasTitle(string value) { _item.Title = value; return this; } - public SurveyImagePickerItemBuilder HasDescription(string value) + public ImagePickerQuestionBuilder HasDescription(string value) { _item.Description = value; return this; } - public SurveyImagePickerItemBuilder IsRequired() + public ImagePickerQuestionBuilder IsRequired() { _item.IsRequired = true; return this; } - public SurveyImagePickerItemBuilder IsHidden() + public ImagePickerQuestionBuilder IsHidden() { _item.Visible = false; return this; } - public SurveyImagePickerItemBuilder ContinueInSameLine() + public ImagePickerQuestionBuilder ContinueInSameLine() { _item.StartWithNewLine = false; return this; } - public SurveyImagePickerItemBuilder HasColumnCount(int value) + public ImagePickerQuestionBuilder HasColumnCount(int value) { _item.ColCount = value; return this; } - public SurveyImagePickerItemBuilder SetChoicesOrder(SurveyChoicesOrderEnum order) + public ImagePickerQuestionBuilder SetChoicesOrder(ChoicesOrderEnum order) { - string enumName = Enum.GetName(typeof(SurveyChoicesOrderEnum), order); + string enumName = Enum.GetName(typeof(ChoicesOrderEnum), order); if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); return this; } - public SurveyImagePickerItemBuilder AddChoice(string choiceValue, string choiceText, string imageLink) + public ImagePickerQuestionBuilder AddChoice(string choiceValue, string choiceText, string imageLink) { _item.Choices.Add( - new SurveyImagePickerChoice() + new ImagePickerChoice() { Value = choiceValue, Text = choiceText, diff --git a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs b/src/SurveyExtensions/Builders/PageBuilder.cs similarity index 58% rename from src/SurveyExtensions/Builders/SurveyPageBuilder.cs rename to src/SurveyExtensions/Builders/PageBuilder.cs index f498b56..6d46f4d 100644 --- a/src/SurveyExtensions/Builders/SurveyPageBuilder.cs +++ b/src/SurveyExtensions/Builders/PageBuilder.cs @@ -5,49 +5,50 @@ using System.Linq.Expressions; using Elements; using Helpers; + using SurveyExtensions.Enums; - public class SurveyPageBuilder: IBuilder where TEntity : new() + public class PageBuilder: IBuilder where TEntity : new() { private SurveyPage _item = new SurveyPage(); private List> elementsBuilder = new List>(); - public SurveyPageBuilder HasName(string name) + public PageBuilder HasName(string name) { _item.Name = name; return this; } - public SurveyPageBuilder AddSingleInput(Expression> expression, Action> inputBuilder) + public PageBuilder AddSingleInputQuestion(Expression> expression, Action> inputBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyInputItemBuilder(); + var builder = new SimgleItemQuestionBuilder(); inputBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddSingleInput(Expression> expression, string title, string placeholder, SurveyInputType inputType) + public PageBuilder AddSingleInputQuestion(Expression> expression, string title, string placeholder, SingleInputTypesEnum inputType) { - return AddSingleInput(expression, + return AddSingleInputQuestion(expression, x => x.HasTitle(title) .HasPlaceHolder(placeholder) .SetInputType(inputType)); } - public SurveyPageBuilder AddCommentInput(Expression> expression, Action> commentBuilder) + public PageBuilder AddCommentInput(Expression> expression, Action> commentBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyCommentItemBuilder(); + var builder = new CommentQuestionBuilder(); commentBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddCommentInput(Expression> expression, string title, string placeholder, int rows) + public PageBuilder AddCommentInput(Expression> expression, string title, string placeholder, int rows) { return AddCommentInput(expression, x => x.HasTitle(title) @@ -55,66 +56,66 @@ public SurveyPageBuilder AddCommentInput(Expression AddCheckboxInput(Expression> expression, Action> checkboxBuilder) + public PageBuilder AddCheckboxInput(Expression> expression, Action> checkboxBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyCheckboxItemBuilder(); + var builder = new CheckboxQuestionBuilder(); checkboxBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddCheckboxInput(Expression> expression, string title) + public PageBuilder AddCheckboxInput(Expression> expression, string title) { return AddCheckboxInput(expression, x => x.HasTitle(title)); } - public SurveyPageBuilder AddRadiogroup(Expression> expression, Action> radiogroupBuilder) + public PageBuilder AddRadiogroup(Expression> expression, Action> radiogroupBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyRadiogroupItemBuilder(); + var builder = new RadiogroupQuestionBuilder(); radiogroupBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddRadiogroup(Expression> expression, string title) + public PageBuilder AddRadiogroup(Expression> expression, string title) { return AddRadiogroup(expression, x => x.HasTitle(title)); } - public SurveyPageBuilder AddDropdown(Expression> expression, Action> dropDownBuilder) + public PageBuilder AddDropdown(Expression> expression, Action> dropDownBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyDropdownItemBuilder(); + var builder = new DropdownQuestionBuilder(); dropDownBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddDropdown(Expression> expression, string title) + public PageBuilder AddDropdown(Expression> expression, string title) { return AddRadiogroup(expression, x => x.HasTitle(title)); } - public SurveyPageBuilder AddRating(Expression> expression, Action> ratingBuilder) + public PageBuilder AddRating(Expression> expression, Action> ratingBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyRatinItemBuilder(); + var builder = new RatingQuestionBuilder(); ratingBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddRating(Expression> expression, + public PageBuilder AddRating(Expression> expression, string title, string description, int rateMin, int rateMax, int rateStep) { return AddRating(expression, @@ -125,55 +126,55 @@ public SurveyPageBuilder AddRating(Expression AddImagePickerInput(Expression> expression, Action> imagePickerBuilder) + public PageBuilder AddImagePickerInput(Expression> expression, Action> imagePickerBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyImagePickerItemBuilder(); + var builder = new ImagePickerQuestionBuilder(); imagePickerBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddImagePickerInput(Expression> expression, string title) + public PageBuilder AddImagePickerInput(Expression> expression, string title) { return AddImagePickerInput(expression, x => x.HasTitle(title)); } - public SurveyPageBuilder AddBooleanInput(Expression> expression, Action> booleanBuilder) + public PageBuilder AddBooleanInput(Expression> expression, Action> booleanBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyBooleanItemBuilder(); + var builder = new BooleanQuestionBuilder(); booleanBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddBooleanInput(Expression> expression, string title, string abel, string labelTrue, string labelNo) + public PageBuilder AddBooleanInput(Expression> expression, string title, string abel, string labelTrue, string labelNo) { return AddImagePickerInput(expression, x => x.HasTitle(title)); } - public SurveyPageBuilder AddHtmlEditor(Expression> expression, Action> htmlEditorBuilder) + public PageBuilder AddHtmlEditor(Expression> expression, Action> htmlEditorBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyHtmlEditorItemBuilder(); + var builder = new HtmlEditorQuestionBuilder(); htmlEditorBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); return this; } - public SurveyPageBuilder AddFile(Expression> expression, Action> fileBuilder) + public PageBuilder AddFile(Expression> expression, Action> fileBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); - var builder = new SurveyFileItemBuilder(); + var builder = new FileQuestionBuilder(); fileBuilder.Invoke(builder); builder.HasName(myProperty.Name); elementsBuilder.Add(builder); diff --git a/src/SurveyExtensions/Builders/QuestionBuilderBase.cs b/src/SurveyExtensions/Builders/QuestionBuilderBase.cs new file mode 100644 index 0000000..de3b798 --- /dev/null +++ b/src/SurveyExtensions/Builders/QuestionBuilderBase.cs @@ -0,0 +1,18 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.Questions; + + public abstract class QuestionBuilderBase : IBuilder + where TEntity : new() + where TQuestion : SurveyQuestion + { + protected TQuestion _item = (TQuestion)(Activator.CreateInstance(typeof(TQuestion))); + + public SurveyItem Build() + { + return _item; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs b/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs new file mode 100644 index 0000000..4cd765c --- /dev/null +++ b/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs @@ -0,0 +1,75 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.Questions; + using SurveyExtensions.Enums; + + public class RadiogroupQuestionBuilder : + QuestionBuilderBase, + IBuilder where TEntity : new() + { + + public RadiogroupQuestionBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public RadiogroupQuestionBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public RadiogroupQuestionBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public RadiogroupQuestionBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public RadiogroupQuestionBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public RadiogroupQuestionBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public RadiogroupQuestionBuilder HasColumnCount(int value) + { + _item.ColCount = value; + return this; + } + + public RadiogroupQuestionBuilder SetChoicesOrder(ChoicesOrderEnum order) + { + string enumName = Enum.GetName(typeof(ChoicesOrderEnum), order); + if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); + return this; + } + + public RadiogroupQuestionBuilder HasOtherChoice(string choiceText) + { + _item.HasOther = true; + _item.OtherText = choiceText; + return this; + } + + public RadiogroupQuestionBuilder AddChoice(string choiceValue, string choiceText) + { + _item.Choices.Add(new Choice() { Value = choiceValue, Text = choiceText }); + return this; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyRatinItemBuilder.cs b/src/SurveyExtensions/Builders/RatingQuestionBuilder.cs similarity index 51% rename from src/SurveyExtensions/Builders/SurveyRatinItemBuilder.cs rename to src/SurveyExtensions/Builders/RatingQuestionBuilder.cs index 20907cd..3fe294c 100644 --- a/src/SurveyExtensions/Builders/SurveyRatinItemBuilder.cs +++ b/src/SurveyExtensions/Builders/RatingQuestionBuilder.cs @@ -1,80 +1,80 @@ namespace SurveyExtensions.Builders { - using System; using Elements; using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.Questions; - public class SurveyRatinItemBuilder : - SurveyItemBuilderBase, + public class RatingQuestionBuilder : + QuestionBuilderBase, IBuilder where TEntity : new() { - public SurveyRatinItemBuilder HasName(string value) + public RatingQuestionBuilder HasName(string value) { _item.Name = value; return this; } - public SurveyRatinItemBuilder HasTitle(string value) + public RatingQuestionBuilder HasTitle(string value) { _item.Title = value; return this; } - public SurveyRatinItemBuilder HasDescription(string value) + public RatingQuestionBuilder HasDescription(string value) { _item.Description = value; return this; } - public SurveyRatinItemBuilder IsRequired() + public RatingQuestionBuilder IsRequired() { _item.IsRequired = true; return this; } - public SurveyRatinItemBuilder IsHidden() + public RatingQuestionBuilder IsHidden() { _item.Visible = false; return this; } - public SurveyRatinItemBuilder ContinueInSameLine() + public RatingQuestionBuilder ContinueInSameLine() { _item.StartWithNewLine = false; return this; } - public SurveyRatinItemBuilder HasRateMin(int value) + public RatingQuestionBuilder HasRateMin(int value) { _item.RateMin = value; return this; } - public SurveyRatinItemBuilder HasRateMax(int value) + public RatingQuestionBuilder HasRateMax(int value) { _item.RateMax = value; return this; } - public SurveyRatinItemBuilder HasRateStep(int value) + public RatingQuestionBuilder HasRateStep(int value) { _item.RateStep = value; return this; } - public SurveyRatinItemBuilder AddRateValue(string value, string text) + public RatingQuestionBuilder AddRateValue(string value, string text) { - _item.RateValues.Add(new SurveyChoice() { Value = value, Text = text}); + _item.RateValues.Add(new Choice() { Value = value, Text = text}); return this; } - public SurveyRatinItemBuilder HasMinRateDescription(string value) + public RatingQuestionBuilder HasMinRateDescription(string value) { _item.MinRateDescription = value; return this; } - public SurveyRatinItemBuilder HasMaxRateDescription(string value) + public RatingQuestionBuilder HasMaxRateDescription(string value) { _item.MaxRateDescription = value; return this; diff --git a/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs b/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs new file mode 100644 index 0000000..ab5d692 --- /dev/null +++ b/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs @@ -0,0 +1,60 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.Questions; + using SurveyExtensions.Enums; + + public class SimgleItemQuestionBuilder : + QuestionBuilderBase, + IBuilder where TEntity : new() + { + public SimgleItemQuestionBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public SimgleItemQuestionBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public SimgleItemQuestionBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public SimgleItemQuestionBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public SimgleItemQuestionBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public SimgleItemQuestionBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public SimgleItemQuestionBuilder SetInputType(SingleInputTypesEnum inputType) + { + string enumName = Enum.GetName(typeof(SingleInputTypesEnum) ,inputType); + if (enumName != null) _item.InputType = enumName.ToLowerInvariant(); + return this; + } + + public SimgleItemQuestionBuilder HasPlaceHolder(string placeholder) + { + _item.PlaceHolder = placeholder; + return this; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyBuilder.cs b/src/SurveyExtensions/Builders/SurveyBuilder.cs index 4bc9a41..9877b3f 100644 --- a/src/SurveyExtensions/Builders/SurveyBuilder.cs +++ b/src/SurveyExtensions/Builders/SurveyBuilder.cs @@ -8,12 +8,12 @@ public class SurveyBuilder where TEntity : new() { private readonly Survey survey = new Survey(); - private readonly List> _pageBuilders = new List>(); + private readonly List> _pageBuilders = new List>(); - public SurveyBuilder AddPage(string pageName, Action> pageBuilder) + public SurveyBuilder AddPage(string pageName, Action> pageBuilder) { - var builder = new SurveyPageBuilder(); + var builder = new PageBuilder(); pageBuilder.Invoke(builder); builder.HasName(pageName); _pageBuilders.Add(builder); diff --git a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs deleted file mode 100644 index a83e47c..0000000 --- a/src/SurveyExtensions/Builders/SurveyDropdownItemBuilder.cs +++ /dev/null @@ -1,67 +0,0 @@ -namespace SurveyExtensions.Builders -{ - using System; - using Elements; - using SurveyExtensions.Elements.ChoiceItems; - - public class SurveyDropdownItemBuilder : - SurveyItemBuilderBase, - IBuilder where TEntity : new() - { - - public SurveyDropdownItemBuilder HasName(string value) - { - _item.Name = value; - return this; - } - public SurveyDropdownItemBuilder HasTitle(string value) - { - _item.Title = value; - return this; - } - - public SurveyDropdownItemBuilder HasDescription(string value) - { - _item.Description = value; - return this; - } - - public SurveyDropdownItemBuilder IsRequired() - { - _item.IsRequired = true; - return this; - } - - public SurveyDropdownItemBuilder IsHidden() - { - _item.Visible = false; - return this; - } - - public SurveyDropdownItemBuilder ContinueInSameLine() - { - _item.StartWithNewLine = false; - return this; - } - - public SurveyDropdownItemBuilder SetChoicesOrder(SurveyChoicesOrderEnum order) - { - string enumName = Enum.GetName(typeof(SurveyChoicesOrderEnum), order); - if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); - return this; - } - - public SurveyDropdownItemBuilder HasOtherChoice(string choiceText) - { - _item.HasOther = true; - _item.OtherText = choiceText; - return this; - } - - public SurveyDropdownItemBuilder AddChoice(string choiceValue, string choiceText) - { - _item.Choices.Add(new SurveyChoice() { Value = choiceValue, Text = choiceText }); - return this; - } - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs deleted file mode 100644 index 85297c4..0000000 --- a/src/SurveyExtensions/Builders/SurveyInputItemBuilder.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace SurveyExtensions.Builders -{ - using System; - using Elements; - - public class SurveyInputItemBuilder : - SurveyItemBuilderBase, - IBuilder where TEntity : new() - { - public SurveyInputItemBuilder HasName(string value) - { - _item.Name = value; - return this; - } - public SurveyInputItemBuilder HasTitle(string value) - { - _item.Title = value; - return this; - } - - public SurveyInputItemBuilder HasDescription(string value) - { - _item.Description = value; - return this; - } - - public SurveyInputItemBuilder IsRequired() - { - _item.IsRequired = true; - return this; - } - - public SurveyInputItemBuilder IsHidden() - { - _item.Visible = false; - return this; - } - - public SurveyInputItemBuilder ContinueInSameLine() - { - _item.StartWithNewLine = false; - return this; - } - - public SurveyInputItemBuilder SetInputType(SurveyInputType inputType) - { - string enumName = Enum.GetName(typeof(SurveyInputType) ,inputType); - if (enumName != null) _item.InputType = enumName.ToLowerInvariant(); - return this; - } - - public SurveyInputItemBuilder HasPlaceHolder(string placeholder) - { - _item.PlaceHolder = placeholder; - return this; - } - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs b/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs deleted file mode 100644 index 840da24..0000000 --- a/src/SurveyExtensions/Builders/SurveyItemBuilderBase.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace SurveyExtensions.Builders -{ - using System; - using Elements; - - public abstract class SurveyItemBuilderBase : IBuilder - where TEntity : new() - where TItem : SurveyPageElement - { - protected TItem _item = (TItem)(Activator.CreateInstance(typeof(TItem))); - - public SurveyItem Build() - { - return _item; - } - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs b/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs deleted file mode 100644 index 5de23e5..0000000 --- a/src/SurveyExtensions/Builders/SurveyRadiogroupItemBuilder.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace SurveyExtensions.Builders -{ - using System; - using Elements; - using SurveyExtensions.Elements.ChoiceItems; - - public class SurveyRadiogroupItemBuilder : - SurveyItemBuilderBase, - IBuilder where TEntity : new() - { - - public SurveyRadiogroupItemBuilder HasName(string value) - { - _item.Name = value; - return this; - } - public SurveyRadiogroupItemBuilder HasTitle(string value) - { - _item.Title = value; - return this; - } - - public SurveyRadiogroupItemBuilder HasDescription(string value) - { - _item.Description = value; - return this; - } - - public SurveyRadiogroupItemBuilder IsRequired() - { - _item.IsRequired = true; - return this; - } - - public SurveyRadiogroupItemBuilder IsHidden() - { - _item.Visible = false; - return this; - } - - public SurveyRadiogroupItemBuilder ContinueInSameLine() - { - _item.StartWithNewLine = false; - return this; - } - - public SurveyRadiogroupItemBuilder HasColumnCount(int value) - { - _item.ColCount = value; - return this; - } - - public SurveyRadiogroupItemBuilder SetChoicesOrder(SurveyChoicesOrderEnum order) - { - string enumName = Enum.GetName(typeof(SurveyChoicesOrderEnum), order); - if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); - return this; - } - - public SurveyRadiogroupItemBuilder HasOtherChoice(string choiceText) - { - _item.HasOther = true; - _item.OtherText = choiceText; - return this; - } - - public SurveyRadiogroupItemBuilder AddChoice(string choiceValue, string choiceText) - { - _item.Choices.Add(new SurveyChoice() { Value = choiceValue, Text = choiceText }); - return this; - } - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoice.cs b/src/SurveyExtensions/Elements/ChoiceItems/Choice.cs similarity index 83% rename from src/SurveyExtensions/Elements/ChoiceItems/SurveyChoice.cs rename to src/SurveyExtensions/Elements/ChoiceItems/Choice.cs index 6ad52c1..b4a265d 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoice.cs +++ b/src/SurveyExtensions/Elements/ChoiceItems/Choice.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.ChoiceItems { - public class SurveyChoice + public class Choice { public string Value { get; set; } diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerChoice.cs b/src/SurveyExtensions/Elements/ChoiceItems/ImagePickerChoice.cs similarity index 68% rename from src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerChoice.cs rename to src/SurveyExtensions/Elements/ChoiceItems/ImagePickerChoice.cs index fd2f1ca..3b0b080 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerChoice.cs +++ b/src/SurveyExtensions/Elements/ChoiceItems/ImagePickerChoice.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.ChoiceItems { - public class SurveyImagePickerChoice : SurveyChoice + public class ImagePickerChoice : Choice { public string ImageLink { get; set; } diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoicesOrderEnum.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoicesOrderEnum.cs deleted file mode 100644 index 4ae59ce..0000000 --- a/src/SurveyExtensions/Elements/ChoiceItems/SurveyChoicesOrderEnum.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace SurveyExtensions.Elements.ChoiceItems -{ - public enum SurveyChoicesOrderEnum - { - none, - asc, - desc, - random, - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerItem.cs b/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerItem.cs deleted file mode 100644 index 2593dfd..0000000 --- a/src/SurveyExtensions/Elements/ChoiceItems/SurveyImagePickerItem.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace SurveyExtensions.Elements.ChoiceItems -{ - using System.Collections.Generic; - - public class SurveyImagePickerItem : SurveyPageElement - { - public SurveyImagePickerItem() - { - Type = "imagepicker"; - } - - public string ChoicesOrder { get; set; } - - public int ColCount { get; set; } = 0; - - public IList Choices { get; set; } = new List(); - - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyBooleanItem.cs b/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs similarity index 62% rename from src/SurveyExtensions/Elements/SurveyBooleanItem.cs rename to src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs index 0a32d23..75057d4 100644 --- a/src/SurveyExtensions/Elements/SurveyBooleanItem.cs +++ b/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs @@ -1,8 +1,8 @@ -namespace SurveyExtensions.Elements +namespace SurveyExtensions.Elements.Questions { - public class SurveyBooleanItem : SurveyPageElement + public class BooleanQuestion : SurveyQuestion { - public SurveyBooleanItem() + public BooleanQuestion() { Type = "boolean"; } diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyCheckboxItem.cs b/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs similarity index 63% rename from src/SurveyExtensions/Elements/ChoiceItems/SurveyCheckboxItem.cs rename to src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs index cce5efa..16cf7fd 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/SurveyCheckboxItem.cs +++ b/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs @@ -1,10 +1,11 @@ -namespace SurveyExtensions.Elements.ChoiceItems +namespace SurveyExtensions.Elements.Questions { + using SurveyExtensions.Elements.ChoiceItems; using System.Collections.Generic; - public class SurveyCheckboxItem : SurveyPageElement + public class CheckboxQuestion : SurveyQuestion { - public SurveyCheckboxItem() + public CheckboxQuestion() { Type = "checkbox"; } @@ -13,7 +14,7 @@ public SurveyCheckboxItem() public int ColCount { get; set; } - public IList Choices { get; set; } = new List(); + public IList Choices { get; set; } = new List(); public string OtherText { get; set; } diff --git a/src/SurveyExtensions/Elements/SurveyCommentItem.cs b/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs similarity index 53% rename from src/SurveyExtensions/Elements/SurveyCommentItem.cs rename to src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs index 96b170e..d5ad5e6 100644 --- a/src/SurveyExtensions/Elements/SurveyCommentItem.cs +++ b/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs @@ -1,8 +1,8 @@ -namespace SurveyExtensions.Elements +namespace SurveyExtensions.Elements.Questions { - public class SurveyCommentItem : SurveyPageElement + public class CommentsQuestion : SurveyQuestion { - public SurveyCommentItem() + public CommentsQuestion() { Type = "comment"; } diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyDropdownItem.cs b/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs similarity index 54% rename from src/SurveyExtensions/Elements/ChoiceItems/SurveyDropdownItem.cs rename to src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs index 1dda3c1..0c9f6f6 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/SurveyDropdownItem.cs +++ b/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs @@ -1,18 +1,19 @@ -namespace SurveyExtensions.Elements.ChoiceItems +namespace SurveyExtensions.Elements.Questions { + using SurveyExtensions.Elements.ChoiceItems; using System.Collections.Generic; - public class SurveyDropdownItem : SurveyPageElement + public class DropdownIQuestion : SurveyQuestion { - public SurveyDropdownItem() + public DropdownIQuestion() { Type = "dropdown"; } public string ChoicesOrder { get; set; } - public IList Choices { get; set; } = new List(); + public IList Choices { get; set; } = new List(); public bool HasOther { get; set; } = false; diff --git a/src/SurveyExtensions/Elements/Questions/FileQuestion.cs b/src/SurveyExtensions/Elements/Questions/FileQuestion.cs new file mode 100644 index 0000000..f9d4d51 --- /dev/null +++ b/src/SurveyExtensions/Elements/Questions/FileQuestion.cs @@ -0,0 +1,12 @@ +namespace SurveyExtensions.Elements.Questions +{ + public class FileQuestion : SurveyQuestion + { + public FileQuestion() + { + Type = "file"; + } + + public int MaxSize { get; set; } = 0; + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs b/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs new file mode 100644 index 0000000..0483070 --- /dev/null +++ b/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs @@ -0,0 +1,12 @@ +namespace SurveyExtensions.Elements.Questions +{ + public class HtmlEditorQuestion : SurveyQuestion + { + public HtmlEditorQuestion() + { + Type = "html"; + } + + public string Html { get; set; } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs b/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs new file mode 100644 index 0000000..10cb593 --- /dev/null +++ b/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs @@ -0,0 +1,20 @@ +namespace SurveyExtensions.Elements.Questions +{ + using SurveyExtensions.Elements.ChoiceItems; + using System.Collections.Generic; + + public class ImagePickerQuestion : SurveyQuestion + { + public ImagePickerQuestion() + { + Type = "imagepicker"; + } + + public string ChoicesOrder { get; set; } + + public int ColCount { get; set; } = 0; + + public IList Choices { get; set; } = new List(); + + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyRadiogroupItem.cs b/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs similarity index 52% rename from src/SurveyExtensions/Elements/ChoiceItems/SurveyRadiogroupItem.cs rename to src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs index 6415549..084b188 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/SurveyRadiogroupItem.cs +++ b/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs @@ -1,11 +1,12 @@ -namespace SurveyExtensions.Elements.ChoiceItems +namespace SurveyExtensions.Elements.Questions { + using SurveyExtensions.Elements.ChoiceItems; using System.Collections.Generic; - public class SurveyRadiogroupItem : SurveyPageElement + public class RadiogroupQuestion : SurveyQuestion { - public SurveyRadiogroupItem() + public RadiogroupQuestion() { Type = "radiogroup"; } @@ -15,7 +16,7 @@ public SurveyRadiogroupItem() public bool HasOther { get; set; } public string OtherText { get; set; } - public IList Choices { get; set; } = new List(); + public IList Choices { get; set; } = new List(); } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/ChoiceItems/SurveyRatingItem.cs b/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs similarity index 58% rename from src/SurveyExtensions/Elements/ChoiceItems/SurveyRatingItem.cs rename to src/SurveyExtensions/Elements/Questions/RatingQuestion.cs index 4d36206..87c1be8 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/SurveyRatingItem.cs +++ b/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs @@ -1,11 +1,12 @@ -namespace SurveyExtensions.Elements.ChoiceItems +namespace SurveyExtensions.Elements.Questions { + using SurveyExtensions.Elements.ChoiceItems; using System.Collections.Generic; - public class SurveyRatingItem : SurveyPageElement + public class RatingQuestion : SurveyQuestion { - public SurveyRatingItem() + public RatingQuestion() { Type = "rating"; } @@ -14,7 +15,7 @@ public SurveyRatingItem() public int RateMax { get; set; } = 5; public int RateStep { get; set; } = 1; - public IList RateValues { get; set; } = new List(); + public IList RateValues { get; set; } = new List(); public string MinRateDescription { get; set; } diff --git a/src/SurveyExtensions/Elements/SurveyInputItem.cs b/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs similarity index 57% rename from src/SurveyExtensions/Elements/SurveyInputItem.cs rename to src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs index 2800e68..c0c187c 100644 --- a/src/SurveyExtensions/Elements/SurveyInputItem.cs +++ b/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs @@ -1,8 +1,8 @@ -namespace SurveyExtensions.Elements +namespace SurveyExtensions.Elements.Questions { - public class SurveyInputItem : SurveyPageElement + public class SingleInputQuestion : SurveyQuestion { - public SurveyInputItem() + public SingleInputQuestion() { Type = "text"; InputType = "text"; diff --git a/src/SurveyExtensions/Elements/Questions/SurveyQuestion.cs b/src/SurveyExtensions/Elements/Questions/SurveyQuestion.cs new file mode 100644 index 0000000..c1d7a25 --- /dev/null +++ b/src/SurveyExtensions/Elements/Questions/SurveyQuestion.cs @@ -0,0 +1,15 @@ +namespace SurveyExtensions.Elements.Questions +{ + using System; + + public abstract class SurveyQuestion : SurveyItem + { + public string Type { get; set; } + public string Title { get; set; } + public string Description { get; set; } + public bool Visible { get; set; } = true; + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; + + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyFileItem.cs b/src/SurveyExtensions/Elements/SurveyFileItem.cs deleted file mode 100644 index 82ec60e..0000000 --- a/src/SurveyExtensions/Elements/SurveyFileItem.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace SurveyExtensions.Elements -{ - public class SurveyFileItem : SurveyPageElement - { - public SurveyFileItem() - { - Type = "file"; - } - - public int MaxSize { get; set; } = 0; - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyHtmlEditorItem.cs b/src/SurveyExtensions/Elements/SurveyHtmlEditorItem.cs deleted file mode 100644 index 7f971b3..0000000 --- a/src/SurveyExtensions/Elements/SurveyHtmlEditorItem.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace SurveyExtensions.Elements -{ - public class SurveyHtmlEditorItem : SurveyPageElement - { - public SurveyHtmlEditorItem() - { - Type = "html"; - } - - public string Html { get; set; } - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyInputType.cs b/src/SurveyExtensions/Elements/SurveyInputType.cs deleted file mode 100644 index c69274b..0000000 --- a/src/SurveyExtensions/Elements/SurveyInputType.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace SurveyExtensions.Elements -{ - public enum SurveyInputType - { - Text, - Date, - Color, - Email - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyItem.cs b/src/SurveyExtensions/Elements/SurveyItem.cs index 8a061f6..c0c5dce 100644 --- a/src/SurveyExtensions/Elements/SurveyItem.cs +++ b/src/SurveyExtensions/Elements/SurveyItem.cs @@ -3,9 +3,6 @@ public class SurveyItem { public string Name { get; set; } - public bool Visible { get; set; } = true; - public bool IsRequired { get; set; } = false; - public bool StartWithNewLine { get; set; } = true; } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyPage.cs b/src/SurveyExtensions/Elements/SurveyPage.cs index f0b5f63..e576641 100644 --- a/src/SurveyExtensions/Elements/SurveyPage.cs +++ b/src/SurveyExtensions/Elements/SurveyPage.cs @@ -2,7 +2,7 @@ { using System.Collections.Generic; - public class SurveyPage:SurveyItem + public class SurveyPage : SurveyItem { public IList Elements { get; set; } = new List(); } diff --git a/src/SurveyExtensions/Elements/SurveyPageElement.cs b/src/SurveyExtensions/Elements/SurveyPageElement.cs deleted file mode 100644 index ae14e4c..0000000 --- a/src/SurveyExtensions/Elements/SurveyPageElement.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace SurveyExtensions.Elements -{ - using System; - - public class SurveyPageElement : SurveyItem - { - public string Type { get; set; } - public string Title { get; set; } - public string Description { get; set; } - - } -} \ No newline at end of file diff --git a/src/SurveyExtensions/Enums/ChoicesOrderEnum.cs b/src/SurveyExtensions/Enums/ChoicesOrderEnum.cs new file mode 100644 index 0000000..298c814 --- /dev/null +++ b/src/SurveyExtensions/Enums/ChoicesOrderEnum.cs @@ -0,0 +1,10 @@ +namespace SurveyExtensions.Enums +{ + public enum ChoicesOrderEnum + { + none, + asc, + desc, + random, + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Enums/SingleInputTypesEnum.cs b/src/SurveyExtensions/Enums/SingleInputTypesEnum.cs new file mode 100644 index 0000000..fb144ab --- /dev/null +++ b/src/SurveyExtensions/Enums/SingleInputTypesEnum.cs @@ -0,0 +1,10 @@ +namespace SurveyExtensions.Enums +{ + public enum SingleInputTypesEnum + { + Text, + Date, + Color, + Email + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/Factory/BulderFactory.cs b/test/SurveyExtensionsTests/Factory/BulderFactory.cs index 921d221..7da81b7 100644 --- a/test/SurveyExtensionsTests/Factory/BulderFactory.cs +++ b/test/SurveyExtensionsTests/Factory/BulderFactory.cs @@ -1,7 +1,7 @@ namespace SurveyExtensionsTests.Factory { using SurveyExtensions.Builders; - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Enums; using SurveyExtensionsTests.Dtos; @@ -24,7 +24,7 @@ public static void Get_1Page_CheckboxWithAllWithNoneSortedAscending .HasOtherChoice("Other choice text") .HasSelectAllChoice("Select All") .HasSelectNoneChoice("Select none") - .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) + .SetChoicesOrder(ChoicesOrderEnum.asc)) ); } @@ -43,7 +43,7 @@ public static void Get_1Page_CheckboxWithAllSortedDescending .HasColumnCount(2) .HasOtherChoice("Other choice text") .HasSelectAllChoice("Select All") - .SetChoicesOrder(SurveyChoicesOrderEnum.desc)) + .SetChoicesOrder(ChoicesOrderEnum.desc)) ); } @@ -64,7 +64,7 @@ public static void Get_1Page_CheckboxWithNoneSortedRandom .HasColumnCount(3) .HasOtherChoice("Other choice text") .HasSelectNoneChoice("Select none") - .SetChoicesOrder(SurveyChoicesOrderEnum.random)) + .SetChoicesOrder(ChoicesOrderEnum.random)) ); } @@ -83,7 +83,7 @@ public static void Get_1Page_RadiogroupAscending(SurveyBuilder build .AddChoice("RG1Val5", "Choice 5") .HasColumnCount(1) .HasOtherChoice("Other choice text") - .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) + .SetChoicesOrder(ChoicesOrderEnum.asc)) ); } @@ -118,7 +118,7 @@ public static void Get_1Page_RadiogroupRandom(SurveyBuilder builder, .AddChoice("RG3Val4", "Choice 4") .AddChoice("RG3Val5", "Choice 5") .HasColumnCount(3) - .SetChoicesOrder(SurveyChoicesOrderEnum.random)) + .SetChoicesOrder(ChoicesOrderEnum.random)) ); } @@ -137,7 +137,7 @@ public static void Get_1Page_DropdownAscending(SurveyBuilder builder .AddChoice("DD1Val4", "Choice 4") .AddChoice("DD1Val5", "Choice 5") .HasOtherChoice("Other choice text") - .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) + .SetChoicesOrder(ChoicesOrderEnum.asc)) ); } @@ -155,7 +155,7 @@ public static void Get_1Page_DropdownDescending(SurveyBuilder builde .AddChoice("DD2Val3", "Choice 3") .AddChoice("DD2Val4", "Choice 4") .AddChoice("DD2Val5", "Choice 5") - .SetChoicesOrder(SurveyChoicesOrderEnum.desc)) + .SetChoicesOrder(ChoicesOrderEnum.desc)) ); } @@ -173,7 +173,7 @@ public static void Get_1Page_DropdownRandom(SurveyBuilder builder, .AddChoice("DD3Val3", "Choice 3") .AddChoice("DD3Val4", "Choice 4") .AddChoice("DD3Val5", "Choice 5") - .SetChoicesOrder(SurveyChoicesOrderEnum.random)) + .SetChoicesOrder(ChoicesOrderEnum.random)) ); } @@ -190,7 +190,7 @@ public static void Get_1Page_ImagePickerAscending(SurveyBuilder buil .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") .HasColumnCount(0) - .SetChoicesOrder(SurveyChoicesOrderEnum.asc)) + .SetChoicesOrder(ChoicesOrderEnum.asc)) ); } @@ -207,7 +207,7 @@ public static void Get_1Page_ImagePickerDescending(SurveyBuilder bui .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") .HasColumnCount(2) - .SetChoicesOrder(SurveyChoicesOrderEnum.desc)) + .SetChoicesOrder(ChoicesOrderEnum.desc)) ); } @@ -224,7 +224,7 @@ public static void Get_1Page_ImagePickerRandom(SurveyBuilder builder .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") .HasColumnCount(0) - .SetChoicesOrder(SurveyChoicesOrderEnum.random)) + .SetChoicesOrder(ChoicesOrderEnum.random)) ); } } diff --git a/test/SurveyExtensionsTests/GeneralBuilderTests.cs b/test/SurveyExtensionsTests/GeneralBuilderTests.cs index e465bc3..07a4c6d 100644 --- a/test/SurveyExtensionsTests/GeneralBuilderTests.cs +++ b/test/SurveyExtensionsTests/GeneralBuilderTests.cs @@ -6,6 +6,7 @@ namespace SurveyExtensionsTests using FluentAssertions; using SurveyExtensions.Builders; using SurveyExtensions.Elements; + using SurveyExtensions.Enums; public class GeneralBuilderTests { @@ -16,22 +17,22 @@ public void TestSingleInput() companyBuilder.AddPage("Pagina 1", page => - page.AddSingleInput(x => x.DocumentId, + page.AddSingleInputQuestion(x => x.DocumentId, b => b .HasTitle("Dni") .HasPlaceHolder("Ponga aqui su dni") - .SetInputType(SurveyInputType.Text)) - .AddSingleInput(x=> x.ContactData, + .SetInputType(SingleInputTypesEnum.Text)) + .AddSingleInputQuestion(x=> x.ContactData, b=> b .HasTitle("Datos de Contacto") .HasPlaceHolder("Ponga Aqui sus Datos de Contacto")) ) .AddPage("Pagina 2", page=> - page.AddSingleInput(x=> x.IsCashReceiptCriteria, b=> b.SetInputType(SurveyInputType.Email)) + page.AddSingleInputQuestion(x=> x.IsCashReceiptCriteria, b=> b.SetInputType(SingleInputTypesEnum.Email)) ); companyBuilder.AddPage("MiPaginaMolona", - p => p.AddSingleInput(c => c.DocumentId, "placeholderMolon", "MiDni", SurveyInputType.Text)); + p => p.AddSingleInputQuestion(c => c.DocumentId, "placeholderMolon", "MiDni", SingleInputTypesEnum.Text)); diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 372f353..41f2ab0 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -1,6 +1,5 @@ namespace SurveyExtensionsTests { - using System; using Xunit; using SurveyExtensionsTests.Dtos; using FluentAssertions; @@ -8,7 +7,7 @@ namespace SurveyExtensionsTests using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using SurveyExtensions.Builders; - using SurveyExtensions.Elements; + using SurveyExtensions.Enums; public class JsonTests { @@ -18,7 +17,7 @@ public void SingleTextInputTest() SurveyBuilder companyBuilder = new SurveyBuilder(); companyBuilder.AddPage("Page1", - p => p.AddSingleInput(c => c.DocumentId, "Put Here your DNI", "Document Id Card", SurveyInputType.Text) + p => p.AddSingleInputQuestion(c => c.DocumentId, "Put Here your DNI", "Document Id Card", SingleInputTypesEnum.Text) ); var myBuildedElements = companyBuilder.Build(); From 444eb04bdf913a0e0b930196ea88bbd37c30ace2 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sat, 23 Nov 2019 19:20:11 +0100 Subject: [PATCH 14/25] Added xls file for quiestions properties listing --- QuestionsProperties.xlsx | Bin 0 -> 11983 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 QuestionsProperties.xlsx diff --git a/QuestionsProperties.xlsx b/QuestionsProperties.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..9bd12de4a840ace6040d1cd9b728db2695816af2 GIT binary patch literal 11983 zcmeHtWmH|swlx|&XmEFOf;++8-66Ph4tCJs5}e==+#xu@gS$%zZb1XV-R+&E?|t2! z+us=9|9AI~+M{aMTxDz4TDxi~%fZ6oKs|#(go1*ifXaLYw6}$Zg2I4@g2IMEgwYeT zw{tePb2e1>a4-kIVR8on$#dag=(C|ZWh$wBk2~gM1W0=qcCFm zqHzZ%Eh{NG^&ugnLM{){;^Kydsp!Wt(Y*o{qPwT|MpxRJH>TB$a8qMRK>bMVXPSHk z2PI}l!`t_n=J@Y4x_D4%7GbOB&u?w2mpnTns~MBZ-cJZQysr+HG+N`=UMSYL63?Hl zS~nP|(}r#*i8^d_<_d`N0CLVbpCTsCefS`7@Z-#%+D{~D6y3jEYcS|aQVugL!M^_4x-oZrVU@;*G2`T;Df(KW ziJSIiYR5n0LQm6J;o@h@9WGDFns=?NA}`EMMp(_o=GhkTKTP!I*eQ9~zl zAefoyXZl}m{vRgfUxr>5r=au)H}69RuBMk`Fhu3tM5LQ3)P4M9meA{>@~DZH+v$ig z)CmJ&rF>g`?uQna`J;9RC@$AI$|A6EUQ^Y(l?Nx^I=Uddq;*P?bSzuz!E~Lzn7&Mr zlJ%f>ZH<0e+W0X?Zg7Q4a`Hs{6UI1`79kRL0dX*{K#IR^pMuUelj{oTX;HO<^5Cil z?(E(8@igDrq{1CEp-^7={jVu62EZnk^A%nLK#GeSLJc)5Uh688Oea1{4?{Cx$C-Fq zJNAPYqhk7iDkTTjHQTsUKTY<9uWl{J$#8~84>wYG>A>+|Km^&xZxD0!pCoB7A$UrF zg@Sqmv1{m%nQ;d)yV*P0n%LXh{xo7`8X)^T9*jqyuMY^%F95w;BvWQD;G~HHxDwS5Mg4$LB1wnwr=$KgL9IV`FDgPG&2N zq0I2hkF?vd0oc%rrPX4>xt&b})vSF|A0HRzlOpzC7Dbw#%>y5)>nhaE317t8=&(pcgb{Sb+3&=P)TY&%zi=nn=Zm#g zx^im6krbKDFP}m~^au(WLkyTZxkw|A)G7FA6`BkFM*n4vslsqtKU#p9mwu@+*SA4l z+3M97ydGq#LG0?dWbs5vKuH*{(jgQ4lO&kth^YhYwj54(+p_N$mlV+QI)>h35&cOd zpL#ZS5#v_a-u;mktwWVM4}&?8W%b6(5xTdLR!Nxd<4;Od){ z>5DJ9;zm*|IA=$&Jfvm(qhP|@T%of8d$Q}f_?cJB(&boXnKBJMK$5hDZB9__QW?f{ zUuppnEjvYF1dlt7$}-brSgOL_1GrH zFICL@Z~5^kYhXZvyD6DdTo&hh$vJ z(e2UDMH0&BKen-tShwGh(bZsc^M2+#S!Tb3!mV{`p;_JhV)1r2r4OI?Q=#;07YYrb zz%GJ(1Wzm6+_{=Bszr3+B!E->{!~vC%bk$nUbc%m!Sfdh_hbl;D^`Q<4c19Cn7fiO z_n3A)fF?x>0zQl7=N(ruz+EW@C;!~!wUJYY$TAKz;gN`u3$d8nuOYhc&0Mbc&`ASh zmwgq&Y}P`*6p6Jfo_{zf^W1pLvR~pkbv`&Pico!byJ9e6cNgm0G#-N>a5-JmzpwE0 zj|7fGNZ5yid=Y|>m=FpP8baVd4BcO8{BNTN4RJ^zb^mWaWpTqcJuIjaSMMGJC)ym@ zyp@9;EhbbyfYN;Y91?isO%U|FH;-&p`35^;?5bI%yRJyXniqZD%CD)(2rXZj$sh-m zxtg2W!XNbxk5YwpSjho1Xy9St=eB3Hnzd|VH;Rl>1w%iY1j2ML*%zQLD2Gru3e58q zrys?b?%2-f37RN4#TTM~9p@w$n#2iF^%qKLAP>)p9(%HFF0tVdc>ORD`yB&>FT`cCN`Q2#hCGogu{GImD$!HROH77w^y3jMR9_;?&7n?jfL7xq=B~44S zP`O+KcKv$<+ZKW>{eKz(d}-TEL1ZW>0tqN6d`OLd z83C}Bxw$i#`PYl}r!~me*8}hJVEL?+JfP!nqBo;Mdr=9~q#(O>(ePMWHe60n(B?dI zzbimjOy z-`3wG%*0)}qYv=$?&qTV@VCrNUWpO6R!KI4mO&h;7jJ6kwZOq+IjB)uK6#Ot60k*CRqQBU2f15NWEt`lol(O0D!)t(69+oP`W4`%t(Lw3_CEr;=9=PmH< zzC1p)CHFiXzD)OL;r&%Bz8+ugYWS$FtH*3Q^vCb+rypEf-$ZMs@030jSP{4TgbH!v z3yXYTa2Z76Nd^q?%T?3Tb+7R`3vw|xOh0iF9Y}VAYAY8iwheD)16NCy&kief10Nk6 zd=KvIRv%Sbn?2@*gC-wK>z+gM2Jz;^bd1ZX0s*yNsJ51Fi1EQle=eO7od-bY(thzX^(f1IS zMCo>0@J_ua@+gLHzvrA17dSG{KiZzfwTd(txwiJ~{V+`vpjqiZ*}7m1ToJv}CUi0I zx!iDu_dt77{25x%G7;#H^Jq8^atIJLkQAD`xQnfMV+-%U0(=8I3Qo7^Msv~xlty#N zx%S3K>+_=YBz@|rGjg<$QGpGQbH;chi7-p`rWseCn;$`+#qul~=)lOg zJwx0+QEL)NTGiHBXJo6t`Z6CnFA(51?Xy||sUT3@nQ?O5jXZh_r^RYy2XKICrm!Wu zS$(@{E5l&1Bp`pwZ@DJfBTQY+OO*xh05&^kMl4YqL1o=#xFRg*clZH9@(ssd}U&p`l(bNIYJckek*4F<+ux|%#%3npNh zrdUhF~|km(h#)i@ITXjuTc!9isappj%THLKkzoX=k^V@y7c9qt7nzus66Q>&Z54QpgXA zh@SbfO~#%C^%yr91-=#(CTDxa%sKv^Spm^AFUfDTe5po~#YhvF%d5+}y%Y=wmB zyJD-ZnmxHLLHLX!N@J1LAd#@m?hN;vO<3EuB?j}d2zfqZ2_tV9B8<714oNsJ+A1V} z1tg%P5g0}fV~)z75$P4q2d=sVwp(=$-Zb40@y|)!y}pGdZsj|yb2WQC_vaj^kl=BS zl}Q$Zo1v?M_D4ekiW`~2q+!e@bXdS~(N)3!ONLU5+UE;(j!z@l{P#>*bXMNFKXB0I zM;XWP_+a+1=lnW?;kYQPSp5|c_x(Ex;kc-(c>Ng>_hUPf;Bb-4oO1xF_c}>oFwWJ4 zohbn#N&cLMQ3=jRl<{_)l)uf$|AK!_hHRyz1orSWqLL~a7W}A3A-&!-)5g~VWcW)4 z2Vs9PWMY-o4={8%*TVj4$muGp=`eUWjrkqQFmiGf-}<;pS232UOFPmn6DfzAo;z7r zzf2G=2g}}UDFD5@!JkjziN~Kl+Yi|lMr4mQP{0RceFW>rCMvarm2bEs8?EwuhycaC z9f-7NbJ$rkx>2W!|)I(+HXg~ zGw0qD9G;-{p^o%^V31kqPFB5TrRsp5c9QqcflDH-$)&3|4NlVvWQ7H@T7<9ft?h9= ze861wvmubpw$q*}$F(;caJ$lbq`B>;WNtjCR^Is34NZT zbmDXT6ecGu?HS&0J#0=DDK_HZwe)I&9agq-u&7#+YlW4`UU~}9*?j)TOAV0UM@?)w zBkOHsLA~vf{2YLsn3m2tLg;P=Hl%PfIcq-(M=otcu0lv?&SjK?I5i^gO+hFsehL@k zyI{b<(mRug2Wb79X{^zA;Ba9QmY;0^6I~BQH8xX=DLL@Q7z&IA25QF=-B+^r#dxz0 z(%C1uD#}3m=5@prC0Ssa=YtyCOzQL%DWW1^N5A40WKvc((B{YscILN6H0}L*9Jp<0M@g3DD$o3`#yyNmY*`FO0i@{Wqg)U?I zISxMugcD8&z)^yfiPu>(_!s;YUSQNUP#epxMV~&-j6#NeHUK|VVbnLk5u2uFMDNcxKJ8}T z5(d&9-Hh;c>c|ap3I51b28QTyRqZxjX4|#J!n09{kwj!(Q?rG6n+gz57Nl-%lv3+% zDpg5V`PM@4uik>ZbQa-;;2>p?o-O{Gx!NdZ+ce<`F7VHR+7kU5X#I&f2%G-9um8ty zykJoG4KM?;m~CYs81tH1@t*^&U-L>Dga6rRuT3#9DJfFEL08sj{&YNT4l*Yo7@b9q z#M5?hbs}D*R}kGdqedw=Q2*v32Rwb~dQ{o; z?ZLZwxtYwsEl}vo&eadjOsSCBQNeQH1}8tM;3RsM|4_S<|FY%a>pRATuiMmt%%b!@ zZv!jI!`4jeq6nS6GN`{~+#}p~Fg>ZpH$x8Q{=w%AQ~(ZWB0xb6kpDbE|K)Q!TbYB* znSZ6f+|7L*y=Wp%93QE5A?>rwEw1?C5{98Vx#mU9<=Rjw`*pLWi%6=)c~H>HoYNi@ zEG%+^821fmiWp&-ldkCEsqo?G)j9UTIie7QIZEN?SWSZM*Zuw5#J+-HuZ!{!B(WlK z>7hwQi8v*+~z&MsCtXUFbOEBDE2BS-#Hjfz@(b`!>fHN5vng;rzW`UOCW( zChG1d4m-hgYa6Vg#C6%TGhvmjs*DV)`Hu_RcMa9a7N{t)D8MGH!%e*xd8UBWB#<_N zgj7*JjZQEU`?45;R-V}UJ9YA>s>%2g$$`Xuc7H|IJvf%hgsiARu@~gQ1p#DyBE9$U z-)*&q-I?)BY(mOtxY>L^>oc(k6sPd^-n+9~<4YRnHBZ<>$%8h6M~zMA=6rbr6nGc1Nm;z=q)$|=0&w~C0pAK4xX`X09R1#rPe;`3@75z4+JZ??l4&J zYcxACcA_`pLkq(aXmUu{)RD9E`|}@~N=Cy=AUKnXtus0d(V%MCB&rlVf4ZRKSdkY$ zA?-}6tw(tkt0%TVN=+BQq)yietqY5CdR~;3$^W=ExIvcXb=(=>zp@1;(s;ilsJLCf zbY$p#-;Z~cx6<}>dZi>dS|}Ku%=I|WO(uAEliaR~4q(zhIj=d&d^ld792dI1*i+(P zXoewMJZ4o06>k_IXd1@W&hGbddS#$!LTtJ#y^8PbsgAC(4`pA@a<=xi$7RhM`qc)k zfuW!SP$0ZlRb_mHd!q-M)M@OkzB`G7+PJxgdyD+`<6!UCzUAKQDQ-8iB1ONDVfZhA zi{kzM9@ewx-NjwtIIMT)_V+;;wNm}01(}z|N zAU%$>VZ}qEdTVBfqFwpoJgtM}v5Kr(W1aF{E}dWo!Ur%B?<(B`J{?NsC`S}%fAJJf z6({et{>^I0(lW&@!MfjM##)-&ind@7)e}cz?r+j?<;weMb60cxC3*g|o_84eB z3dKD68cs0|G}csR!&I8O>T5W?zc8F!H)75R))~J3)@C5bsFuL2Jdg8+bn;Bbwcg7j z;S*Jz$)<2>MRX8%>JH*Fh1Wyp)ZC065~zk}&*B5qP=IDJtGgs6>v{Oh*_`T}qhp^( zG{$Lk9gs+<*nz3Vo9T9wZo0G~Ua2m8r5elABl`58UiJYdEQp)bUy5<3N?h6HeLEN1 zE*x&+5*}`g#GEm!z;ubm9K9eHU#pB{0W@O(7DxfQx(|Hnd-Qht(1oB}n93zYgQ?dd zI2I&kR(&EKg42#ese^kzc31VS^4)mj=Lw)_F8N@?r5ozXUndu7B^NB9h%c~q$#Tyk z0?LPh)_Vo6sws!i zPvyF>qSv#8v(I#I8VC?X+ydn-*x6KE=gKh;cJ?vx1vik7DkblyJ9XojDVC&8&QVEf z3K}CQdUGu_UOULr=o726+bc3G1%X1#2HL?0YKqO58VQ3rK;jyS$TRF-+A~x;X=l^- z9t+nUZ--`4pD(+vo#>NQ`QA-=KdO`qSjJj7TJV+SDk%u1w6%$St1jUYCn;sycvN_B3$m zrfeFar>TM?%${lVKo8_|4>e#4brm94n2$uWq=SMgVdx5*GVu%;8}hOebB#zBc>(EL zsrYi0VZ?2LEPybn>#a6JU9Mg0R8;O;7kmvspuqtq@vE1LB`U7QLID8O`k~5$(d(IM z@9MUK&unWlDQSS4YStzFWi8vWX>V7w=)PMEL17%}?N&+9R7Hbllxp)glEf~NN)4MU zqSmk36ZX#~1AV4!qDkR@O!;-&wUTiKm#gM293^*2N~EpWB&Qme&!D9(&#>$Z4h`dL zdq|RfX6|V1tFZNjT!a1R(T`SxGPO3uKp#QQ|Iz+1!(e9*pgH*0d5`Ae`$aAcZ}b>n z^6QFebH;uyYWNcgVLxibD!uH=TJb?~cT9R4K+!*S73A4nMthJ*l~IadwzUF z>*|lN-6V#T^<$=v&>_)8`5A`C4c047{JP+QI0qW*@bTJS`uau=+n=m4V~lrCygN}%`&y9nHbVN)L< z!79{PsxO7NSsOph`OF^&gRKjRDt``)+99uaX$?tKn)*J|^+Xf8p`r=kCx5C_@;r zTR~~IRTwkId1?_W+2gey7%hahi@Hu<#=tzCXERDFS>izN`_*kd3nAvIx-U>3}9YLQ&1~F39PIe$=Bv=?y4A!Hg zkjsQz?v$o|(aF6yhW%vLgM84p zByQdoN<)np3~ld)=4eq#%oftn8JE0|B{D1+9`CBWYrc`44(P!zCN?w{eQJ2$;K^*T zUw`M__B_|<3UtZ$(6_irsurWzI9E$-z#Hc%^v47JW9;ZR@Ap(v*(foR8}x!X5%ztRhG-di19vvu;c~gVa&e6< z;_!z<>K_HpCbi)=g$@KA6D8>N!=z zlx5{6Kt{iI;&#ieD-1TdnX1Z}`J=uu7{GxYlk`DI@Pnz4zAj;Gp5CHgHT$evN}!(F zAoflNYP7tQjoECda5jnTh&83TpWY4TPPgyA*ir3s3NMs*EGy;3r9O?toYPYrW!-xf zM@;XGp2l5tkhiYV{N-G}VX|Qss~~fhF3fOLRJx&T(oy-XlME1wUE;^=bg#zQ0@q@M z$#M!FKVb^a`M$zMzHG$2p~_0D?30Gm9M*Fe=E5cUFrSJhDK#R@*EjMId##Dc20YU( zG#pMr+}E^Djp_~T2xjz3n<4IPGke%$Yr}(21ctWaro(jhyz86B1Jh;dkjkyxnV$E# z6s>`T3N1l$%(gPQaRaFLSTnLUNIE?2UOrPyZ)$N0P)TY>Fb1-3Yy2=8$kpXLpK%UB+Lw|ipYqT}LxTak-oeb!p@vhp1G~gU zAHL!!M5V2)vAB0t`M#?%l>8}0Zu2`RYlE+)al7IhVqOK&Y5h!wH?3te_4UUlU;lU& zh^X|hgqg=_H575r8InMX=zisn;G`5C#1}>MRy*J^9~rAeo?9pe8KSVeb&W8N zq$BRtvVbZ1k=Psl$Q}iy=oxR}UIri@!QpAnp`dt*{A>cS{|;VCT)PNbO57cbm|$(6 z4blWevLsJ4Di3AX>&{rrF(%mep~s32WepHk#*u(_J(ZVXwWtebCKElyeBIHsI zur~Qc$owyd&K^!vPVMJjJe1FQ{o~bOkt)L%ZOE5*kj(`Xay4jXZ>sEM?*L{twRbZA zxyX<(nE&1gLX9Kl~v|#F*H2Y2P zwMpTDCII_{Y4B#;?eQtbtQvrFgjPEUNTI|E8h{-H#16ZJXX3Iy5qk8oF=(sENKcTW zrkZVAB55UP5t2F=2rm*xZcBevu28N0q^S~#wjw+zzl!tqg;pX{ii=ijU-*eu{WIcs zYlz84DMm?a&wi9^vqw_&4ovNpW}y>&-nok&exXl$JhIXFPhJW*cv>)vytpS zpAT^BHE3n`U@qI^`?xU^e5Q2l$i^4~HGX>SUPh02b6VmyZew)dsuS57xSF zqu38QtE9l8n~ln%SnMx>d=mp3=bz?1N?h3&Lzj&(GT9ZHL;Huo{HJ7NU-L5O)*f zuj***;P78fi7p(4p=RC`#iOsa)-B;)nmZRx-bQZTZ0bzsxz~+{XEXAA-PY%qlp4CFNeApKcTa%qC~GV z5l4vGPQDyXQSk!4L!+7LvfuE>&4O%A#D_04Mrt!9c@iPPqA#l-22Gn^^l}f(ZK&r4 znss8EUVu#5dYCL^-@a%QW3qWQa%4D0tgjq*Cka9F`A-V>EjFUTFPD>=siZ`uMK z$@Vei?8`WO-MRd@VSeGJdENyXWI_IL*Pvk- zA+Fg!2mk(i+5Y|hhfrW;xxWkedt~Cjfj{5*5N`Y>PVsl(@6lR+LI)wv<8QHBzk~lC zDe@;23Mw3O_y7Nn8~I(%@6iH(N*Y7`-%k8T?7;6*en0>HQ;I0wKb{8vF5ve+*FOae zlKv9#=YQ<)(BD1oKcVuJe?WitzkiqTyZiK~gih*T68`2){f_>-Vg3^f1yw)`1@#|h m`gi!>H`2etIT-!||JSyvEC&zKjh`W~C{S$>Pv8#lGxtA5&qu%j literal 0 HcmV?d00001 From dbc72008442d181ce405256ed7021c2a6aa6035e Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sun, 24 Nov 2019 20:49:02 +0100 Subject: [PATCH 15/25] Fixed tests --- QuestionsProperties.xlsx | Bin 11983 -> 12074 bytes .../jsonResults/jsoncollections.Designer.cs | 30 +++++++-------- .../jsonResults/jsoncollections.resx | 36 +++++++++--------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/QuestionsProperties.xlsx b/QuestionsProperties.xlsx index 9bd12de4a840ace6040d1cd9b728db2695816af2..5fca10c2a7a1e2f477d84d376d74360234d6e5e7 100644 GIT binary patch delta 4609 zcmaKwc{o&m`^N`^W{_8sL1o{U>`L~1$yS!JZxtp)mW&wt3}r9-7KUUH#+t}d zmW*x4lCl#X^<3ZI^IX5{`u)xy@9R4EdENKt-p(KAe6%gKtDc|&S?xD$WK#eD&geNR zHl(e0fgD3v+sG+(<(N5mS@=nIIS2Vy-5Jxdy&!ub(~B}))_7dEgvr?H{w2%{*wmP* zcW}W6)cv`GfdTg8MJIdnZax;LxSn!A>cT?TDK1G7^O^ABQN?gOr z!g{AYKc^^nI#!ttFkEkJqKiYp%LetVkm$Y4DmRK;7N}%$HDuqcg*6p|(0NlX++VYS zF9mrFKVe8{bl4h;UkYg7t}IUEQUO-P0*?^A;~TMNB=3l_xR8}`*P%5@6%os>MKqO$ zW=_xjeLASKrRt>OUZNdd`Uy|NJ)iCz{H}Xh_EKbH=(QxWuN>NK@jO$k-PD4}6?@Vg zLOb``3ZJp$bPZFxyd|Z4`5YzfR9j+V<{+6cdSCBTuE70-6%nf+b68km!`Cjzqm9?;c=uH+h(9xp;~KtbZ?(FtTz>QbQ;7 zG4FwNcK_ZUmqMd?PDr7F8+~djnXoa>z6ds0)t+E{}>fYZEz#lOU{cm+it$db*1GEa+P>Bu$2I+ z6F<9sc_HFm?PFh+>PSqkJzH z=KaP|F|;X{T~5^@h5`A&06DD_lI^BB&V4N`gjpZZeciKig?y@PS#H!hc95LzP7^W}nI(ZjCt*Eg~ zM1}lE8{p?52gt)#gzFK)U%^tm2VOzm%UPTm@F+dj0>pf-rwoL{`De6shOe<$UB_GMVdbXHyH{1FgoSp{N z#Rq$<{NzFuEb{ZgGlI(Y7F~FFB1!OrlTN=V)72ib(>mfyv~A4E$+~XKgTUCNpRhLo zf28EbHtx8>y^Nz=W)ydZdmz&I=z{VU+E=e?69RjG$z;F@*huHVJ29Ps58AZWT7I3a zy)~KT_#Uk$tAaXs2QES(UM~FxBIOe zwSr{1iqt*TQ13J53bgqOhkk2d6KJ-v*Z8;W#e$3p;3?SFS$5p+Z2ege%T>jI5~Snf zkQ~!@ltu?gHz;vEx{xlsdg7zlkXg~{L$B5^fNauMCN1BhNQT*uo~yGi=BM+zmY27l zQ`+53*X;812yB9hP%8V*Jt0b3Rdw#<1KEMO$?YDRK^-Y|2Afd2ckxQ9`4ZXVZdHE2 zRCz2K=Oh=(?6FC?9O}P=b(k#Y~EEYY_Sp z0X2{n#xNeh*6g>z?>#l=9-)6)rp1_g$TkJBCD}{yi?|up3qhI0>^ZEz)FbiI_9y<8 zKGGQ0bO|vLw+hH9QvxP!kjf_N!zu58no@E5?GDfQo$k=gX1pir8-s+NfL zp`|hI^oJ6g`I41wIa5ifKzRqqVZdmIT(q0(;DDM*`dihQ7!Sn}4iY_ChU;8cGa3?OVEJUK!!SUsuOHli* z)y?0LI%}yezFzaV5?B&cACi;~)xT9}z;prJu0yUvBaADYc2aLZ(*CqDlKXTUj!j6o z7_kfTRB=!z=VYAB#KVAlDh|fv7{*B~o)x&K?Vv}#P1zuL@3MWAdXs30_0?~PW9~{_ z#;Lw)$zFum42=g9#@&FO{f46Yr1Yh4t;bzwl&-qXv9@-dcLfMVBEewC&QXX-F+%!n z6E+e!&RYC8CnTQf}ZMZiG=&`BL|u_ZOr1xP||v9inU zko=sbP4q-~pC8mY>Bka5eHeS_v8rgXon|2DW$QfB3nyP=o_vCj0ZLt|z8-P=f~T&- zO>zwLWF(#&0)5 zpZEWalMY;_(Z}!)y}9tXFB>wztiU5?vRzGd8#KPyHd=+@GBQ)FdRkJ<2k_ZNDjH^s?P#6e-=a5GSz-Tgc#-{%R7t@mapIR!)%;hoA0aMcQ!X~mCV6-z z%8LR%+7WzUF5|hU%Cu(rDWy?|1P_hft_2S~G!q0@ zc<^Sx%0fY(;jTJ+%8ZR8CaOjsuXc ziOv?^e*+^KDl^ruTSR9ISE}b41|2N$Hna(~tUFu9`Qa9?!(_%rGVs%#eoI~u@5|Y= z=Ly_1M4dc-u5bNv6hS*1H(>j+4yNIRil4l^jC2si8vjTl4qCS!5O^m{fBF{LG!8Dx zWz&#S(NWxdqZ)U}w>44Hf^4!=`jYuLpF3Zk@33W!%jOCC%V$Ume#d5c*1LRpAZ&_w z@>&XhO}x>c-QJKiP?!hTQ@6I?4kgv{dSEE(Dp<&wGWF!JBM?li0GP{FcGd+boIL zEVUY!=y?IoRmS`yLY6RO$b49~M?Vkw3KxqtB56L?hsuHmT3&6zG;(el3!uvHaup3F zGK^{7A@`RLE>iOyfPk|T2!erL9|-ly==aCPiYnU_n0|FK=7maSFuO_h^YHTi+XsS%N(|D0!21X1`e@UL@at<@dI zG5PzIcV+%G6%x-U3^BKamz+2CrnvyN>b1WsxGR|@zHA*_{EzLGe`S`Ms=pn{W@*Qx zj}Q=eK0sFA^L75iD&n?_KjQ@RzY=uLhf--Gfcy({%Nl%P8DPtT`T2u)uH7Z!9{os^ z7UVFyc{rcTRV{EYhqshw4f|(rHxAQE#458IRQ(zKi`0hLvVt12JvfKVCCXjDb{BaC z4l<5?H1kJv9>&YvFGko{PKERVv-$qiKlQgKZk*=hQn~qv)A?3HQtjv&#l}K>U)sbDt;xIEi}V}K^{RvPASC4(l63pWo|P~K?Omh6~P;rT+_A3 zon946)oTaZaXW@gTZHKSnfJi9o-QqU{Ou#!C-(&lS&QgH89r=3 zl;U#(y}m_e_;7RC<)75l(@8UQSW&Vbs2_0&Q|~FoeVeq;b5!mDDLmml-T{Bq01-*8 zZ^2D(*uSG6OH`M-G|m6rgB2gzce^4LO^X}Kd-fU8oL8E5m8+h)z*GEgG6+hqjCdS#n7E1pkac+TV zvF#I!nIR3A(JOa((WXfy6qzYWEacIY=(e@BPAfiOA<1!l52t-UVz2alW^d0GIr=$l zdwSgV?i=0@x{ceR;X?6~_2I7<92JgVD9NHm?|xj}2oRco_-mK9VfLfC{p6CLE$tf> zZ|THrp;mj#isl^#t6k-)E*@m-){Z3fy?xQ5_i4(&ts3VeOOY&)UV4&(&Qt!;UYp?b ztgS`Gt2c?gl7EEdk1(ZVA-4*noM8%Cw?Fk}EN&hx>iOJy8XQ?*QMk8 z04l)wI03u>F#=bed0i7sf(%LHFN~nRvz$oL9@p9O0*h#u64Y^({zf2eb?Hx4n8D_4 zQ?_6J_l%lUvWb$|h+wiw|YPlM|n9`)NyO1>|WhGo@Ni@E49EYbE(+cHhO zh^Sfyu4i#j&`N>bGmU8&Hv@IYAo2=fKH$}Ok0L$y8B=c`jW5D803@oz=c!(GsxJ={ZG$a$-?K^0-DuCCF2IuDebA^%#mM2zQ2a;w3gV2lVa3d0AI8vD06ia3 zZt13)Xxp?=MY)CPe5sa0a+j`4oTQ`LlpWQ9{xo@ry5HC@+gI>HKUD3vfL)3q)9sXy zosrDLPv4%daQ77yA(?t~0ybVz%!6K(9IP)a+SkDaEhzr$cMD474%rLzj0l|Tf4=H8 z006f0#{cK~OpE?b%Yjyb3z3zeJ>V+jqCDsdxGY%>ngr+P`rj|#fBazA&_beDDF4n6 aZ79k@PR5UZAgV}~gf154qcRiuL;efbD5uN- delta 4491 zcmZ8lcQ{<#*4KtHqKh7h&O1SLqqiv02||cYl+i|sD930~Uu6(ol#%G7MD)=Tb&y1~ zh!LWTXwl7;-0$A!z2Es`KhIugwcl^8y`QsA#iKFnx+zlft_l`>Ixzu(H3~<{48Xlg zWN0qKK3tGd9YXt8ZhUgQp7x^plY%L{_6%+OJ=~-nl-HoAX1Wb@iAG7x)aZBoFfC7V z!R?BRk4?K2wzi5Dyh=%wrl&9D`uIW*OYvD=ccjZx3@S!hu4R%EFYRZqXyO`{b9p&8 zlbP`T`f4&MfrPJp<~=ywTxO8AJHTad5+jAPKp4@3barirlU|gj@S-bfJjjYLHRSFi zgq*ZH-MCH3;q{1BxE`BiIM|XFbl@~7<*Qz~e}tJ-mw&?sT|FedWmaXs(LyGfBx``Z z$tpZh5m6_%#g-p#Lx5-Q#wE%jH%HARhe6Lns`UwHIkdXsZgR6Nl`!}LUWlKHJY$Rp zaqFx5P|dY{HN_(;c1x>?Q$ssL37l2l~SIm)H#|{Wv?ffqLdh8o)Q|7j61lK5Ff(+ zw|oYMtTf86H@_eTLjCX&O#8P+j2C(yy={~a%(QsD`80EAhQ5q)>sI2zAoyZl?d( zL#4hS(*ETawzkTUR{*NP(JnTvX!6UD$YD!!7EJjfTW^F(I+xp}z#w&=hj{~M+ zdv_nrRy0moV)0oVsHYY<)D$q>bSYVP!e;~ADSv-0MNy1#O+1Xmmwjh+%Af zNU&tvq}IAqQKr~2mc@7yAyChiw!t@~?O#ppMM*OYX1HCk?MRs>y z{EUFH(YKu!w><9rbR+v6GwgMlmYhGQsZwMQODS3KW5(iXpkdtjC4c-4=$_U4oL~x< z^=HHVVuwwN2iMcjZ<6^eJRW?~?3&3-yP=VCPV3nRZPn*wk#(M@!W^Y|Y-kGlB8#6d zj_i3SR!LAQk0gv7s->KMcxL&xqyOAZxoScd_|<*jB>EmtcX*fa>#QsyZr}B?Vugh1;~UoR-DUV0O9lf`1f@SK+p%z23a20 zdaN6Ou^Kx&pS%d@uueA1Td%~UAG3Fb#VScNE315;^&cdcc@7E^z!?eRR z>&YeDF%Bjg5y?qrGb`dh`XAPXJ?@b>rrrd9QRUxgXW9#$DB&DF{a&=kj`k6mxpd!8 z>riR74e03GTyw}(;9YpXyK*QLxuAOVfYtv|*smo&P!Oecc?+SUONIxM;nHRX?hQn! zKGIN{K0HfpuyzL_7d)(qM-h3>y_CLY(8^>9oq&E+vK5S?FY`5~$=1hhO21^AQ#~?shqsXI>Sy+@iAMWKj=Ik7CR=wa++U@HC6Um; z$uL~am4ZTjcmD3rUdZSviMgmP;0g66YU6ajd4hYo?5-{7{6#_cRNiG#qfeQq8pd4+ z@XN?P^)W`0ce47iq8O#l?|^A@sBH5HZ(osPuW}c^jyrhcKuIg{vhHL#v9+ByLD

lBfcU=J-@ZX!1N=_m{b*yEn9I8iSBbOeTj+(X;82&2CzY#>P^_d+jy z@~r%EPs1jl)1wH=f5~O1f{Rj#Tkg$&a>2!=Ui4=bw2q^^oabnPJ(sFoT;`Io<{JC%;|Km{0 zH3rI=Q6VgoEYT+YbT}r4M2f3U6sZT^LSo8Dq`2!~NFnf6DkhVJ5mMz>1kE|O$c!WM zt7q-bj!?-&O4=l)`|WU{JSDmQA1D7c{zJ#TT0rA2{qQ8%z?hN_G#XSU@NiOi=>r-9 z`X%VCj8ucL8{x8u_!*9sktUElBU~O46T{n5j3JSZ4(Hc*Qk6KGd7es4o=XPTa4VIs zYyDs8%GHQ_Co6g$p}mNfJrMgCzQt?Evn=5SwwV(YL-z_{m6~DD9#_5e1Y(Pm$x46& zX-@|dy+r*Aj(!JpfL!A>ly=@I2$z0+LtLIxlv(@^lS7%K4zEDJXmR0gEcae`KKNA4=w&Z=`>i=3&dhj+skgWaq!8lr>L#PxzFyNc-nxT2tGA&3 zqe#A9q80lG>BN^D+#f%$hOkA7uoGt82_uw<^YoC~JO}3jlVll6tWnEOP8lh^E8Bp`selsuI!_R33So_Nq z9{$RVUdPsT6{7fXb)>Wis-tFZaX=QkkxzdmTz+1-mBgTvyQEX2q%`e6D#4zUP-2aa zy~dm^B@`V4-To47pKw8Fbuvje8jXlozH#Sw5RZ(2AF8IyIptguOjtp*?Z7}IHsi^{ zi!C)+;dY+*N2!`BxRp~AJHS~{h~T9fG+hr%h>F3NN3KIw8&i)~d++HzJ03ekg;%l}x?KRS=2(r#Tw1?HOoH6*m{i8Vc<8Oo!vdNh-A|B?OCt4)s}Q$NIJLm99xS8S^8I!1qkR(@wN>OibO zqW5QHUCIpQEsBnZ++cU_@8q?pE{43pW(zVHm&L$kOl0Ju)*Bb(<~k+0N{Zr#BQyi{3F3g1FQ4F1$+ z52Vz|nMaSlg{PQ0ccbflML@18_+hnE&1@$v{Kr`>g1vb zG5I54r?&O$MQGc6+s#LTkxJw1M{AM=n$M<26{|g#B;_SI6hBfIB8R#Rkn=8sa%V#6 zA69uHMN|dCo<`Q*id%GON@Dd3$>$l*KPNlK2;+@WZFu5_A|@0i`RY#<=o>-;f?SjW zFAFg2*>i{H?oq}mb>-K$RuuP(v`-jWFV7_ysgFHBW$xMo+*-12$b5(Q&@ zcKFL-Z8A9PgKJ`wR07(J^UcyCLvmACXi#U%)L)}|@)8%!YSl_=ALd36CtKmCzslY9 zjlRcZxy_I6pS-Rxo{KKhPS|C)zg&jr#W-UDua^!PSd+(8|#!)1vE20h~6MeD=%0 znRSZAK{+kP9#nJ6?I?cp-^=i_>%9UiE9^(PwcAmF5!^Olga2DZWPEY40C>|67yDbr z|9cDGA<@+LR-aROh{J$rFNNwTR8NQe z`OXKuG!`6x(7?biK?o##jDADRzyA)2>sz$e!oIQ3jp1p?^;$+8+m~&dLFspe2T#TV zFYzgk^-zi(%Em!xHWyvg0P!F+b=W_?fKeRJ8uU&~@PU!G)&$439LH4`a`SX^Rt`V3 z@*I2Os@4a?8so;-W=4sW3(AAKIED|`%`=3v{mnbx#qXNGAqCi@7s1bMvu!gMN!Kb1 zVyU#cgG*;Oib3GNi^AzjC9_CK0C%Ca59hPvW~4)6&B5QrZfsG_LJSeSsoIo% zwe&e=-{7Zj7=Bvg5HYhAPdr4|EjWeoKsU5ik18oO#sqo|HU_Lxcn$d(Ws^`lj^3ki z-ueOuG9us3;MHe>DgwmkV&`pX3dHr=V&4xTl*xx9GoV?nWd&mMGg@LyPX0 zbdgUeq?763c^(=0YL`?J?t%yCLiT*>MF{@PPWggr#Q*rsv3^^hB>rlOLe)T6QKmvP zZ2vn}5&Yx9qQZsl5~`x!2`Li|a-hJ%FhX6FsxUwMe~%iNfPm&71_T7%Jg8`4F7`il gygG}~L<9u1|D%BBL-h(P5K5p3MYu`NpugY!3uO3zdjJ3c diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index ea46ddb..c4b924e 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -61,7 +61,7 @@ internal jsoncollections() { } ///

- /// Looks up a localized string similar to {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"}],"name":"Page1"}]}. /// internal static string BooleanTestExtractedJson { get { @@ -70,7 +70,7 @@ internal static string BooleanTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":f [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"visible":true,"isRequired":false,"startWithNewLin [rest of string was truncated]";. /// internal static string Checkbox1TestExtractedJson { get { @@ -79,7 +79,7 @@ internal static string Checkbox1TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":false,"noneText":null,"type":"checkbox","title":"Choice 2 Title (desc) - All","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWi [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":false,"noneText":null,"type":"checkbox","title":"Choice 2 Title (desc) - All","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name [rest of string was truncated]";. /// internal static string Checkbox2TestExtractedJson { get { @@ -88,7 +88,7 @@ internal static string Checkbox2TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":f [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"visible":true,"isRequired":false,"startWithNewLin [rest of string was truncated]";. /// internal static string Checkbox3TestExtractedJson { get { @@ -97,7 +97,7 @@ internal static string Checkbox3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":false}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"visible":true,"isRequired":false,"startWithNewLine":false,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string CommentTestExtractedJson { get { @@ -106,7 +106,7 @@ internal static string CommentTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startW [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Dropdown1TestExtractedJson { get { @@ -115,7 +115,7 @@ internal static string Dropdown1TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isReq [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Dropdown2TestExtractedJson { get { @@ -124,7 +124,7 @@ internal static string Dropdown2TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"i [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Dropdown3TestExtractedJson { get { @@ -133,7 +133,7 @@ internal static string Dropdown3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"maxSize":250,"type":"file","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"maxSize":250,"type":"file","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string FileExtractedJson { get { @@ -142,7 +142,7 @@ internal static string FileExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string HtmlEditorTestExtractedJson { get { @@ -178,7 +178,7 @@ internal static string ImagePicker3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false, [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Radiogroup1TestExtractedJson { get { @@ -187,7 +187,7 @@ internal static string Radiogroup1TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 2 Title (desc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNew [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 2 Title (desc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Radiogroup2TestExtractedJson { get { @@ -196,7 +196,7 @@ internal static string Radiogroup2TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startW [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Radiogroup3TestExtractedJson { get { @@ -205,7 +205,7 @@ internal static string Radiogroup3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":"","name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6 [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":"","visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6 [rest of string was truncated]";. /// internal static string RatingTestExtractedJson { get { @@ -214,7 +214,7 @@ internal static string RatingTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"Document Id Card","inputType":"text","type":"text","title":"Put Here your DNI","description":null,"name":"DocumentId","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"Document Id Card","inputType":"text","type":"text","title":"Put Here your DNI","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"DocumentId"}],"name":"Page1"}]}. /// internal static string SingleInputTestExtractedJson { get { diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index c0eae56..2ca447c 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -118,58 +118,58 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":false,"noneText":null,"type":"checkbox","title":"Choice 2 Title (desc) - All","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":false,"noneText":null,"type":"checkbox","title":"Choice 2 Title (desc) - All","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Checkbox 3","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Checkbox 3"}]} - {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":false}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"visible":true,"isRequired":false,"startWithNewLine":false,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"maxSize":250,"type":"file","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"maxSize":250,"type":"file","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 2 Title (desc)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 2 Title (desc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"name":"ContactData","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":"","name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6","text":"Val 6"},{"value":"RTVal7","text":"Val 7"},{"value":"RTVal8","text":"Val 8"}],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with options","description":null,"name":"IsLegalPerson","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":"","visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6","text":"Val 6"},{"value":"RTVal7","text":"Val 7"},{"value":"RTVal8","text":"Val 8"}],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with options","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"}],"name":"Page1"}]} - {"pages":[{"elements":[{"placeHolder":"Document Id Card","inputType":"text","type":"text","title":"Put Here your DNI","description":null,"name":"DocumentId","visible":true,"isRequired":false,"startWithNewLine":true}],"name":"Page1","visible":true,"isRequired":false,"startWithNewLine":true}]} + {"pages":[{"elements":[{"placeHolder":"Document Id Card","inputType":"text","type":"text","title":"Put Here your DNI","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"DocumentId"}],"name":"Page1"}]} {"pages":[{"name":"Page1","elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","isRequired":false,"name":"DocumentId"}]}]} From 758b3c9f4c38c2a7b9594f638b1bb51021db7f50 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sun, 24 Nov 2019 22:25:47 +0100 Subject: [PATCH 16/25] Added Matrix single choice --- .../MatrixSingleChoiceQuestionBuilder.cs | 67 +++++++++++++ src/SurveyExtensions/Builders/PageBuilder.cs | 11 +++ .../Questions/MatrixSingleChoiceQuestion.cs | 18 ++++ test/SurveyExtensionsTests/JsonTests.cs | 96 ++++++++++++------- .../jsonResults/jsoncollections.Designer.cs | 9 ++ .../jsonResults/jsoncollections.resx | 3 + 6 files changed, 168 insertions(+), 36 deletions(-) create mode 100644 src/SurveyExtensions/Builders/MatrixSingleChoiceQuestionBuilder.cs create mode 100644 src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs diff --git a/src/SurveyExtensions/Builders/MatrixSingleChoiceQuestionBuilder.cs b/src/SurveyExtensions/Builders/MatrixSingleChoiceQuestionBuilder.cs new file mode 100644 index 0000000..5dc6c15 --- /dev/null +++ b/src/SurveyExtensions/Builders/MatrixSingleChoiceQuestionBuilder.cs @@ -0,0 +1,67 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.Questions; + using SurveyExtensions.Enums; + + public class MatrixSingleChoiceQuestionBuilder : + QuestionBuilderBase, + IBuilder where TEntity : new() + { + + public MatrixSingleChoiceQuestionBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public MatrixSingleChoiceQuestionBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public MatrixSingleChoiceQuestionBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public MatrixSingleChoiceQuestionBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public MatrixSingleChoiceQuestionBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public MatrixSingleChoiceQuestionBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public MatrixSingleChoiceQuestionBuilder SetIsAllRowRequired() + { + _item.IsAllRowRequired = true; + return this; + } + + public MatrixSingleChoiceQuestionBuilder AddColumn(string value, string text) + { + _item.Columns.Add(new Choice() { Value = value, Text = text }); + return this; + } + public MatrixSingleChoiceQuestionBuilder AddRow(string value, string text) + { + _item.Rows.Add(new Choice() { Value = value, Text = text }); + return this; + } + + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/PageBuilder.cs b/src/SurveyExtensions/Builders/PageBuilder.cs index 6d46f4d..f867fa5 100644 --- a/src/SurveyExtensions/Builders/PageBuilder.cs +++ b/src/SurveyExtensions/Builders/PageBuilder.cs @@ -181,6 +181,17 @@ public PageBuilder AddFile(Expression AddMAtrixSingleChoice(Expression> expression, Action> matrixSingleChoiceQuestionBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new MatrixSingleChoiceQuestionBuilder(); + matrixSingleChoiceQuestionBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs b/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs new file mode 100644 index 0000000..06a4270 --- /dev/null +++ b/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs @@ -0,0 +1,18 @@ +namespace SurveyExtensions.Elements.Questions +{ + using SurveyExtensions.Elements.ChoiceItems; + using System.Collections.Generic; + + public class MatrixSingleChoiceQuestion : SurveyQuestion + { + public MatrixSingleChoiceQuestion() + { + Type = "matrix"; + } + + public IList Columns { get; set; } = new List(); + public IList Rows { get; set; } = new List(); + + public bool IsAllRowRequired { get; set; } = false; + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 41f2ab0..186c850 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -21,8 +21,8 @@ public void SingleTextInputTest() ); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.SingleInputTestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.SingleInputTestExtractedJson); } [Fact] @@ -40,8 +40,8 @@ public void CommentTest() ); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.CommentTestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.CommentTestExtractedJson); } [Fact] @@ -65,8 +65,8 @@ public void RatingTests() ); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.RatingTestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.RatingTestExtractedJson); } [Fact] @@ -75,8 +75,8 @@ public void Checkbox1TestWithAllWithNoneSortedAscending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Checkbox1TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Checkbox1TestExtractedJson); } [Fact] @@ -85,8 +85,8 @@ public void Checkbox2TestWithAllSortedDescending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_CheckboxWithAllSortedDescending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Checkbox2TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Checkbox2TestExtractedJson); } [Fact] @@ -95,8 +95,8 @@ public void Checkbox3TestWithAllWithNoneSortedAscending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Checkbox 3"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Checkbox3TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Checkbox3TestExtractedJson); } [Fact] @@ -105,8 +105,8 @@ public void Radiogroup1TestAscending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_RadiogroupAscending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Radiogroup1TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Radiogroup1TestExtractedJson); } [Fact] @@ -115,8 +115,8 @@ public void Radiogroup2TestDescending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_RadiogroupDescending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Radiogroup2TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Radiogroup2TestExtractedJson); } [Fact] @@ -125,8 +125,8 @@ public void Radiogroup3TestRandom() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_RadiogroupRandom(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Radiogroup3TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Radiogroup3TestExtractedJson); } [Fact] @@ -135,8 +135,8 @@ public void Dromdowm1TestAscending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_RadiogroupRandom(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Dropdown1TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Dropdown1TestExtractedJson); } [Fact] @@ -145,8 +145,8 @@ public void Dromdowm2TestDescending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_DropdownDescending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Dropdown2TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Dropdown2TestExtractedJson); } [Fact] @@ -155,8 +155,8 @@ public void Dromdowm3TestRandom() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_DropdownRandom(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.Dropdown3TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.Dropdown3TestExtractedJson); } [Fact] @@ -165,8 +165,8 @@ public void ImagePicker1TestAscending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_ImagePickerAscending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.ImagePicker1TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.ImagePicker1TestExtractedJson); } [Fact] @@ -175,8 +175,8 @@ public void ImagePicker2TestDescending() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_ImagePickerDescending(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.ImagePicker2TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.ImagePicker2TestExtractedJson); } [Fact] @@ -185,8 +185,8 @@ public void ImagePicker3TestRandom() SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_ImagePickerRandom(companyBuilder, "Page1"); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.ImagePicker3TestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.ImagePicker3TestExtractedJson); } [Fact] @@ -200,8 +200,8 @@ public void BooleanTest() .HasLabelFalse("False") )); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.BooleanTestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.BooleanTestExtractedJson); } [Fact] @@ -213,8 +213,8 @@ public void HtmlEditornTest() l => l.HasHtml("

H1 content

Paragraph

") )); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.HtmlEditorTestExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.HtmlEditorTestExtractedJson); } [Fact] @@ -226,8 +226,32 @@ public void FileTest() l => l.HasMaxSize(250) )); var myBuildedElements = companyBuilder.Build(); - var jsonextracted = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - jsonextracted.Should().Be(jsoncollections.FileExtractedJson); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.FileExtractedJson); + } + + [Fact] + public void MAtrixSinglehiceTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + companyBuilder.AddPage("Page1", + p => p.AddMAtrixSingleChoice(c => c.ContactData, + m => m.HasTitle("MSC Title") + .HasDescription("MSC DEscription") + .AddColumn("0", "Bad") + .AddColumn("1", "Mid-Bad") + .AddColumn("2", "Mid") + .AddColumn("3", "Mid-Good") + .AddColumn("4", "Good") + .AddRow("R0", "Superman") + .AddRow("R1", "Batman") + .AddRow("R2", "Spiderman") + .AddRow("R3", "Jocker") + .SetIsAllRowRequired() + )); + var myBuildedElements = companyBuilder.Build(); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.MatrixSingleChoiceExtractedJson); } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index c4b924e..d230b4f 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -177,6 +177,15 @@ internal static string ImagePicker3TestExtractedJson { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"nam.... + /// + internal static string MatrixSingleChoiceExtractedJson { + get { + return ResourceManager.GetString("MatrixSingleChoiceExtractedJson", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index 2ca447c..a0aef86 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -156,6 +156,9 @@ {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + + {"pages":[{"elements":[{"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} From cfdcafcf040225734dc78e5ffefe514246809ec7 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sun, 24 Nov 2019 23:08:18 +0100 Subject: [PATCH 17/25] Added MAtrix Mutiple value --- .../MatrixMultipleChoiceQuestionBuilder.cs | 96 +++++++++++++++++++ src/SurveyExtensions/Builders/PageBuilder.cs | 13 ++- .../ChoiceItems/MatrixMultipleChoiceChoice.cs | 8 ++ .../Questions/MatrixMultipleChoiceQuestion.cs | 21 ++++ src/SurveyExtensions/Enums/CellTypesEnum.cs | 12 +++ test/SurveyExtensionsTests/JsonTests.cs | 33 ++++++- .../jsonResults/jsoncollections.Designer.cs | 9 ++ .../jsonResults/jsoncollections.resx | 3 + 8 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs create mode 100644 src/SurveyExtensions/Elements/ChoiceItems/MatrixMultipleChoiceChoice.cs create mode 100644 src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs create mode 100644 src/SurveyExtensions/Enums/CellTypesEnum.cs diff --git a/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs b/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs new file mode 100644 index 0000000..67f2e5c --- /dev/null +++ b/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs @@ -0,0 +1,96 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.Questions; + using SurveyExtensions.Enums; + + public class MatrixMultipleChoiceQuestionBuilder : + QuestionBuilderBase, + IBuilder where TEntity : new() + { + + public MatrixMultipleChoiceQuestionBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public MatrixMultipleChoiceQuestionBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public MatrixMultipleChoiceQuestionBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public MatrixMultipleChoiceQuestionBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public MatrixMultipleChoiceQuestionBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public MatrixMultipleChoiceQuestionBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public MatrixMultipleChoiceQuestionBuilder SetIsAllRowRequired() + { + _item.IsAllRowRequired = true; + return this; + } + + public MatrixMultipleChoiceQuestionBuilder HasTotalText(string value) + { + _item.TotalText= value; + return this; + } + + public MatrixMultipleChoiceQuestionBuilder HasCellType(CellTypesEnum cellType) + { + string enumName = Enum.GetName(typeof(CellTypesEnum), cellType); + if (enumName != null) _item.CellType = enumName.ToLowerInvariant(); + return this; + } + + public MatrixMultipleChoiceQuestionBuilder AddColumn(string value, string text, CellTypesEnum cellType) + { + string ct = null; + string enumName = Enum.GetName(typeof(CellTypesEnum), cellType); + if (enumName != null) ct = enumName.ToLowerInvariant(); + _item.Columns.Add(new MatrixMultipleChoiceChoice() { Value = value, Text = text, CellType = ct }); + return this; + } + + public MatrixMultipleChoiceQuestionBuilder AddColumn(string value, string text) + { + string ct = null; + _item.Columns.Add(new MatrixMultipleChoiceChoice() { Value = value, Text = text, CellType = ct }); + return this; + } + + public MatrixMultipleChoiceQuestionBuilder AddRow(string value, string text) + { + _item.Rows.Add(new Choice() { Value = value, Text = text }); + return this; + } + + public MatrixMultipleChoiceQuestionBuilder AddChoice(string value, string text) + { + _item.Choices.Add(new Choice() { Value = value, Text = text }); + return this; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/PageBuilder.cs b/src/SurveyExtensions/Builders/PageBuilder.cs index f867fa5..a6d9e5c 100644 --- a/src/SurveyExtensions/Builders/PageBuilder.cs +++ b/src/SurveyExtensions/Builders/PageBuilder.cs @@ -181,7 +181,7 @@ public PageBuilder AddFile(Expression AddMAtrixSingleChoice(Expression> expression, Action> matrixSingleChoiceQuestionBuilder) + public PageBuilder AddMatrixSingleChoice(Expression> expression, Action> matrixSingleChoiceQuestionBuilder) { TEntity mEntity = new TEntity(); var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); @@ -192,6 +192,17 @@ public PageBuilder AddMAtrixSingleChoice(Expression AddMatrixMutipleChoice(Expression> expression, Action> matrixMutipleChoiceQuestionBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new MatrixMultipleChoiceQuestionBuilder(); + matrixMutipleChoiceQuestionBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Elements/ChoiceItems/MatrixMultipleChoiceChoice.cs b/src/SurveyExtensions/Elements/ChoiceItems/MatrixMultipleChoiceChoice.cs new file mode 100644 index 0000000..a82593d --- /dev/null +++ b/src/SurveyExtensions/Elements/ChoiceItems/MatrixMultipleChoiceChoice.cs @@ -0,0 +1,8 @@ +namespace SurveyExtensions.Elements.ChoiceItems +{ + public class MatrixMultipleChoiceChoice : Choice + { + + public string CellType { get; set; } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs b/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs new file mode 100644 index 0000000..ff51363 --- /dev/null +++ b/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs @@ -0,0 +1,21 @@ +namespace SurveyExtensions.Elements.Questions +{ + using SurveyExtensions.Elements.ChoiceItems; + using System.Collections.Generic; + + public class MatrixMultipleChoiceQuestion : SurveyQuestion + { + public MatrixMultipleChoiceQuestion() + { + Type = "matrixdropdown"; + } + public string CellType { get; set; } + public string TotalText { get; set; } + + public IList Columns { get; set; } = new List(); + public IList Rows { get; set; } = new List(); + public IList Choices { get; set; } = new List(); + + public bool IsAllRowRequired { get; set; } = false; + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Enums/CellTypesEnum.cs b/src/SurveyExtensions/Enums/CellTypesEnum.cs new file mode 100644 index 0000000..3e9dc91 --- /dev/null +++ b/src/SurveyExtensions/Enums/CellTypesEnum.cs @@ -0,0 +1,12 @@ +namespace SurveyExtensions.Enums +{ + public enum CellTypesEnum + { + Dropdown, + Checkbox, + Radiogroup, + Text, + Comment, + Boolean + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 186c850..9eec5f3 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -231,11 +231,11 @@ public void FileTest() } [Fact] - public void MAtrixSinglehiceTest() + public void MatrixSingleChoiceTest() { SurveyBuilder companyBuilder = new SurveyBuilder(); companyBuilder.AddPage("Page1", - p => p.AddMAtrixSingleChoice(c => c.ContactData, + p => p.AddMatrixSingleChoice(c => c.ContactData, m => m.HasTitle("MSC Title") .HasDescription("MSC DEscription") .AddColumn("0", "Bad") @@ -253,5 +253,34 @@ public void MAtrixSinglehiceTest() var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); extractedJson.Should().Be(jsoncollections.MatrixSingleChoiceExtractedJson); } + + [Fact] + public void MatrixMultipleChoiceTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + companyBuilder.AddPage("Page1", + p => p.AddMatrixMutipleChoice(c => c.ContactData, + m => m.HasTitle("MSC Title") + .HasDescription("MSC DEscription") + .AddColumn("0", "Bad") + .AddColumn("1", "Mid-Bad", CellTypesEnum.Boolean) + .AddColumn("2", "Mid", CellTypesEnum.Checkbox) + .AddColumn("3", "Mid-Good", CellTypesEnum.Comment) + .AddColumn("4", "Good", CellTypesEnum.Dropdown) + .AddColumn("5", "Excellent", CellTypesEnum.Radiogroup) + .AddColumn("6", "SuperPower", CellTypesEnum.Text) + .AddRow("R0", "Superman") + .AddRow("R1", "Batman") + .AddRow("R2", "Spiderman") + .AddRow("R3", "Jocker") + .AddChoice("C1", "Choice 1") + .AddChoice("C2", "Chice 2") + .HasCellType(CellTypesEnum.Dropdown) + .SetIsAllRowRequired() + )); + var myBuildedElements = companyBuilder.Build(); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.MatrixMultipleChoiceExtractedJson); + } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index d230b4f..70a8605 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -177,6 +177,15 @@ internal static string ImagePicker3TestExtractedJson { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"cellType":"dropdown","totalText":null,"columns":[{"cellType":null,"value":"0","text":"Bad"},{"cellType":"boolean","value":"1","text":"Mid-Bad"},{"cellType":"checkbox","value":"2","text":"Mid"},{"cellType":"comment","value":"3","text":"Mid-Good"},{"cellType":"dropdown","value":"4","text":"Good"},{"cellType":"radiogroup","value":"5","text":"Excellent"},{"cellType":"text","value":"6","text":"SuperPower"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1&q.... + /// + internal static string MatrixMultipleChoiceExtractedJson { + get { + return ResourceManager.GetString("MatrixMultipleChoiceExtractedJson", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"elements":[{"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"nam.... /// diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index a0aef86..9b81ce0 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -156,6 +156,9 @@ {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + + {"pages":[{"elements":[{"cellType":"dropdown","totalText":null,"columns":[{"cellType":null,"value":"0","text":"Bad"},{"cellType":"boolean","value":"1","text":"Mid-Bad"},{"cellType":"checkbox","value":"2","text":"Mid"},{"cellType":"comment","value":"3","text":"Mid-Good"},{"cellType":"dropdown","value":"4","text":"Good"},{"cellType":"radiogroup","value":"5","text":"Excellent"},{"cellType":"text","value":"6","text":"SuperPower"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"choices":[{"value":"C1","text":"Choice 1"},{"value":"C2","text":"Chice 2"}],"isAllRowRequired":true,"type":"matrixdropdown","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} From 6fc38c3766d25e8571d4f17d581dd0f2af7b445a Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sun, 24 Nov 2019 23:27:58 +0100 Subject: [PATCH 18/25] Added Multiple text question --- .../Builders/MultipleTextQuestionBuilder.cs | 60 +++++++++++++++++++ src/SurveyExtensions/Builders/PageBuilder.cs | 11 ++++ .../Elements/ChoiceItems/MultiTextItem.cs | 7 +++ .../Questions/MultipleTextQuestion.cs | 17 ++++++ test/SurveyExtensionsTests/JsonTests.cs | 17 ++++++ .../jsonResults/jsoncollections.Designer.cs | 9 +++ .../jsonResults/jsoncollections.resx | 3 + 7 files changed, 124 insertions(+) create mode 100644 src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs create mode 100644 src/SurveyExtensions/Elements/ChoiceItems/MultiTextItem.cs create mode 100644 src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs diff --git a/src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs b/src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs new file mode 100644 index 0000000..b469d1e --- /dev/null +++ b/src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs @@ -0,0 +1,60 @@ +namespace SurveyExtensions.Builders +{ + using System; + using Elements; + using SurveyExtensions.Elements.Questions; + using SurveyExtensions.Enums; + + public class MultipleTextQuestionBuilder : + QuestionBuilderBase, + IBuilder where TEntity : new() + { + public MultipleTextQuestionBuilder HasName(string value) + { + _item.Name = value; + return this; + } + public MultipleTextQuestionBuilder HasTitle(string value) + { + _item.Title = value; + return this; + } + + public MultipleTextQuestionBuilder HasDescription(string value) + { + _item.Description = value; + return this; + } + + public MultipleTextQuestionBuilder IsRequired() + { + _item.IsRequired = true; + return this; + } + + public MultipleTextQuestionBuilder IsHidden() + { + _item.Visible = false; + return this; + } + + public MultipleTextQuestionBuilder ContinueInSameLine() + { + _item.StartWithNewLine = false; + return this; + } + + public MultipleTextQuestionBuilder HasColumnCount(int value) + { + _item.ColCount = value; + return this; + } + + + public MultipleTextQuestionBuilder AddItem(string text) + { + _item.Items.Add(new Elements.ChoiceItems.MultiTextItem() { Name = text }); + return this; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/PageBuilder.cs b/src/SurveyExtensions/Builders/PageBuilder.cs index a6d9e5c..cead4eb 100644 --- a/src/SurveyExtensions/Builders/PageBuilder.cs +++ b/src/SurveyExtensions/Builders/PageBuilder.cs @@ -203,6 +203,17 @@ public PageBuilder AddMatrixMutipleChoice(Expression AddMultipleText(Expression> expression, Action> multipleTextQuestionBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new MultipleTextQuestionBuilder(); + multipleTextQuestionBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Elements/ChoiceItems/MultiTextItem.cs b/src/SurveyExtensions/Elements/ChoiceItems/MultiTextItem.cs new file mode 100644 index 0000000..f148c41 --- /dev/null +++ b/src/SurveyExtensions/Elements/ChoiceItems/MultiTextItem.cs @@ -0,0 +1,7 @@ +namespace SurveyExtensions.Elements.ChoiceItems +{ + public class MultiTextItem + { + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs b/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs new file mode 100644 index 0000000..82f838e --- /dev/null +++ b/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs @@ -0,0 +1,17 @@ +namespace SurveyExtensions.Elements.Questions +{ + using SurveyExtensions.Elements.ChoiceItems; + using System.Collections.Generic; + + public class MultipleTextQuestion : SurveyQuestion + { + public MultipleTextQuestion() + { + Type = "multipletext"; + } + + public int ColCount { get; set; } = 1; + + public IList Items { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 9eec5f3..e5e444d 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -282,5 +282,22 @@ public void MatrixMultipleChoiceTest() var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); extractedJson.Should().Be(jsoncollections.MatrixMultipleChoiceExtractedJson); } + + [Fact] + public void MultipleText() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + companyBuilder.AddPage("Page1", + p => p.AddMultipleText(c => c.ContactData, + l => l.AddItem("Item 1 text") + .AddItem("Item 2 text") + .AddItem("Item 3 text") + .AddItem("Item 4 text") + .HasColumnCount(2) + )); + var myBuildedElements = companyBuilder.Build(); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.MultipleTextTestExtractedJson); + } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index 70a8605..d902d38 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -195,6 +195,15 @@ internal static string MatrixSingleChoiceExtractedJson { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"colCount":2,"items":[{"name":"Item 1 text"},{"name":"Item 2 text"},{"name":"Item 3 text"},{"name":"Item 4 text"}],"type":"multipletext","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// + internal static string MultipleTextTestExtractedJson { + get { + return ResourceManager.GetString("MultipleTextTestExtractedJson", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index 9b81ce0..c022860 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -162,6 +162,9 @@ {"pages":[{"elements":[{"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + + {"pages":[{"elements":[{"colCount":2,"items":[{"name":"Item 1 text"},{"name":"Item 2 text"},{"name":"Item 3 text"},{"name":"Item 4 text"}],"type":"multipletext","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} From 96bd4eb20402098b25b5d77836ff21730638767d Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sun, 24 Nov 2019 23:46:53 +0100 Subject: [PATCH 19/25] Rreamed namespace ChoiceItems to QuestionElements --- src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs | 2 +- src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs | 2 +- src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs | 2 +- .../Builders/MatrixMultipleChoiceQuestionBuilder.cs | 2 +- .../Builders/MatrixSingleChoiceQuestionBuilder.cs | 2 +- src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs | 2 +- src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs | 2 +- src/SurveyExtensions/Builders/RatingQuestionBuilder.cs | 2 +- .../Elements/{ChoiceItems => QuestionElements}/Choice.cs | 2 +- .../{ChoiceItems => QuestionElements}/ImagePickerChoice.cs | 2 +- .../MatrixMultipleChoiceChoice.cs | 2 +- .../Elements/{ChoiceItems => QuestionElements}/MultiTextItem.cs | 2 +- src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs | 2 +- .../Elements/Questions/MatrixMultipleChoiceQuestion.cs | 2 +- .../Elements/Questions/MatrixSingleChoiceQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/RatingQuestion.cs | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) rename src/SurveyExtensions/Elements/{ChoiceItems => QuestionElements}/Choice.cs (69%) rename src/SurveyExtensions/Elements/{ChoiceItems => QuestionElements}/ImagePickerChoice.cs (66%) rename src/SurveyExtensions/Elements/{ChoiceItems => QuestionElements}/MatrixMultipleChoiceChoice.cs (68%) rename src/SurveyExtensions/Elements/{ChoiceItems => QuestionElements}/MultiTextItem.cs (60%) diff --git a/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs b/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs index d8aafbc..0879e3f 100644 --- a/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs @@ -2,7 +2,7 @@ { using System; using Elements; - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using SurveyExtensions.Elements.Questions; using SurveyExtensions.Enums; diff --git a/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs b/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs index ca20882..13e7bca 100644 --- a/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs @@ -2,7 +2,7 @@ { using System; using Elements; - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using SurveyExtensions.Elements.Questions; using SurveyExtensions.Enums; diff --git a/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs b/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs index e6cc61b..3e6fba7 100644 --- a/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs @@ -2,7 +2,7 @@ { using System; using Elements; - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using SurveyExtensions.Elements.Questions; using SurveyExtensions.Enums; diff --git a/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs b/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs index 67f2e5c..7c90e35 100644 --- a/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs @@ -2,7 +2,7 @@ { using System; using Elements; - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using SurveyExtensions.Elements.Questions; using SurveyExtensions.Enums; diff --git a/src/SurveyExtensions/Builders/MatrixSingleChoiceQuestionBuilder.cs b/src/SurveyExtensions/Builders/MatrixSingleChoiceQuestionBuilder.cs index 5dc6c15..733c8af 100644 --- a/src/SurveyExtensions/Builders/MatrixSingleChoiceQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/MatrixSingleChoiceQuestionBuilder.cs @@ -2,7 +2,7 @@ { using System; using Elements; - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using SurveyExtensions.Elements.Questions; using SurveyExtensions.Enums; diff --git a/src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs b/src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs index b469d1e..050e39b 100644 --- a/src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/MultipleTextQuestionBuilder.cs @@ -53,7 +53,7 @@ public MultipleTextQuestionBuilder HasColumnCount(int value) public MultipleTextQuestionBuilder AddItem(string text) { - _item.Items.Add(new Elements.ChoiceItems.MultiTextItem() { Name = text }); + _item.Items.Add(new Elements.QuestionElements.MultiTextItem() { Name = text }); return this; } } diff --git a/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs b/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs index 4cd765c..8cef3cc 100644 --- a/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs @@ -2,7 +2,7 @@ { using System; using Elements; - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using SurveyExtensions.Elements.Questions; using SurveyExtensions.Enums; diff --git a/src/SurveyExtensions/Builders/RatingQuestionBuilder.cs b/src/SurveyExtensions/Builders/RatingQuestionBuilder.cs index 3fe294c..257ea88 100644 --- a/src/SurveyExtensions/Builders/RatingQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/RatingQuestionBuilder.cs @@ -1,7 +1,7 @@ namespace SurveyExtensions.Builders { using Elements; - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using SurveyExtensions.Elements.Questions; public class RatingQuestionBuilder : diff --git a/src/SurveyExtensions/Elements/ChoiceItems/Choice.cs b/src/SurveyExtensions/Elements/QuestionElements/Choice.cs similarity index 69% rename from src/SurveyExtensions/Elements/ChoiceItems/Choice.cs rename to src/SurveyExtensions/Elements/QuestionElements/Choice.cs index b4a265d..840c57e 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/Choice.cs +++ b/src/SurveyExtensions/Elements/QuestionElements/Choice.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements.ChoiceItems +namespace SurveyExtensions.Elements.QuestionElements { public class Choice { diff --git a/src/SurveyExtensions/Elements/ChoiceItems/ImagePickerChoice.cs b/src/SurveyExtensions/Elements/QuestionElements/ImagePickerChoice.cs similarity index 66% rename from src/SurveyExtensions/Elements/ChoiceItems/ImagePickerChoice.cs rename to src/SurveyExtensions/Elements/QuestionElements/ImagePickerChoice.cs index 3b0b080..87f0997 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/ImagePickerChoice.cs +++ b/src/SurveyExtensions/Elements/QuestionElements/ImagePickerChoice.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements.ChoiceItems +namespace SurveyExtensions.Elements.QuestionElements { public class ImagePickerChoice : Choice { diff --git a/src/SurveyExtensions/Elements/ChoiceItems/MatrixMultipleChoiceChoice.cs b/src/SurveyExtensions/Elements/QuestionElements/MatrixMultipleChoiceChoice.cs similarity index 68% rename from src/SurveyExtensions/Elements/ChoiceItems/MatrixMultipleChoiceChoice.cs rename to src/SurveyExtensions/Elements/QuestionElements/MatrixMultipleChoiceChoice.cs index a82593d..bd59047 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/MatrixMultipleChoiceChoice.cs +++ b/src/SurveyExtensions/Elements/QuestionElements/MatrixMultipleChoiceChoice.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements.ChoiceItems +namespace SurveyExtensions.Elements.QuestionElements { public class MatrixMultipleChoiceChoice : Choice { diff --git a/src/SurveyExtensions/Elements/ChoiceItems/MultiTextItem.cs b/src/SurveyExtensions/Elements/QuestionElements/MultiTextItem.cs similarity index 60% rename from src/SurveyExtensions/Elements/ChoiceItems/MultiTextItem.cs rename to src/SurveyExtensions/Elements/QuestionElements/MultiTextItem.cs index f148c41..daf16e6 100644 --- a/src/SurveyExtensions/Elements/ChoiceItems/MultiTextItem.cs +++ b/src/SurveyExtensions/Elements/QuestionElements/MultiTextItem.cs @@ -1,4 +1,4 @@ -namespace SurveyExtensions.Elements.ChoiceItems +namespace SurveyExtensions.Elements.QuestionElements { public class MultiTextItem { diff --git a/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs b/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs index 16cf7fd..5772b3e 100644 --- a/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; public class CheckboxQuestion : SurveyQuestion diff --git a/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs b/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs index 0c9f6f6..5a119f5 100644 --- a/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; public class DropdownIQuestion : SurveyQuestion diff --git a/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs b/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs index 10cb593..b556afc 100644 --- a/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; public class ImagePickerQuestion : SurveyQuestion diff --git a/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs b/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs index ff51363..7be9d4e 100644 --- a/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; public class MatrixMultipleChoiceQuestion : SurveyQuestion diff --git a/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs b/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs index 06a4270..cb064b0 100644 --- a/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; public class MatrixSingleChoiceQuestion : SurveyQuestion diff --git a/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs b/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs index 82f838e..2d7836e 100644 --- a/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; public class MultipleTextQuestion : SurveyQuestion diff --git a/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs b/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs index 084b188..3386caf 100644 --- a/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; public class RadiogroupQuestion : SurveyQuestion diff --git a/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs b/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs index 87c1be8..743622f 100644 --- a/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - using SurveyExtensions.Elements.ChoiceItems; + using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; public class RatingQuestion : SurveyQuestion From d8295dff9703878e8f61289dd21e183a68625e08 Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Sun, 24 Nov 2019 23:49:00 +0100 Subject: [PATCH 20/25] Removed page add item methods having extra parameters --- src/SurveyExtensions/Builders/PageBuilder.cs | 53 -------------------- 1 file changed, 53 deletions(-) diff --git a/src/SurveyExtensions/Builders/PageBuilder.cs b/src/SurveyExtensions/Builders/PageBuilder.cs index cead4eb..f7d723c 100644 --- a/src/SurveyExtensions/Builders/PageBuilder.cs +++ b/src/SurveyExtensions/Builders/PageBuilder.cs @@ -29,14 +29,6 @@ public PageBuilder AddSingleInputQuestion(Expression AddSingleInputQuestion(Expression> expression, string title, string placeholder, SingleInputTypesEnum inputType) - { - return AddSingleInputQuestion(expression, - x => x.HasTitle(title) - .HasPlaceHolder(placeholder) - .SetInputType(inputType)); - } - public PageBuilder AddCommentInput(Expression> expression, Action> commentBuilder) { TEntity mEntity = new TEntity(); @@ -48,14 +40,6 @@ public PageBuilder AddCommentInput(Expression AddCommentInput(Expression> expression, string title, string placeholder, int rows) - { - return AddCommentInput(expression, - x => x.HasTitle(title) - .HasPlaceHolder(placeholder) - .HasRows(7)); - } - public PageBuilder AddCheckboxInput(Expression> expression, Action> checkboxBuilder) { TEntity mEntity = new TEntity(); @@ -67,11 +51,6 @@ public PageBuilder AddCheckboxInput(Expression AddCheckboxInput(Expression> expression, string title) - { - return AddCheckboxInput(expression, x => x.HasTitle(title)); - } - public PageBuilder AddRadiogroup(Expression> expression, Action> radiogroupBuilder) { TEntity mEntity = new TEntity(); @@ -83,11 +62,6 @@ public PageBuilder AddRadiogroup(Expression AddRadiogroup(Expression> expression, string title) - { - return AddRadiogroup(expression, x => x.HasTitle(title)); - } - public PageBuilder AddDropdown(Expression> expression, Action> dropDownBuilder) { TEntity mEntity = new TEntity(); @@ -99,11 +73,6 @@ public PageBuilder AddDropdown(Expression AddDropdown(Expression> expression, string title) - { - return AddRadiogroup(expression, x => x.HasTitle(title)); - } - public PageBuilder AddRating(Expression> expression, Action> ratingBuilder) { TEntity mEntity = new TEntity(); @@ -115,17 +84,6 @@ public PageBuilder AddRating(Expression AddRating(Expression> expression, - string title, string description, int rateMin, int rateMax, int rateStep) - { - return AddRating(expression, - x => x.HasTitle(title) - .HasDescription(description) - .HasRateMin(rateMin) - .HasRateMax(rateMax) - .HasRateStep(rateStep)); - } - public PageBuilder AddImagePickerInput(Expression> expression, Action> imagePickerBuilder) { TEntity mEntity = new TEntity(); @@ -137,11 +95,6 @@ public PageBuilder AddImagePickerInput(Expression AddImagePickerInput(Expression> expression, string title) - { - return AddImagePickerInput(expression, x => x.HasTitle(title)); - } - public PageBuilder AddBooleanInput(Expression> expression, Action> booleanBuilder) { TEntity mEntity = new TEntity(); @@ -153,12 +106,6 @@ public PageBuilder AddBooleanInput(Expression AddBooleanInput(Expression> expression, string title, string abel, string labelTrue, string labelNo) - { - return AddImagePickerInput(expression, x => x.HasTitle(title)); - } - - public PageBuilder AddHtmlEditor(Expression> expression, Action> htmlEditorBuilder) { TEntity mEntity = new TEntity(); From d4e59be9f33a2ee70d3b54218a34f2c4d1ea4c2c Mon Sep 17 00:00:00 2001 From: "carlos.gutierrez@sage.com" Date: Mon, 25 Nov 2019 09:11:48 +0100 Subject: [PATCH 21/25] Added panel element and builder --- src/SurveyExtensions/Builders/PageBuilder.cs | 10 + src/SurveyExtensions/Builders/PanelBuilder.cs | 174 ++++++++++++++++++ src/SurveyExtensions/Elements/SurveyPanel.cs | 10 + .../GeneralBuilderTests.cs | 5 +- test/SurveyExtensionsTests/JsonTests.cs | 27 ++- .../jsonResults/jsoncollections.Designer.cs | 13 +- .../jsonResults/jsoncollections.resx | 7 +- 7 files changed, 238 insertions(+), 8 deletions(-) create mode 100644 src/SurveyExtensions/Builders/PanelBuilder.cs create mode 100644 src/SurveyExtensions/Elements/SurveyPanel.cs diff --git a/src/SurveyExtensions/Builders/PageBuilder.cs b/src/SurveyExtensions/Builders/PageBuilder.cs index f7d723c..c49546b 100644 --- a/src/SurveyExtensions/Builders/PageBuilder.cs +++ b/src/SurveyExtensions/Builders/PageBuilder.cs @@ -161,6 +161,16 @@ public PageBuilder AddMultipleText(Expression AddPanel(string name,Action> panelBuilder) + { + var builder = new PanelBuilder(); + panelBuilder.Invoke(builder); + builder.HasName(name); + elementsBuilder.Add(builder); + return this; + } + + public SurveyPage Build() { foreach (var surveyItemBuilder in elementsBuilder) diff --git a/src/SurveyExtensions/Builders/PanelBuilder.cs b/src/SurveyExtensions/Builders/PanelBuilder.cs new file mode 100644 index 0000000..4f4c4f1 --- /dev/null +++ b/src/SurveyExtensions/Builders/PanelBuilder.cs @@ -0,0 +1,174 @@ +namespace SurveyExtensions.Builders +{ + using System; + using System.Collections.Generic; + using System.Linq.Expressions; + using Elements; + using Helpers; + using SurveyExtensions.Enums; + + public class PanelBuilder: + IBuilder where TEntity : new() + { + private SurveyPanel _item = new SurveyPanel(); + private List> elementsBuilder = new List>(); + + public PanelBuilder HasName(string name) + { + _item.Name = name; + return this; + } + + public PanelBuilder AddSingleInputQuestion(Expression> expression, Action> inputBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new SimgleItemQuestionBuilder(); + inputBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddCommentInput(Expression> expression, Action> commentBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new CommentQuestionBuilder(); + commentBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddCheckboxInput(Expression> expression, Action> checkboxBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new CheckboxQuestionBuilder(); + checkboxBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddRadiogroup(Expression> expression, Action> radiogroupBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new RadiogroupQuestionBuilder(); + radiogroupBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddDropdown(Expression> expression, Action> dropDownBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new DropdownQuestionBuilder(); + dropDownBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddRating(Expression> expression, Action> ratingBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new RatingQuestionBuilder(); + ratingBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddImagePickerInput(Expression> expression, Action> imagePickerBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new ImagePickerQuestionBuilder(); + imagePickerBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddBooleanInput(Expression> expression, Action> booleanBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new BooleanQuestionBuilder(); + booleanBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddHtmlEditor(Expression> expression, Action> htmlEditorBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new HtmlEditorQuestionBuilder(); + htmlEditorBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddFile(Expression> expression, Action> fileBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new FileQuestionBuilder(); + fileBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddMatrixSingleChoice(Expression> expression, Action> matrixSingleChoiceQuestionBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new MatrixSingleChoiceQuestionBuilder(); + matrixSingleChoiceQuestionBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddMatrixMutipleChoice(Expression> expression, Action> matrixMutipleChoiceQuestionBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new MatrixMultipleChoiceQuestionBuilder(); + matrixMutipleChoiceQuestionBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + public PanelBuilder AddMultipleText(Expression> expression, Action> multipleTextQuestionBuilder) + { + TEntity mEntity = new TEntity(); + var myProperty = ReflectionHelpers.GetPropertyInfo(mEntity, expression); + var builder = new MultipleTextQuestionBuilder(); + multipleTextQuestionBuilder.Invoke(builder); + builder.HasName(myProperty.Name); + elementsBuilder.Add(builder); + return this; + } + + SurveyItem IBuilder.Build() + { + foreach (var surveyItemBuilder in elementsBuilder) + { + _item.Elements.Add(surveyItemBuilder.Build()); + } + return _item; + } + } +} \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/SurveyPanel.cs b/src/SurveyExtensions/Elements/SurveyPanel.cs new file mode 100644 index 0000000..656ef7a --- /dev/null +++ b/src/SurveyExtensions/Elements/SurveyPanel.cs @@ -0,0 +1,10 @@ +namespace SurveyExtensions.Elements +{ + using System.Collections.Generic; + + public class SurveyPanel : SurveyItem + { + public string Type { get => "panel"; } + public IList Elements { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/test/SurveyExtensionsTests/GeneralBuilderTests.cs b/test/SurveyExtensionsTests/GeneralBuilderTests.cs index 07a4c6d..ba1bd7e 100644 --- a/test/SurveyExtensionsTests/GeneralBuilderTests.cs +++ b/test/SurveyExtensionsTests/GeneralBuilderTests.cs @@ -32,7 +32,10 @@ public void TestSingleInput() ); companyBuilder.AddPage("MiPaginaMolona", - p => p.AddSingleInputQuestion(c => c.DocumentId, "placeholderMolon", "MiDni", SingleInputTypesEnum.Text)); + p => p.AddSingleInputQuestion(c => c.DocumentId, + i => i.HasPlaceHolder("placeholderMolon") + .HasTitle("MiDni") + .SetInputType(SingleInputTypesEnum.Text))); diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index e5e444d..976216f 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -17,7 +17,10 @@ public void SingleTextInputTest() SurveyBuilder companyBuilder = new SurveyBuilder(); companyBuilder.AddPage("Page1", - p => p.AddSingleInputQuestion(c => c.DocumentId, "Put Here your DNI", "Document Id Card", SingleInputTypesEnum.Text) + p => p.AddSingleInputQuestion(c => c.DocumentId, + i => i.HasPlaceHolder("Put Here your DNI") + .HasTitle("Document Id Card") + .SetInputType(SingleInputTypesEnum.Text)) ); var myBuildedElements = companyBuilder.Build(); @@ -31,7 +34,10 @@ public void CommentTest() SurveyBuilder companyBuilder = new SurveyBuilder(); companyBuilder.AddPage("Page1", - p => p.AddCommentInput(c => c.ContactData, "Datos de contacto", "entra los datos de contacto", 7) + p => p.AddCommentInput(c => c.ContactData, + i => i.HasTitle("Datos de contacto") + .HasPlaceHolder("entra los datos de contacto") + .HasRows(7)) .AddCommentInput(c => c.ContactData, i => i.HasTitle("Datos de contacto 2") .HasPlaceHolder("placeholder 2") @@ -51,7 +57,11 @@ public void RatingTests() companyBuilder.AddPage("Page1", p => p - .AddRating(c => c.IsLegalPerson, "Rating with values", "", 1, 10, 1) + .AddRating(c => c.IsLegalPerson, + i => i.HasTitle("Rating with values") + .HasRateMin(1) + .HasRateMax(10) + .HasRateStep(1)) .AddRating(c => c.IsLegalPerson, i => i.HasTitle("Rating with options") .AddRateValue("RTVal1", "Val 1") @@ -299,5 +309,16 @@ public void MultipleText() var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); extractedJson.Should().Be(jsoncollections.MultipleTextTestExtractedJson); } + + [Fact] + public void PanelWithelementsTest() + { + SurveyBuilder companyBuilder = new SurveyBuilder(); + companyBuilder.AddPage("Page1", + p => p.AddPanel("Panel1", pn => pn.AddFile( i=> i.ContactData, f=>f.HasMaxSize(50)))); + var myBuildedElements = companyBuilder.Build(); + var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + extractedJson.Should().Be(jsoncollections.PanelWithElementsExtractedJson); + } } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index d902d38..544dc1f 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -204,6 +204,15 @@ internal static string MultipleTextTestExtractedJson { } } + /// + /// Looks up a localized string similar to {"pages":[{"elements":[{"type":"panel","elements":[{"maxSize":50,"type":"file","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Panel1"}],"name":"Page1"}]}. + /// + internal static string PanelWithElementsExtractedJson { + get { + return ResourceManager.GetString("PanelWithElementsExtractedJson", resourceCulture); + } + } + /// /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. /// @@ -232,7 +241,7 @@ internal static string Radiogroup3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":"","visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6 [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVa [rest of string was truncated]";. /// internal static string RatingTestExtractedJson { get { @@ -241,7 +250,7 @@ internal static string RatingTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"Document Id Card","inputType":"text","type":"text","title":"Put Here your DNI","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"DocumentId"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"DocumentId"}],"name":"Page1"}]}. /// internal static string SingleInputTestExtractedJson { get { diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index c022860..5f28cb9 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -165,6 +165,9 @@ {"pages":[{"elements":[{"colCount":2,"items":[{"name":"Item 1 text"},{"name":"Item 2 text"},{"name":"Item 3 text"},{"name":"Item 4 text"}],"type":"multipletext","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + + {"pages":[{"elements":[{"type":"panel","elements":[{"maxSize":50,"type":"file","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Panel1"}],"name":"Page1"}]} + {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} @@ -175,10 +178,10 @@ {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}
- {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":"","visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6","text":"Val 6"},{"value":"RTVal7","text":"Val 7"},{"value":"RTVal8","text":"Val 8"}],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with options","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"}],"name":"Page1"}]} + {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6","text":"Val 6"},{"value":"RTVal7","text":"Val 7"},{"value":"RTVal8","text":"Val 8"}],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with options","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"}],"name":"Page1"}]} - {"pages":[{"elements":[{"placeHolder":"Document Id Card","inputType":"text","type":"text","title":"Put Here your DNI","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"DocumentId"}],"name":"Page1"}]} + {"pages":[{"elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"DocumentId"}],"name":"Page1"}]} {"pages":[{"name":"Page1","elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","isRequired":false,"name":"DocumentId"}]}]} From b08fe7acc9a2d1567f5215d568eb27a5468faa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Guti=C3=A9rrez=20Xarri=C3=A9?= Date: Sat, 7 Dec 2019 22:04:35 +0100 Subject: [PATCH 22/25] Rename enums --- .../Builders/CheckboxQuestionBuilder.cs | 4 ++-- .../Builders/DropdownQuestionBuilder.cs | 4 ++-- .../Builders/ImagePickerQuestionBuilder.cs | 4 ++-- .../MatrixMultipleChoiceQuestionBuilder.cs | 8 +++---- .../Builders/RadiogroupQuestionBuilder.cs | 4 ++-- .../Builders/SimgleItemQuestionBuilder.cs | 4 ++-- .../Enums/{CellTypesEnum.cs => CellTypes.cs} | 2 +- ...cesOrderEnum.cs => ChoicesOrderOprions.cs} | 2 +- ...eInputTypesEnum.cs => SingleInputTypes.cs} | 2 +- .../Factory/BulderFactory.cs | 22 +++++++++---------- .../GeneralBuilderTests.cs | 6 ++--- test/SurveyExtensionsTests/JsonTests.cs | 16 +++++++------- 12 files changed, 39 insertions(+), 39 deletions(-) rename src/SurveyExtensions/Enums/{CellTypesEnum.cs => CellTypes.cs} (83%) rename src/SurveyExtensions/Enums/{ChoicesOrderEnum.cs => ChoicesOrderOprions.cs} (75%) rename src/SurveyExtensions/Enums/{SingleInputTypesEnum.cs => SingleInputTypes.cs} (74%) diff --git a/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs b/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs index 0879e3f..2173c36 100644 --- a/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs @@ -52,9 +52,9 @@ public CheckboxQuestionBuilder HasColumnCount(int value) return this; } - public CheckboxQuestionBuilder SetChoicesOrder(ChoicesOrderEnum order) + public CheckboxQuestionBuilder SetChoicesOrder(ChoicesOrderOprions order) { - string enumName = Enum.GetName(typeof(ChoicesOrderEnum), order); + string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order); if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); return this; } diff --git a/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs b/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs index 13e7bca..c1d0a09 100644 --- a/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs @@ -46,9 +46,9 @@ public DropdownQuestionBuilder ContinueInSameLine() return this; } - public DropdownQuestionBuilder SetChoicesOrder(ChoicesOrderEnum order) + public DropdownQuestionBuilder SetChoicesOrder(ChoicesOrderOprions order) { - string enumName = Enum.GetName(typeof(ChoicesOrderEnum), order); + string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order); if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); return this; } diff --git a/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs b/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs index 3e6fba7..b7277fd 100644 --- a/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs @@ -52,9 +52,9 @@ public ImagePickerQuestionBuilder HasColumnCount(int value) return this; } - public ImagePickerQuestionBuilder SetChoicesOrder(ChoicesOrderEnum order) + public ImagePickerQuestionBuilder SetChoicesOrder(ChoicesOrderOprions order) { - string enumName = Enum.GetName(typeof(ChoicesOrderEnum), order); + string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order); if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); return this; } diff --git a/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs b/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs index 7c90e35..44c30a4 100644 --- a/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs @@ -58,17 +58,17 @@ public MatrixMultipleChoiceQuestionBuilder HasTotalText(string value) return this; } - public MatrixMultipleChoiceQuestionBuilder HasCellType(CellTypesEnum cellType) + public MatrixMultipleChoiceQuestionBuilder HasCellType(CellTypes cellType) { - string enumName = Enum.GetName(typeof(CellTypesEnum), cellType); + string enumName = Enum.GetName(typeof(CellTypes), cellType); if (enumName != null) _item.CellType = enumName.ToLowerInvariant(); return this; } - public MatrixMultipleChoiceQuestionBuilder AddColumn(string value, string text, CellTypesEnum cellType) + public MatrixMultipleChoiceQuestionBuilder AddColumn(string value, string text, CellTypes cellType) { string ct = null; - string enumName = Enum.GetName(typeof(CellTypesEnum), cellType); + string enumName = Enum.GetName(typeof(CellTypes), cellType); if (enumName != null) ct = enumName.ToLowerInvariant(); _item.Columns.Add(new MatrixMultipleChoiceChoice() { Value = value, Text = text, CellType = ct }); return this; diff --git a/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs b/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs index 8cef3cc..44ff453 100644 --- a/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs @@ -52,9 +52,9 @@ public RadiogroupQuestionBuilder HasColumnCount(int value) return this; } - public RadiogroupQuestionBuilder SetChoicesOrder(ChoicesOrderEnum order) + public RadiogroupQuestionBuilder SetChoicesOrder(ChoicesOrderOprions order) { - string enumName = Enum.GetName(typeof(ChoicesOrderEnum), order); + string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order); if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); return this; } diff --git a/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs b/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs index ab5d692..45cd897 100644 --- a/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs @@ -44,9 +44,9 @@ public SimgleItemQuestionBuilder ContinueInSameLine() return this; } - public SimgleItemQuestionBuilder SetInputType(SingleInputTypesEnum inputType) + public SimgleItemQuestionBuilder SetInputType(SingleInputTypes inputType) { - string enumName = Enum.GetName(typeof(SingleInputTypesEnum) ,inputType); + string enumName = Enum.GetName(typeof(SingleInputTypes) ,inputType); if (enumName != null) _item.InputType = enumName.ToLowerInvariant(); return this; } diff --git a/src/SurveyExtensions/Enums/CellTypesEnum.cs b/src/SurveyExtensions/Enums/CellTypes.cs similarity index 83% rename from src/SurveyExtensions/Enums/CellTypesEnum.cs rename to src/SurveyExtensions/Enums/CellTypes.cs index 3e9dc91..23e7c0a 100644 --- a/src/SurveyExtensions/Enums/CellTypesEnum.cs +++ b/src/SurveyExtensions/Enums/CellTypes.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Enums { - public enum CellTypesEnum + public enum CellTypes { Dropdown, Checkbox, diff --git a/src/SurveyExtensions/Enums/ChoicesOrderEnum.cs b/src/SurveyExtensions/Enums/ChoicesOrderOprions.cs similarity index 75% rename from src/SurveyExtensions/Enums/ChoicesOrderEnum.cs rename to src/SurveyExtensions/Enums/ChoicesOrderOprions.cs index 298c814..66500b7 100644 --- a/src/SurveyExtensions/Enums/ChoicesOrderEnum.cs +++ b/src/SurveyExtensions/Enums/ChoicesOrderOprions.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Enums { - public enum ChoicesOrderEnum + public enum ChoicesOrderOprions { none, asc, diff --git a/src/SurveyExtensions/Enums/SingleInputTypesEnum.cs b/src/SurveyExtensions/Enums/SingleInputTypes.cs similarity index 74% rename from src/SurveyExtensions/Enums/SingleInputTypesEnum.cs rename to src/SurveyExtensions/Enums/SingleInputTypes.cs index fb144ab..bc4a652 100644 --- a/src/SurveyExtensions/Enums/SingleInputTypesEnum.cs +++ b/src/SurveyExtensions/Enums/SingleInputTypes.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Enums { - public enum SingleInputTypesEnum + public enum SingleInputTypes { Text, Date, diff --git a/test/SurveyExtensionsTests/Factory/BulderFactory.cs b/test/SurveyExtensionsTests/Factory/BulderFactory.cs index 7da81b7..2a304fa 100644 --- a/test/SurveyExtensionsTests/Factory/BulderFactory.cs +++ b/test/SurveyExtensionsTests/Factory/BulderFactory.cs @@ -24,7 +24,7 @@ public static void Get_1Page_CheckboxWithAllWithNoneSortedAscending .HasOtherChoice("Other choice text") .HasSelectAllChoice("Select All") .HasSelectNoneChoice("Select none") - .SetChoicesOrder(ChoicesOrderEnum.asc)) + .SetChoicesOrder(ChoicesOrderOprions.asc)) ); } @@ -43,7 +43,7 @@ public static void Get_1Page_CheckboxWithAllSortedDescending .HasColumnCount(2) .HasOtherChoice("Other choice text") .HasSelectAllChoice("Select All") - .SetChoicesOrder(ChoicesOrderEnum.desc)) + .SetChoicesOrder(ChoicesOrderOprions.desc)) ); } @@ -64,7 +64,7 @@ public static void Get_1Page_CheckboxWithNoneSortedRandom .HasColumnCount(3) .HasOtherChoice("Other choice text") .HasSelectNoneChoice("Select none") - .SetChoicesOrder(ChoicesOrderEnum.random)) + .SetChoicesOrder(ChoicesOrderOprions.random)) ); } @@ -83,7 +83,7 @@ public static void Get_1Page_RadiogroupAscending(SurveyBuilder build .AddChoice("RG1Val5", "Choice 5") .HasColumnCount(1) .HasOtherChoice("Other choice text") - .SetChoicesOrder(ChoicesOrderEnum.asc)) + .SetChoicesOrder(ChoicesOrderOprions.asc)) ); } @@ -118,7 +118,7 @@ public static void Get_1Page_RadiogroupRandom(SurveyBuilder builder, .AddChoice("RG3Val4", "Choice 4") .AddChoice("RG3Val5", "Choice 5") .HasColumnCount(3) - .SetChoicesOrder(ChoicesOrderEnum.random)) + .SetChoicesOrder(ChoicesOrderOprions.random)) ); } @@ -137,7 +137,7 @@ public static void Get_1Page_DropdownAscending(SurveyBuilder builder .AddChoice("DD1Val4", "Choice 4") .AddChoice("DD1Val5", "Choice 5") .HasOtherChoice("Other choice text") - .SetChoicesOrder(ChoicesOrderEnum.asc)) + .SetChoicesOrder(ChoicesOrderOprions.asc)) ); } @@ -155,7 +155,7 @@ public static void Get_1Page_DropdownDescending(SurveyBuilder builde .AddChoice("DD2Val3", "Choice 3") .AddChoice("DD2Val4", "Choice 4") .AddChoice("DD2Val5", "Choice 5") - .SetChoicesOrder(ChoicesOrderEnum.desc)) + .SetChoicesOrder(ChoicesOrderOprions.desc)) ); } @@ -173,7 +173,7 @@ public static void Get_1Page_DropdownRandom(SurveyBuilder builder, .AddChoice("DD3Val3", "Choice 3") .AddChoice("DD3Val4", "Choice 4") .AddChoice("DD3Val5", "Choice 5") - .SetChoicesOrder(ChoicesOrderEnum.random)) + .SetChoicesOrder(ChoicesOrderOprions.random)) ); } @@ -190,7 +190,7 @@ public static void Get_1Page_ImagePickerAscending(SurveyBuilder buil .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") .HasColumnCount(0) - .SetChoicesOrder(ChoicesOrderEnum.asc)) + .SetChoicesOrder(ChoicesOrderOprions.asc)) ); } @@ -207,7 +207,7 @@ public static void Get_1Page_ImagePickerDescending(SurveyBuilder bui .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") .HasColumnCount(2) - .SetChoicesOrder(ChoicesOrderEnum.desc)) + .SetChoicesOrder(ChoicesOrderOprions.desc)) ); } @@ -224,7 +224,7 @@ public static void Get_1Page_ImagePickerRandom(SurveyBuilder builder .AddChoice("IP1Val3", "Panda", "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg") .AddChoice("IP1Val4", "Camel", "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg") .HasColumnCount(0) - .SetChoicesOrder(ChoicesOrderEnum.random)) + .SetChoicesOrder(ChoicesOrderOprions.random)) ); } } diff --git a/test/SurveyExtensionsTests/GeneralBuilderTests.cs b/test/SurveyExtensionsTests/GeneralBuilderTests.cs index ba1bd7e..08f191f 100644 --- a/test/SurveyExtensionsTests/GeneralBuilderTests.cs +++ b/test/SurveyExtensionsTests/GeneralBuilderTests.cs @@ -21,21 +21,21 @@ public void TestSingleInput() b => b .HasTitle("Dni") .HasPlaceHolder("Ponga aqui su dni") - .SetInputType(SingleInputTypesEnum.Text)) + .SetInputType(SingleInputTypes.Text)) .AddSingleInputQuestion(x=> x.ContactData, b=> b .HasTitle("Datos de Contacto") .HasPlaceHolder("Ponga Aqui sus Datos de Contacto")) ) .AddPage("Pagina 2", page=> - page.AddSingleInputQuestion(x=> x.IsCashReceiptCriteria, b=> b.SetInputType(SingleInputTypesEnum.Email)) + page.AddSingleInputQuestion(x=> x.IsCashReceiptCriteria, b=> b.SetInputType(SingleInputTypes.Email)) ); companyBuilder.AddPage("MiPaginaMolona", p => p.AddSingleInputQuestion(c => c.DocumentId, i => i.HasPlaceHolder("placeholderMolon") .HasTitle("MiDni") - .SetInputType(SingleInputTypesEnum.Text))); + .SetInputType(SingleInputTypes.Text))); diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index 976216f..a20c28e 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -20,7 +20,7 @@ public void SingleTextInputTest() p => p.AddSingleInputQuestion(c => c.DocumentId, i => i.HasPlaceHolder("Put Here your DNI") .HasTitle("Document Id Card") - .SetInputType(SingleInputTypesEnum.Text)) + .SetInputType(SingleInputTypes.Text)) ); var myBuildedElements = companyBuilder.Build(); @@ -273,19 +273,19 @@ public void MatrixMultipleChoiceTest() m => m.HasTitle("MSC Title") .HasDescription("MSC DEscription") .AddColumn("0", "Bad") - .AddColumn("1", "Mid-Bad", CellTypesEnum.Boolean) - .AddColumn("2", "Mid", CellTypesEnum.Checkbox) - .AddColumn("3", "Mid-Good", CellTypesEnum.Comment) - .AddColumn("4", "Good", CellTypesEnum.Dropdown) - .AddColumn("5", "Excellent", CellTypesEnum.Radiogroup) - .AddColumn("6", "SuperPower", CellTypesEnum.Text) + .AddColumn("1", "Mid-Bad", CellTypes.Boolean) + .AddColumn("2", "Mid", CellTypes.Checkbox) + .AddColumn("3", "Mid-Good", CellTypes.Comment) + .AddColumn("4", "Good", CellTypes.Dropdown) + .AddColumn("5", "Excellent", CellTypes.Radiogroup) + .AddColumn("6", "SuperPower", CellTypes.Text) .AddRow("R0", "Superman") .AddRow("R1", "Batman") .AddRow("R2", "Spiderman") .AddRow("R3", "Jocker") .AddChoice("C1", "Choice 1") .AddChoice("C2", "Chice 2") - .HasCellType(CellTypesEnum.Dropdown) + .HasCellType(CellTypes.Dropdown) .SetIsAllRowRequired() )); var myBuildedElements = companyBuilder.Build(); From a1df3ff64b95e1c5186533dec044a89582cbd842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Guti=C3=A9rrez=20Xarri=C3=A9?= Date: Sat, 7 Dec 2019 22:23:10 +0100 Subject: [PATCH 23/25] Renqme abstract class SurveyQuestion to Question --- src/SurveyExtensions/Builders/QuestionBuilderBase.cs | 2 +- src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs | 2 +- .../Elements/Questions/DropdownIQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/FileQuestion.cs | 2 +- .../Elements/Questions/HtmlEditorQuestion.cs | 2 +- .../Elements/Questions/ImagePickerQuestion.cs | 2 +- .../Elements/Questions/MatrixMultipleChoiceQuestion.cs | 2 +- .../Elements/Questions/MatrixSingleChoiceQuestion.cs | 2 +- .../Elements/Questions/MultipleTextQuestion.cs | 2 +- .../Elements/Questions/{SurveyQuestion.cs => Question.cs} | 2 +- .../Elements/Questions/RadiogroupQuestion.cs | 2 +- src/SurveyExtensions/Elements/Questions/RatingQuestion.cs | 2 +- .../Elements/Questions/SingleInputQuestion.cs | 2 +- src/SurveyExtensions/Helpers/ReflectionHelpers.cs | 6 ++++++ 16 files changed, 21 insertions(+), 15 deletions(-) rename src/SurveyExtensions/Elements/Questions/{SurveyQuestion.cs => Question.cs} (87%) diff --git a/src/SurveyExtensions/Builders/QuestionBuilderBase.cs b/src/SurveyExtensions/Builders/QuestionBuilderBase.cs index de3b798..56ce3f1 100644 --- a/src/SurveyExtensions/Builders/QuestionBuilderBase.cs +++ b/src/SurveyExtensions/Builders/QuestionBuilderBase.cs @@ -6,7 +6,7 @@ public abstract class QuestionBuilderBase : IBuilder where TEntity : new() - where TQuestion : SurveyQuestion + where TQuestion : Question { protected TQuestion _item = (TQuestion)(Activator.CreateInstance(typeof(TQuestion))); diff --git a/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs b/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs index 75057d4..0e17bdd 100644 --- a/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - public class BooleanQuestion : SurveyQuestion + public class BooleanQuestion : Question { public BooleanQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs b/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs index 5772b3e..abc15cf 100644 --- a/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs @@ -3,7 +3,7 @@ using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; - public class CheckboxQuestion : SurveyQuestion + public class CheckboxQuestion : Question { public CheckboxQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs b/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs index d5ad5e6..71939d1 100644 --- a/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - public class CommentsQuestion : SurveyQuestion + public class CommentsQuestion : Question { public CommentsQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs b/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs index 5a119f5..67c46d5 100644 --- a/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs @@ -3,7 +3,7 @@ using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; - public class DropdownIQuestion : SurveyQuestion + public class DropdownIQuestion : Question { public DropdownIQuestion() diff --git a/src/SurveyExtensions/Elements/Questions/FileQuestion.cs b/src/SurveyExtensions/Elements/Questions/FileQuestion.cs index f9d4d51..384287a 100644 --- a/src/SurveyExtensions/Elements/Questions/FileQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/FileQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - public class FileQuestion : SurveyQuestion + public class FileQuestion : Question { public FileQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs b/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs index 0483070..824f5f7 100644 --- a/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - public class HtmlEditorQuestion : SurveyQuestion + public class HtmlEditorQuestion : Question { public HtmlEditorQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs b/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs index b556afc..5868681 100644 --- a/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs @@ -3,7 +3,7 @@ using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; - public class ImagePickerQuestion : SurveyQuestion + public class ImagePickerQuestion : Question { public ImagePickerQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs b/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs index 7be9d4e..26078e4 100644 --- a/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs @@ -3,7 +3,7 @@ using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; - public class MatrixMultipleChoiceQuestion : SurveyQuestion + public class MatrixMultipleChoiceQuestion : Question { public MatrixMultipleChoiceQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs b/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs index cb064b0..7bda9eb 100644 --- a/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs @@ -3,7 +3,7 @@ using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; - public class MatrixSingleChoiceQuestion : SurveyQuestion + public class MatrixSingleChoiceQuestion : Question { public MatrixSingleChoiceQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs b/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs index 2d7836e..6131bed 100644 --- a/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs @@ -3,7 +3,7 @@ using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; - public class MultipleTextQuestion : SurveyQuestion + public class MultipleTextQuestion : Question { public MultipleTextQuestion() { diff --git a/src/SurveyExtensions/Elements/Questions/SurveyQuestion.cs b/src/SurveyExtensions/Elements/Questions/Question.cs similarity index 87% rename from src/SurveyExtensions/Elements/Questions/SurveyQuestion.cs rename to src/SurveyExtensions/Elements/Questions/Question.cs index c1d7a25..44b835c 100644 --- a/src/SurveyExtensions/Elements/Questions/SurveyQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/Question.cs @@ -2,7 +2,7 @@ { using System; - public abstract class SurveyQuestion : SurveyItem + public abstract class Question : SurveyItem { public string Type { get; set; } public string Title { get; set; } diff --git a/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs b/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs index 3386caf..e11afb1 100644 --- a/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs @@ -3,7 +3,7 @@ using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; - public class RadiogroupQuestion : SurveyQuestion + public class RadiogroupQuestion : Question { public RadiogroupQuestion() diff --git a/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs b/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs index 743622f..94510f7 100644 --- a/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs @@ -3,7 +3,7 @@ using SurveyExtensions.Elements.QuestionElements; using System.Collections.Generic; - public class RatingQuestion : SurveyQuestion + public class RatingQuestion : Question { public RatingQuestion() diff --git a/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs b/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs index c0c187c..0799943 100644 --- a/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs @@ -1,6 +1,6 @@ namespace SurveyExtensions.Elements.Questions { - public class SingleInputQuestion : SurveyQuestion + public class SingleInputQuestion : Question { public SingleInputQuestion() { diff --git a/src/SurveyExtensions/Helpers/ReflectionHelpers.cs b/src/SurveyExtensions/Helpers/ReflectionHelpers.cs index db4e6d5..a795703 100644 --- a/src/SurveyExtensions/Helpers/ReflectionHelpers.cs +++ b/src/SurveyExtensions/Helpers/ReflectionHelpers.cs @@ -11,22 +11,28 @@ public static PropertyInfo GetPropertyInfo(TSource source, E Type type = typeof(TSource); MemberExpression member = propertyLambda.Body as MemberExpression; if (member == null) + { throw new ArgumentException(string.Format( "Expression '{0}' refers to a method, not a property.", propertyLambda.ToString())); + } PropertyInfo propInfo = member.Member as PropertyInfo; if (propInfo == null) + { throw new ArgumentException(string.Format( "Expression '{0}' refers to a field, not a property.", propertyLambda.ToString())); + } if (type != propInfo.ReflectedType && !type.IsSubclassOf(propInfo.ReflectedType)) + { throw new ArgumentException(string.Format( "Expression '{0}' refers to a property that is not from type {1}.", propertyLambda.ToString(), type)); + } return propInfo; } From 482e9c0697da89c840553f56cbd10a9c6f96b1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Guti=C3=A9rrez=20Xarri=C3=A9?= Date: Sat, 7 Dec 2019 23:17:55 +0100 Subject: [PATCH 24/25] Finetune on questions properties --- .../Builders/CheckboxQuestionBuilder.cs | 7 ++++++- .../Builders/DropdownQuestionBuilder.cs | 14 +++++++++++++- .../Builders/ImagePickerQuestionBuilder.cs | 6 +++++- .../MatrixMultipleChoiceQuestionBuilder.cs | 18 ++++++++++-------- .../Builders/RadiogroupQuestionBuilder.cs | 6 +++++- .../Builders/SimgleItemQuestionBuilder.cs | 6 +++++- .../Elements/Questions/BooleanQuestion.cs | 4 ++++ .../Elements/Questions/CheckboxQuestion.cs | 11 +++++------ .../Elements/Questions/CommentsQuestion.cs | 4 ++++ .../Elements/Questions/DropdownIQuestion.cs | 11 +++++++---- .../Elements/Questions/FileQuestion.cs | 8 ++++++++ .../Elements/Questions/HtmlEditorQuestion.cs | 1 + .../Elements/Questions/ImagePickerQuestion.cs | 6 ++++-- .../Questions/MatrixMultipleChoiceQuestion.cs | 8 +++++--- .../Questions/MatrixSingleChoiceQuestion.cs | 5 ++++- .../Elements/Questions/MultipleTextQuestion.cs | 5 ++++- .../Elements/Questions/Question.cs | 5 ----- .../Elements/Questions/RadiogroupQuestion.cs | 5 +++++ .../Elements/Questions/RatingQuestion.cs | 7 ++++--- .../Elements/Questions/SingleInputQuestion.cs | 4 ++++ src/SurveyExtensions/Elements/SurveyPanel.cs | 1 + 21 files changed, 104 insertions(+), 38 deletions(-) diff --git a/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs b/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs index 2173c36..4a24712 100644 --- a/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs @@ -55,13 +55,18 @@ public CheckboxQuestionBuilder HasColumnCount(int value) public CheckboxQuestionBuilder SetChoicesOrder(ChoicesOrderOprions order) { string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order); - if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); + if (enumName != null) + { + _item.ChoicesOrder = enumName.ToLowerInvariant(); + } + return this; } public CheckboxQuestionBuilder HasOtherChoice(string choiceText) { _item.OtherText = choiceText; + _item.HasNone = true; return this; } diff --git a/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs b/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs index c1d0a09..4484fd7 100644 --- a/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs @@ -49,7 +49,11 @@ public DropdownQuestionBuilder ContinueInSameLine() public DropdownQuestionBuilder SetChoicesOrder(ChoicesOrderOprions order) { string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order); - if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); + if (enumName != null) + { + _item.ChoicesOrder = enumName.ToLowerInvariant(); + } + return this; } @@ -65,5 +69,13 @@ public DropdownQuestionBuilder AddChoice(string choiceValue, string cho _item.Choices.Add(new Choice() { Value = choiceValue, Text = choiceText }); return this; } + + public DropdownQuestionBuilder AutoChoices(int minChoice, int maxChoice, int choiceStep) + { + _item.ChoicesMin = minChoice; + _item.ChoicesMax = maxChoice; + _item.ChoicesStep = choiceStep; + return this; + } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs b/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs index b7277fd..dec797e 100644 --- a/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/ImagePickerQuestionBuilder.cs @@ -55,7 +55,11 @@ public ImagePickerQuestionBuilder HasColumnCount(int value) public ImagePickerQuestionBuilder SetChoicesOrder(ChoicesOrderOprions order) { string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order); - if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); + if (enumName != null) + { + _item.ChoicesOrder = enumName.ToLowerInvariant(); + } + return this; } diff --git a/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs b/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs index 44c30a4..f8321e0 100644 --- a/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/MatrixMultipleChoiceQuestionBuilder.cs @@ -46,12 +46,6 @@ public MatrixMultipleChoiceQuestionBuilder ContinueInSameLine() return this; } - public MatrixMultipleChoiceQuestionBuilder SetIsAllRowRequired() - { - _item.IsAllRowRequired = true; - return this; - } - public MatrixMultipleChoiceQuestionBuilder HasTotalText(string value) { _item.TotalText= value; @@ -61,7 +55,11 @@ public MatrixMultipleChoiceQuestionBuilder HasTotalText(string value) public MatrixMultipleChoiceQuestionBuilder HasCellType(CellTypes cellType) { string enumName = Enum.GetName(typeof(CellTypes), cellType); - if (enumName != null) _item.CellType = enumName.ToLowerInvariant(); + if (enumName != null) + { + _item.CellType = enumName.ToLowerInvariant(); + } + return this; } @@ -69,7 +67,11 @@ public MatrixMultipleChoiceQuestionBuilder AddColumn(string value, stri { string ct = null; string enumName = Enum.GetName(typeof(CellTypes), cellType); - if (enumName != null) ct = enumName.ToLowerInvariant(); + if (enumName != null) + { + ct = enumName.ToLowerInvariant(); + } + _item.Columns.Add(new MatrixMultipleChoiceChoice() { Value = value, Text = text, CellType = ct }); return this; } diff --git a/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs b/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs index 44ff453..cb7f8a1 100644 --- a/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/RadiogroupQuestionBuilder.cs @@ -55,7 +55,11 @@ public RadiogroupQuestionBuilder HasColumnCount(int value) public RadiogroupQuestionBuilder SetChoicesOrder(ChoicesOrderOprions order) { string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order); - if (enumName != null) _item.ChoicesOrder = enumName.ToLowerInvariant(); + if (enumName != null) + { + _item.ChoicesOrder = enumName.ToLowerInvariant(); + } + return this; } diff --git a/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs b/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs index 45cd897..4f7ce96 100644 --- a/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs +++ b/src/SurveyExtensions/Builders/SimgleItemQuestionBuilder.cs @@ -47,7 +47,11 @@ public SimgleItemQuestionBuilder ContinueInSameLine() public SimgleItemQuestionBuilder SetInputType(SingleInputTypes inputType) { string enumName = Enum.GetName(typeof(SingleInputTypes) ,inputType); - if (enumName != null) _item.InputType = enumName.ToLowerInvariant(); + if (enumName != null) + { + _item.InputType = enumName.ToLowerInvariant(); + } + return this; } diff --git a/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs b/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs index 0e17bdd..3e7a2a4 100644 --- a/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/BooleanQuestion.cs @@ -7,6 +7,10 @@ public BooleanQuestion() Type = "boolean"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public string Label { get; set; } public string LabelTrue { get; set; } = "Yes"; public string LabelFalse { get; set; } = "No"; diff --git a/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs b/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs index abc15cf..62b5ca3 100644 --- a/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/CheckboxQuestion.cs @@ -10,18 +10,17 @@ public CheckboxQuestion() Type = "checkbox"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public string ChoicesOrder { get; set; } - public int ColCount { get; set; } - public IList Choices { get; set; } = new List(); - - + public bool HasOther { get; set; } public string OtherText { get; set; } - public bool HasSelectAll { get; set; } = false; public string SelectAllText { get; set; } - public bool HasNone { get; set; } = false; public string NoneText { get; set; } } diff --git a/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs b/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs index 71939d1..60e404c 100644 --- a/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/CommentsQuestion.cs @@ -7,6 +7,10 @@ public CommentsQuestion() Type = "comment"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public string PlaceHolder { get; set; } public int Rows { get; set; } = 4; } diff --git a/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs b/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs index 67c46d5..3d8f5dd 100644 --- a/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/DropdownIQuestion.cs @@ -11,14 +11,17 @@ public DropdownIQuestion() Type = "dropdown"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public string ChoicesOrder { get; set; } - public IList Choices { get; set; } = new List(); - - public bool HasOther { get; set; } = false; public string OtherText { get; set; } - public string OptionCaption { get; set; } + public int ChoicesMin { get; set; } + public int ChoicesMax { get; set; } + public int ChoicesStep { get; set; } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/FileQuestion.cs b/src/SurveyExtensions/Elements/Questions/FileQuestion.cs index 384287a..0c44b4f 100644 --- a/src/SurveyExtensions/Elements/Questions/FileQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/FileQuestion.cs @@ -7,6 +7,14 @@ public FileQuestion() Type = "file"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; + public bool ShowPreview { get; set; } + public int ImageHeight { get; set; } + public int ImageWidth { get; set; } + public bool StoreDataAsText { get; set; } public int MaxSize { get; set; } = 0; } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs b/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs index 824f5f7..5a0e67e 100644 --- a/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/HtmlEditorQuestion.cs @@ -7,6 +7,7 @@ public HtmlEditorQuestion() Type = "html"; } + public bool StartWithNewLine { get; set; } = true; public string Html { get; set; } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs b/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs index 5868681..0364664 100644 --- a/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/ImagePickerQuestion.cs @@ -10,10 +10,12 @@ public ImagePickerQuestion() Type = "imagepicker"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public string ChoicesOrder { get; set; } - public int ColCount { get; set; } = 0; - public IList Choices { get; set; } = new List(); } diff --git a/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs b/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs index 26078e4..9bcea4e 100644 --- a/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MatrixMultipleChoiceQuestion.cs @@ -9,13 +9,15 @@ public MatrixMultipleChoiceQuestion() { Type = "matrixdropdown"; } + + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public string CellType { get; set; } public string TotalText { get; set; } - public IList Columns { get; set; } = new List(); public IList Rows { get; set; } = new List(); public IList Choices { get; set; } = new List(); - - public bool IsAllRowRequired { get; set; } = false; } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs b/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs index 7bda9eb..2b66b44 100644 --- a/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MatrixSingleChoiceQuestion.cs @@ -10,9 +10,12 @@ public MatrixSingleChoiceQuestion() Type = "matrix"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public IList Columns { get; set; } = new List(); public IList Rows { get; set; } = new List(); - public bool IsAllRowRequired { get; set; } = false; } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs b/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs index 6131bed..758435e 100644 --- a/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/MultipleTextQuestion.cs @@ -10,8 +10,11 @@ public MultipleTextQuestion() Type = "multipletext"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public int ColCount { get; set; } = 1; - public IList Items { get; set; } = new List(); } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/Question.cs b/src/SurveyExtensions/Elements/Questions/Question.cs index 44b835c..34a6914 100644 --- a/src/SurveyExtensions/Elements/Questions/Question.cs +++ b/src/SurveyExtensions/Elements/Questions/Question.cs @@ -5,11 +5,6 @@ public abstract class Question : SurveyItem { public string Type { get; set; } - public string Title { get; set; } - public string Description { get; set; } public bool Visible { get; set; } = true; - public bool IsRequired { get; set; } = false; - public bool StartWithNewLine { get; set; } = true; - } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs b/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs index e11afb1..7d3557e 100644 --- a/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/RadiogroupQuestion.cs @@ -10,7 +10,12 @@ public RadiogroupQuestion() { Type = "radiogroup"; } + public string Title { get; set; } + public string Description { get; set; } + + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public string ChoicesOrder { get; set; } public int ColCount { get; set; } public bool HasOther { get; set; } diff --git a/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs b/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs index 94510f7..a20a0b6 100644 --- a/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/RatingQuestion.cs @@ -11,14 +11,15 @@ public RatingQuestion() Type = "rating"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public int RateMin { get; set; } = 1; public int RateMax { get; set; } = 5; public int RateStep { get; set; } = 1; - public IList RateValues { get; set; } = new List(); - public string MinRateDescription { get; set; } - public string MaxRateDescription { get; set; } } } \ No newline at end of file diff --git a/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs b/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs index 0799943..211e4b0 100644 --- a/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs +++ b/src/SurveyExtensions/Elements/Questions/SingleInputQuestion.cs @@ -8,6 +8,10 @@ public SingleInputQuestion() InputType = "text"; } + public string Title { get; set; } + public string Description { get; set; } + public bool IsRequired { get; set; } = false; + public bool StartWithNewLine { get; set; } = true; public string PlaceHolder { get; set; } public string InputType { get; set; } } diff --git a/src/SurveyExtensions/Elements/SurveyPanel.cs b/src/SurveyExtensions/Elements/SurveyPanel.cs index 656ef7a..210edef 100644 --- a/src/SurveyExtensions/Elements/SurveyPanel.cs +++ b/src/SurveyExtensions/Elements/SurveyPanel.cs @@ -5,6 +5,7 @@ public class SurveyPanel : SurveyItem { public string Type { get => "panel"; } + public string Title { get; set; } public IList Elements { get; set; } = new List(); } } \ No newline at end of file From 6fcf8511998ed3a3f229f31b00fcdcdc524a33dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Guti=C3=A9rrez=20Xarri=C3=A9?= Date: Sun, 8 Dec 2019 00:06:27 +0100 Subject: [PATCH 25/25] Green tests --- src/SurveyExtensions/Elements/Survey.cs | 4 + src/SurveyExtensions/SurveyExtensions.csproj | 4 + test/SurveyExtensionsTests/JsonTests.cs | 93 +++++++++---------- .../jsonResults/jsoncollections.Designer.cs | 44 ++++----- .../jsonResults/jsoncollections.resx | 44 ++++----- 5 files changed, 97 insertions(+), 92 deletions(-) diff --git a/src/SurveyExtensions/Elements/Survey.cs b/src/SurveyExtensions/Elements/Survey.cs index 5475c54..d78d998 100644 --- a/src/SurveyExtensions/Elements/Survey.cs +++ b/src/SurveyExtensions/Elements/Survey.cs @@ -1,9 +1,13 @@ namespace SurveyExtensions.Elements { + using Newtonsoft.Json; + using Newtonsoft.Json.Serialization; using System.Collections.Generic; public class Survey { public List Pages { get; set; } = new List(); + + public string ToJson() => JsonConvert.SerializeObject(this, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); } } \ No newline at end of file diff --git a/src/SurveyExtensions/SurveyExtensions.csproj b/src/SurveyExtensions/SurveyExtensions.csproj index 2bd48b2..5221246 100644 --- a/src/SurveyExtensions/SurveyExtensions.csproj +++ b/src/SurveyExtensions/SurveyExtensions.csproj @@ -4,4 +4,8 @@ netcoreapp2.2 + + + + diff --git a/test/SurveyExtensionsTests/JsonTests.cs b/test/SurveyExtensionsTests/JsonTests.cs index a20c28e..cb59d32 100644 --- a/test/SurveyExtensionsTests/JsonTests.cs +++ b/test/SurveyExtensionsTests/JsonTests.cs @@ -4,8 +4,6 @@ namespace SurveyExtensionsTests using SurveyExtensionsTests.Dtos; using FluentAssertions; using SurveyExtensionsTests.jsonResults; - using Newtonsoft.Json; - using Newtonsoft.Json.Serialization; using SurveyExtensions.Builders; using SurveyExtensions.Enums; @@ -23,8 +21,8 @@ public void SingleTextInputTest() .SetInputType(SingleInputTypes.Text)) ); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.SingleInputTestExtractedJson); } @@ -45,8 +43,8 @@ public void CommentTest() .ContinueInSameLine()) ); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.CommentTestExtractedJson); } @@ -74,8 +72,8 @@ public void RatingTests() .AddRateValue("RTVal8", "Val 8")) ); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.RatingTestExtractedJson); } @@ -84,8 +82,8 @@ public void Checkbox1TestWithAllWithNoneSortedAscending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Checkbox1TestExtractedJson); } @@ -94,8 +92,8 @@ public void Checkbox2TestWithAllSortedDescending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_CheckboxWithAllSortedDescending(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Checkbox2TestExtractedJson); } @@ -104,8 +102,8 @@ public void Checkbox3TestWithAllWithNoneSortedAscending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_CheckboxWithAllWithNoneSortedAscending(companyBuilder, "Checkbox 3"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Checkbox3TestExtractedJson); } @@ -114,8 +112,8 @@ public void Radiogroup1TestAscending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_RadiogroupAscending(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Radiogroup1TestExtractedJson); } @@ -124,8 +122,8 @@ public void Radiogroup2TestDescending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_RadiogroupDescending(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Radiogroup2TestExtractedJson); } @@ -134,8 +132,8 @@ public void Radiogroup3TestRandom() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_RadiogroupRandom(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Radiogroup3TestExtractedJson); } @@ -143,9 +141,9 @@ public void Radiogroup3TestRandom() public void Dromdowm1TestAscending() { SurveyBuilder companyBuilder = new SurveyBuilder(); - Factory.BulderFactory.Get_1Page_RadiogroupRandom(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + Factory.BulderFactory.Get_1Page_DropdownAscending(companyBuilder, "Page1"); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Dropdown1TestExtractedJson); } @@ -154,8 +152,8 @@ public void Dromdowm2TestDescending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_DropdownDescending(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Dropdown2TestExtractedJson); } @@ -164,8 +162,8 @@ public void Dromdowm3TestRandom() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_DropdownRandom(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.Dropdown3TestExtractedJson); } @@ -174,8 +172,8 @@ public void ImagePicker1TestAscending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_ImagePickerAscending(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.ImagePicker1TestExtractedJson); } @@ -184,8 +182,8 @@ public void ImagePicker2TestDescending() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_ImagePickerDescending(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.ImagePicker2TestExtractedJson); } @@ -194,8 +192,8 @@ public void ImagePicker3TestRandom() { SurveyBuilder companyBuilder = new SurveyBuilder(); Factory.BulderFactory.Get_1Page_ImagePickerRandom(companyBuilder, "Page1"); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.ImagePicker3TestExtractedJson); } @@ -209,8 +207,8 @@ public void BooleanTest() .HasLabelTrue("True") .HasLabelFalse("False") )); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.BooleanTestExtractedJson); } @@ -222,8 +220,8 @@ public void HtmlEditornTest() p => p.AddHtmlEditor(c => c.ContactData, l => l.HasHtml("

H1 content

Paragraph

") )); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.HtmlEditorTestExtractedJson); } @@ -235,8 +233,8 @@ public void FileTest() p => p.AddFile(c => c.ContactData, l => l.HasMaxSize(250) )); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.FileExtractedJson); } @@ -259,8 +257,8 @@ public void MatrixSingleChoiceTest() .AddRow("R3", "Jocker") .SetIsAllRowRequired() )); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.MatrixSingleChoiceExtractedJson); } @@ -286,10 +284,9 @@ public void MatrixMultipleChoiceTest() .AddChoice("C1", "Choice 1") .AddChoice("C2", "Chice 2") .HasCellType(CellTypes.Dropdown) - .SetIsAllRowRequired() )); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.MatrixMultipleChoiceExtractedJson); } @@ -305,8 +302,8 @@ public void MultipleText() .AddItem("Item 4 text") .HasColumnCount(2) )); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.MultipleTextTestExtractedJson); } @@ -316,8 +313,8 @@ public void PanelWithelementsTest() SurveyBuilder companyBuilder = new SurveyBuilder(); companyBuilder.AddPage("Page1", p => p.AddPanel("Panel1", pn => pn.AddFile( i=> i.ContactData, f=>f.HasMaxSize(50)))); - var myBuildedElements = companyBuilder.Build(); - var extractedJson = JsonConvert.SerializeObject(myBuildedElements, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var builtCompany = companyBuilder.Build(); + var extractedJson = builtCompany.ToJson(); extractedJson.Should().Be(jsoncollections.PanelWithElementsExtractedJson); } } diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs index 544dc1f..df561f1 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.Designer.cs @@ -61,7 +61,7 @@ internal jsoncollections() { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":null,"description":null,"isRequired":false,"startWithNewLine":true,"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","visible":true,"name":"IsLegalPerson"}],"name":"Page1"}]}. /// internal static string BooleanTestExtractedJson { get { @@ -70,7 +70,7 @@ internal static string BooleanTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"visible":true,"isRequired":false,"startWithNewLin [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Choice 1 Title (asc) - All - None","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"hasOther":false,"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":" [rest of string was truncated]";. /// internal static string Checkbox1TestExtractedJson { get { @@ -79,7 +79,7 @@ internal static string Checkbox1TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":false,"noneText":null,"type":"checkbox","title":"Choice 2 Title (desc) - All","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Choice 2 Title (desc) - All","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"hasOther":false,"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":null,"type":"checkbox","vis [rest of string was truncated]";. /// internal static string Checkbox2TestExtractedJson { get { @@ -88,7 +88,7 @@ internal static string Checkbox2TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"visible":true,"isRequired":false,"startWithNewLin [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Choice 1 Title (asc) - All - None","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"hasOther":false,"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":" [rest of string was truncated]";. /// internal static string Checkbox3TestExtractedJson { get { @@ -97,7 +97,7 @@ internal static string Checkbox3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"visible":true,"isRequired":false,"startWithNewLine":false,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Datos de contacto","description":null,"isRequired":false,"startWithNewLine":true,"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","visible":true,"name":"ContactData"},{"title":"Datos de contacto 2","description":null,"isRequired":false,"startWithNewLine":false,"placeHolder":"placeholder 2","rows":14,"type":"comment","visible":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string CommentTestExtractedJson { get { @@ -106,7 +106,7 @@ internal static string CommentTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Dropdown 1 Title (asc)","description":"Dropdown 1 description","isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","choices":[{"value":"DD1Val1","text":"Choice 1"},{"value":"DD1Val2","text":"Choice 2"},{"value":"DD1Val3","text":"Choice 3"},{"value":"DD1Val4","text":"Choice 4"},{"value":"DD1Val5","text":"Choice 5"}],"hasOther":true,"otherText":"Other choice text","optionCaption":null,"choicesMin":0,"choicesMax":0,"choicesStep":0,"type":"dropdown","visible":true,"n [rest of string was truncated]";. /// internal static string Dropdown1TestExtractedJson { get { @@ -115,7 +115,7 @@ internal static string Dropdown1TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","isRequired":false,"startWithNewLine":true,"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"choicesMin":0,"choicesMax":0,"choicesStep":0,"type":"dropdown","visible":true,"name":"Conta [rest of string was truncated]";. /// internal static string Dropdown2TestExtractedJson { get { @@ -124,7 +124,7 @@ internal static string Dropdown2TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","isRequired":false,"startWithNewLine":true,"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"choicesMin":0,"choicesMax":0,"choicesStep":0,"type":"dropdown","visible":true,"name":"C [rest of string was truncated]";. /// internal static string Dropdown3TestExtractedJson { get { @@ -133,7 +133,7 @@ internal static string Dropdown3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"maxSize":250,"type":"file","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":null,"description":null,"isRequired":false,"startWithNewLine":true,"showPreview":false,"imageHeight":0,"imageWidth":0,"storeDataAsText":false,"maxSize":250,"type":"file","visible":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string FileExtractedJson { get { @@ -142,7 +142,7 @@ internal static string FileExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"startWithNewLine":true,"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","visible":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string HtmlEditorTestExtractedJson { get { @@ -151,7 +151,7 @@ internal static string HtmlEditorTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Image Picker 1 Title (asc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Pa [rest of string was truncated]";. /// internal static string ImagePicker1TestExtractedJson { get { @@ -160,7 +160,7 @@ internal static string ImagePicker1TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"I [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Image Picker 1 Title (asc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"P [rest of string was truncated]";. /// internal static string ImagePicker2TestExtractedJson { get { @@ -169,7 +169,7 @@ internal static string ImagePicker2TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value": [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Image Picker 1 Title (asc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text": [rest of string was truncated]";. /// internal static string ImagePicker3TestExtractedJson { get { @@ -178,7 +178,7 @@ internal static string ImagePicker3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"cellType":"dropdown","totalText":null,"columns":[{"cellType":null,"value":"0","text":"Bad"},{"cellType":"boolean","value":"1","text":"Mid-Bad"},{"cellType":"checkbox","value":"2","text":"Mid"},{"cellType":"comment","value":"3","text":"Mid-Good"},{"cellType":"dropdown","value":"4","text":"Good"},{"cellType":"radiogroup","value":"5","text":"Excellent"},{"cellType":"text","value":"6","text":"SuperPower"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1&q.... + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"MSC Title","description":"MSC DEscription","isRequired":false,"startWithNewLine":true,"cellType":"dropdown","totalText":null,"columns":[{"cellType":null,"value":"0","text":"Bad"},{"cellType":"boolean","value":"1","text":"Mid-Bad"},{"cellType":"checkbox","value":"2","text":"Mid"},{"cellType":"comment","value":"3","text":"Mid-Good"},{"cellType":"dropdown","value":"4","text":"Good"},{"cellType":"radiogroup","value":"5","text":"Excellent"},{"cellType":"text","value":"6","t.... /// internal static string MatrixMultipleChoiceExtractedJson { get { @@ -187,7 +187,7 @@ internal static string MatrixMultipleChoiceExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"nam.... + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"MSC Title","description":"MSC DEscription","isRequired":false,"startWithNewLine":true,"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","visible":true,"name":"ContactData"}],"nam.... /// internal static string MatrixSingleChoiceExtractedJson { get { @@ -196,7 +196,7 @@ internal static string MatrixSingleChoiceExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"colCount":2,"items":[{"name":"Item 1 text"},{"name":"Item 2 text"},{"name":"Item 3 text"},{"name":"Item 4 text"}],"type":"multipletext","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":null,"description":null,"isRequired":false,"startWithNewLine":true,"colCount":2,"items":[{"name":"Item 1 text"},{"name":"Item 2 text"},{"name":"Item 3 text"},{"name":"Item 4 text"}],"type":"multipletext","visible":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string MultipleTextTestExtractedJson { get { @@ -205,7 +205,7 @@ internal static string MultipleTextTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"type":"panel","elements":[{"maxSize":50,"type":"file","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Panel1"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"type":"panel","title":null,"elements":[{"title":null,"description":null,"isRequired":false,"startWithNewLine":true,"showPreview":false,"imageHeight":0,"imageWidth":0,"storeDataAsText":false,"maxSize":50,"type":"file","visible":true,"name":"ContactData"}],"name":"Panel1"}],"name":"Page1"}]}. /// internal static string PanelWithElementsExtractedJson { get { @@ -214,7 +214,7 @@ internal static string PanelWithElementsExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Radiogroup 1 Title (asc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","visible":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Radiogroup1TestExtractedJson { get { @@ -223,7 +223,7 @@ internal static string Radiogroup1TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 2 Title (desc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Radiogroup 2 Title (desc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","visible":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Radiogroup2TestExtractedJson { get { @@ -232,7 +232,7 @@ internal static string Radiogroup2TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Radiogroup 3 Title (random)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","visible":true,"name":"ContactData"}],"name":"Page1"}]}. /// internal static string Radiogroup3TestExtractedJson { get { @@ -241,7 +241,7 @@ internal static string Radiogroup3TestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVa [rest of string was truncated]";. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Rating with values","description":null,"isRequired":false,"startWithNewLine":true,"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","visible":true,"name":"IsLegalPerson"},{"title":"Rating with options","description":null,"isRequired":false,"startWithNewLine":true,"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text" [rest of string was truncated]";. /// internal static string RatingTestExtractedJson { get { @@ -250,7 +250,7 @@ internal static string RatingTestExtractedJson { } /// - /// Looks up a localized string similar to {"pages":[{"elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"DocumentId"}],"name":"Page1"}]}. + /// Looks up a localized string similar to {"pages":[{"elements":[{"title":"Document Id Card","description":null,"isRequired":false,"startWithNewLine":true,"placeHolder":"Put Here your DNI","inputType":"text","type":"text","visible":true,"name":"DocumentId"}],"name":"Page1"}]}. /// internal static string SingleInputTestExtractedJson { get { diff --git a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx index 5f28cb9..192d77b 100644 --- a/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx +++ b/test/SurveyExtensionsTests/jsonResults/jsoncollections.resx @@ -118,70 +118,70 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - {"pages":[{"elements":[{"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":null,"description":null,"isRequired":false,"startWithNewLine":true,"label":"Boolean label","labelTrue":"True","labelFalse":"False","type":"boolean","visible":true,"name":"IsLegalPerson"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Choice 1 Title (asc) - All - None","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"hasOther":false,"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":false,"noneText":null,"type":"checkbox","title":"Choice 2 Title (desc) - All","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Choice 2 Title (desc) - All","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"desc","colCount":2,"choices":[{"value":"CB2Val1","text":"Choice 1"},{"value":"CB2Val2","text":"Choice 2"},{"value":"CB2Val3","text":"Choice 3"},{"value":"CB2Val4","text":"Choice 4"},{"value":"CB2Val5","text":"Choice 5"}],"hasOther":false,"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":null,"type":"checkbox","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","title":"Choice 1 Title (asc) - All - None","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Checkbox 3"}]} + {"pages":[{"elements":[{"title":"Choice 1 Title (asc) - All - None","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","colCount":1,"choices":[{"value":"CB1Val1","text":"Choice 1"},{"value":"CB1Val2","text":"Choice 2"},{"value":"CB1Val3","text":"Choice 3"},{"value":"CB1Val4","text":"Choice 4"},{"value":"CB1Val5","text":"Choice 5"}],"hasOther":false,"otherText":"Other choice text","hasSelectAll":true,"selectAllText":"Select All","hasNone":true,"noneText":"Select none","type":"checkbox","visible":true,"name":"ContactData"}],"name":"Checkbox 3"}]} - {"pages":[{"elements":[{"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","title":"Datos de contacto","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"},{"placeHolder":"placeholder 2","rows":14,"type":"comment","title":"Datos de contacto 2","description":null,"visible":true,"isRequired":false,"startWithNewLine":false,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Datos de contacto","description":null,"isRequired":false,"startWithNewLine":true,"placeHolder":"entra los datos de contacto","rows":7,"type":"comment","visible":true,"name":"ContactData"},{"title":"Datos de contacto 2","description":null,"isRequired":false,"startWithNewLine":false,"placeHolder":"placeholder 2","rows":14,"type":"comment","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Dropdown 1 Title (asc)","description":"Dropdown 1 description","isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","choices":[{"value":"DD1Val1","text":"Choice 1"},{"value":"DD1Val2","text":"Choice 2"},{"value":"DD1Val3","text":"Choice 3"},{"value":"DD1Val4","text":"Choice 4"},{"value":"DD1Val5","text":"Choice 5"}],"hasOther":true,"otherText":"Other choice text","optionCaption":null,"choicesMin":0,"choicesMax":0,"choicesStep":0,"type":"dropdown","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Dropdown 2 Title (desc)","description":"Dropdown 2 description","isRequired":false,"startWithNewLine":true,"choicesOrder":"desc","choices":[{"value":"DD2Val1","text":"Choice 1"},{"value":"DD2Val2","text":"Choice 2"},{"value":"DD2Val3","text":"Choice 3"},{"value":"DD2Val4","text":"Choice 4"},{"value":"DD2Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"choicesMin":0,"choicesMax":0,"choicesStep":0,"type":"dropdown","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"type":"dropdown","title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Dropdown 3 Title (random)","description":"Dropdown 3 description","isRequired":false,"startWithNewLine":true,"choicesOrder":"random","choices":[{"value":"DD3Val1","text":"Choice 1"},{"value":"DD3Val2","text":"Choice 2"},{"value":"DD3Val3","text":"Choice 3"},{"value":"DD3Val4","text":"Choice 4"},{"value":"DD3Val5","text":"Choice 5"}],"hasOther":false,"otherText":null,"optionCaption":null,"choicesMin":0,"choicesMax":0,"choicesStep":0,"type":"dropdown","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"maxSize":250,"type":"file","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":null,"description":null,"isRequired":false,"startWithNewLine":true,"showPreview":false,"imageHeight":0,"imageWidth":0,"storeDataAsText":false,"maxSize":250,"type":"file","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"startWithNewLine":true,"html":"<h1>H1 content</h1><p>Paragraph</p>","type":"html","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Image Picker 1 Title (asc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Image Picker 1 Title (asc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"desc","colCount":2,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","title":"Image Picker 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Image Picker 1 Title (asc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"random","colCount":0,"choices":[{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg","value":"IP1Val1","text":"Lion"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg","value":"IP1Val2","text":"Giraffe"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg","value":"IP1Val3","text":"Panda"},{"imageLink":"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg","value":"IP1Val4","text":"Camel"}],"type":"imagepicker","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"cellType":"dropdown","totalText":null,"columns":[{"cellType":null,"value":"0","text":"Bad"},{"cellType":"boolean","value":"1","text":"Mid-Bad"},{"cellType":"checkbox","value":"2","text":"Mid"},{"cellType":"comment","value":"3","text":"Mid-Good"},{"cellType":"dropdown","value":"4","text":"Good"},{"cellType":"radiogroup","value":"5","text":"Excellent"},{"cellType":"text","value":"6","text":"SuperPower"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"choices":[{"value":"C1","text":"Choice 1"},{"value":"C2","text":"Chice 2"}],"isAllRowRequired":true,"type":"matrixdropdown","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"MSC Title","description":"MSC DEscription","isRequired":false,"startWithNewLine":true,"cellType":"dropdown","totalText":null,"columns":[{"cellType":null,"value":"0","text":"Bad"},{"cellType":"boolean","value":"1","text":"Mid-Bad"},{"cellType":"checkbox","value":"2","text":"Mid"},{"cellType":"comment","value":"3","text":"Mid-Good"},{"cellType":"dropdown","value":"4","text":"Good"},{"cellType":"radiogroup","value":"5","text":"Excellent"},{"cellType":"text","value":"6","text":"SuperPower"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"choices":[{"value":"C1","text":"Choice 1"},{"value":"C2","text":"Chice 2"}],"type":"matrixdropdown","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","title":"MSC Title","description":"MSC DEscription","visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"MSC Title","description":"MSC DEscription","isRequired":false,"startWithNewLine":true,"columns":[{"value":"0","text":"Bad"},{"value":"1","text":"Mid-Bad"},{"value":"2","text":"Mid"},{"value":"3","text":"Mid-Good"},{"value":"4","text":"Good"}],"rows":[{"value":"R0","text":"Superman"},{"value":"R1","text":"Batman"},{"value":"R2","text":"Spiderman"},{"value":"R3","text":"Jocker"}],"isAllRowRequired":true,"type":"matrix","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"colCount":2,"items":[{"name":"Item 1 text"},{"name":"Item 2 text"},{"name":"Item 3 text"},{"name":"Item 4 text"}],"type":"multipletext","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":null,"description":null,"isRequired":false,"startWithNewLine":true,"colCount":2,"items":[{"name":"Item 1 text"},{"name":"Item 2 text"},{"name":"Item 3 text"},{"name":"Item 4 text"}],"type":"multipletext","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"type":"panel","elements":[{"maxSize":50,"type":"file","title":null,"description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Panel1"}],"name":"Page1"}]} + {"pages":[{"elements":[{"type":"panel","title":null,"elements":[{"title":null,"description":null,"isRequired":false,"startWithNewLine":true,"showPreview":false,"imageHeight":0,"imageWidth":0,"storeDataAsText":false,"maxSize":50,"type":"file","visible":true,"name":"ContactData"}],"name":"Panel1"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 1 Title (asc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Radiogroup 1 Title (asc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"asc","colCount":1,"hasOther":true,"otherText":"Other choice text","choices":[{"value":"RG1Val1","text":"Choice 1"},{"value":"RG1Val2","text":"Choice 2"},{"value":"RG1Val3","text":"Choice 3"},{"value":"RG1Val4","text":"Choice 4"},{"value":"RG1Val5","text":"Choice 5"}],"type":"radiogroup","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 2 Title (desc)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Radiogroup 2 Title (desc)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":null,"colCount":2,"hasOther":false,"otherText":null,"choices":[{"value":"RG2Val1","text":"Choice 1"},{"value":"RG2Val2","text":"Choice 2"},{"value":"RG2Val3","text":"Choice 3"},{"value":"RG2Val4","text":"Choice 4"},{"value":"RG2Val5","text":"Choice 5"}],"type":"radiogroup","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","title":"Radiogroup 3 Title (random)","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"ContactData"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Radiogroup 3 Title (random)","description":null,"isRequired":false,"startWithNewLine":true,"choicesOrder":"random","colCount":3,"hasOther":false,"otherText":null,"choices":[{"value":"RG3Val1","text":"Choice 1"},{"value":"RG3Val2","text":"Choice 2"},{"value":"RG3Val3","text":"Choice 3"},{"value":"RG3Val4","text":"Choice 4"},{"value":"RG3Val5","text":"Choice 5"}],"type":"radiogroup","visible":true,"name":"ContactData"}],"name":"Page1"}]} - {"pages":[{"elements":[{"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with values","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"},{"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6","text":"Val 6"},{"value":"RTVal7","text":"Val 7"},{"value":"RTVal8","text":"Val 8"}],"minRateDescription":null,"maxRateDescription":null,"type":"rating","title":"Rating with options","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"IsLegalPerson"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Rating with values","description":null,"isRequired":false,"startWithNewLine":true,"rateMin":1,"rateMax":10,"rateStep":1,"rateValues":[],"minRateDescription":null,"maxRateDescription":null,"type":"rating","visible":true,"name":"IsLegalPerson"},{"title":"Rating with options","description":null,"isRequired":false,"startWithNewLine":true,"rateMin":1,"rateMax":5,"rateStep":1,"rateValues":[{"value":"RTVal1","text":"Val 1"},{"value":"RTVal2","text":"Val 2"},{"value":"RTVal3","text":"Val 3"},{"value":"RTVal4","text":"Val 4"},{"value":"RTVal5","text":"Val 5"},{"value":"RTVal6","text":"Val 6"},{"value":"RTVal7","text":"Val 7"},{"value":"RTVal8","text":"Val 8"}],"minRateDescription":null,"maxRateDescription":null,"type":"rating","visible":true,"name":"IsLegalPerson"}],"name":"Page1"}]} - {"pages":[{"elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","description":null,"visible":true,"isRequired":false,"startWithNewLine":true,"name":"DocumentId"}],"name":"Page1"}]} + {"pages":[{"elements":[{"title":"Document Id Card","description":null,"isRequired":false,"startWithNewLine":true,"placeHolder":"Put Here your DNI","inputType":"text","type":"text","visible":true,"name":"DocumentId"}],"name":"Page1"}]} {"pages":[{"name":"Page1","elements":[{"placeHolder":"Put Here your DNI","inputType":"text","type":"text","title":"Document Id Card","isRequired":false,"name":"DocumentId"}]}]}