Skip to content

Commit

Permalink
Add a test case around optional properties with a field validator. To…
Browse files Browse the repository at this point in the history
… verify microsoft#1203 works.
  • Loading branch information
chrimc62 committed Sep 12, 2016
1 parent ed6f4d4 commit e083f2b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
33 changes: 32 additions & 1 deletion CSharp/Tests/Microsoft.Bot.Builder.Tests/FormTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,44 @@ await VerifyFormScript(@"..\..\JSON.script",
"abc",
"1 state st",
"",
"1pm",
"9/9/2016 1pm",
"status",
"y",
"2.5"
);
}

public class MyClass
{
[Prompt("I didn't get you")]
public string xxx { get; set; }

[Optional]
public string yyy { get; set; }

public static IForm<MyClass> Build()
{
return new FormBuilder<MyClass>()
.Message("Welcome")
.Field(nameof(xxx))
.Field(nameof(yyy), validate: async (state, value) =>
new ValidateResult() { IsValid = true} )
.Build()
;
}
}

[TestMethod]
public async Task Optional()
{
await VerifyFormScript(@"..\..\Optional.script",
"en-us", () => MyClass.Build(), FormOptions.None, new MyClass(), Array.Empty<EntityRecommendation>(),
"ok",
"This is something",
""
);
}

[TestMethod]
public async Task FormFlow_Localization()
{
Expand Down
15 changes: 15 additions & 0 deletions CSharp/Tests/Microsoft.Bot.Builder.Tests/Optional.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
en-us
{"xxx":null,"yyy":null}
[]
FromUser:"ok"
2
ToUserText:"Welcome"
ToUserText:"I didn't get you"
State:{"xxx":null,"yyy":null}
FromUser:"This is something"
1
ToUserText:"Please enter yyy (current choice: No Preference)"
State:{"xxx":"This is something","yyy":null}
FromUser:""
0
State:{"xxx":"This is something","yyy":null}

0 comments on commit e083f2b

Please sign in to comment.