Skip to content

Commit fdc73d8

Browse files
Formflow: Bring tests back to life. Still 2 failing but all others passing and form test program working end to end. (#4742)
1 parent 81232b0 commit fdc73d8

11 files changed

+786
-8
lines changed

CSharp/Microsoft.Bot.Builder.sln

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2027
4+
VisualStudioVersion = 15.0.27004.2010
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{28BCEB2C-F4BE-416D-A4FD-A311E99A9EB5}"
77
ProjectSection(SolutionItems) = preProject
@@ -62,6 +62,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.Sample.FormFl
6262
EndProject
6363
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EchoBot", "EchoBot\EchoBot.csproj", "{BC07AED8-F885-4810-8C41-66C05D4C1EAD}"
6464
EndProject
65+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormTest", "Tests\FormTest\FormTest.csproj", "{77BD8C61-FB06-4BF7-A346-D2C87284390A}"
66+
EndProject
6567
Global
6668
GlobalSection(SharedMSBuildProjectFiles) = preSolution
6769
Library\Microsoft.Bot.Connector.Shared\Microsoft.Bot.Connector.Shared.projitems*{09c14ef5-f94a-480f-82ca-4d934a977c7f}*SharedItemsImports = 4
@@ -174,6 +176,12 @@ Global
174176
{BC07AED8-F885-4810-8C41-66C05D4C1EAD}.Documentation|Any CPU.Build.0 = Debug|Any CPU
175177
{BC07AED8-F885-4810-8C41-66C05D4C1EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
176178
{BC07AED8-F885-4810-8C41-66C05D4C1EAD}.Release|Any CPU.Build.0 = Release|Any CPU
179+
{77BD8C61-FB06-4BF7-A346-D2C87284390A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
180+
{77BD8C61-FB06-4BF7-A346-D2C87284390A}.Debug|Any CPU.Build.0 = Debug|Any CPU
181+
{77BD8C61-FB06-4BF7-A346-D2C87284390A}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
182+
{77BD8C61-FB06-4BF7-A346-D2C87284390A}.Documentation|Any CPU.Build.0 = Debug|Any CPU
183+
{77BD8C61-FB06-4BF7-A346-D2C87284390A}.Release|Any CPU.ActiveCfg = Release|Any CPU
184+
{77BD8C61-FB06-4BF7-A346-D2C87284390A}.Release|Any CPU.Build.0 = Release|Any CPU
177185
EndGlobalSection
178186
GlobalSection(SolutionProperties) = preSolution
179187
HideSolutionNode = FALSE
@@ -197,6 +205,7 @@ Global
197205
{09C14EF5-F94A-480F-82CA-4D934A977C7F} = {28BCEB2C-F4BE-416D-A4FD-A311E99A9EB5}
198206
{48E4B834-49A5-48EB-BBA7-20A7CD9690D2} = {8E05398E-3CBE-4DCD-9382-072DC8859427}
199207
{BC07AED8-F885-4810-8C41-66C05D4C1EAD} = {8E05398E-3CBE-4DCD-9382-072DC8859427}
208+
{77BD8C61-FB06-4BF7-A346-D2C87284390A} = {8E05398E-3CBE-4DCD-9382-072DC8859427}
200209
EndGlobalSection
201210
GlobalSection(ExtensibilityGlobals) = postSolution
202211
SolutionGuid = {F82D70DE-DC3B-4B04-97CD-3CFF66345798}

CSharp/Tests/FormTest/FormTest.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
<Reference Include="System.Xml" />
105105
</ItemGroup>
106106
<ItemGroup>
107+
<Compile Include="Models\AnnotatedSandwichOrder.cs" />
108+
<Compile Include="Models\SandwichOrder.cs" />
107109
<Compile Include="pizza.cs" />
108110
<Compile Include="Program.cs" />
109111
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -112,6 +114,7 @@
112114
<DesignTime>True</DesignTime>
113115
<DependentUpon>DynamicPizza.resx</DependentUpon>
114116
</Compile>
117+
<Compile Include="Resource\DynamicSandwich.Designer.cs" />
115118
</ItemGroup>
116119
<ItemGroup>
117120
<None Include="App.config" />
@@ -142,6 +145,9 @@
142145
<ItemGroup>
143146
<EmbeddedResource Include="Resource\DynamicPizza.en.resx" />
144147
<EmbeddedResource Include="Resource\DynamicPizza.fr.resx" />
148+
<EmbeddedResource Include="Resource\DynamicSandwich.en.resx" />
149+
<EmbeddedResource Include="Resource\DynamicSandwich.fr.resx" />
150+
<EmbeddedResource Include="Resource\DynamicSandwich.resx" />
145151
<EmbeddedResource Include="Resource\Microsoft.Bot.Builder.FormFlowTest.PizzaOrder.en.resx" />
146152
<EmbeddedResource Include="Resource\Microsoft.Bot.Builder.FormFlowTest.PizzaOrder.fr.resx" />
147153
<EmbeddedResource Include="Resource\Microsoft.Bot.Builder.FormFlowTest.PizzaOrder.resx" />

CSharp/Tests/FormTest/Models/AnnotatedSandwichOrder.cs

Lines changed: 379 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
// Licensed under the MIT license.
4+
//
5+
// Microsoft Bot Framework: http://botframework.com
6+
//
7+
// Bot Builder SDK GitHub:
8+
// https://github.com/Microsoft/BotBuilder
9+
//
10+
// Copyright (c) Microsoft Corporation
11+
// All rights reserved.
12+
//
13+
// MIT License:
14+
// Permission is hereby granted, free of charge, to any person obtaining
15+
// a copy of this software and associated documentation files (the
16+
// "Software"), to deal in the Software without restriction, including
17+
// without limitation the rights to use, copy, modify, merge, publish,
18+
// distribute, sublicense, and/or sell copies of the Software, and to
19+
// permit persons to whom the Software is furnished to do so, subject to
20+
// the following conditions:
21+
//
22+
// The above copyright notice and this permission notice shall be
23+
// included in all copies or substantial portions of the Software.
24+
//
25+
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32+
//
33+
34+
using Microsoft.Bot.Builder.FormFlow;
35+
using System;
36+
using System.Collections.Generic;
37+
38+
namespace FormTest.Models.SimpleSandwich
39+
{
40+
public enum SandwichOptions
41+
{
42+
BLT, BlackForestHam, BuffaloChicken, ChickenAndBaconRanchMelt, ColdCutCombo, MeatballMarinara,
43+
OvenRoastedChicken, RoastBeef, RotisserieStyleChicken, SpicyItalian, SteakAndCheese, SweetOnionTeriyaki, Tuna,
44+
TurkeyBreast, Veggie
45+
};
46+
public enum LengthOptions { SixInch, FootLong };
47+
public enum BreadOptions { NineGrainWheat, NineGrainHoneyOat, Italian, ItalianHerbsAndCheese, Flatbread };
48+
public enum CheeseOptions { American, MontereyCheddar, Pepperjack };
49+
public enum ToppingOptions
50+
{
51+
Avocado, BananaPeppers, Cucumbers, GreenBellPeppers, Jalapenos,
52+
Lettuce, Olives, Pickles, RedOnion, Spinach, Tomatoes
53+
};
54+
public enum SauceOptions
55+
{
56+
ChipotleSouthwest, HoneyMustard, LightMayonnaise, RegularMayonnaise,
57+
Mustard, Oil, Pepper, Ranch, SweetOnion, Vinegar
58+
};
59+
60+
[Serializable]
61+
public class SandwichOrder
62+
{
63+
public SandwichOptions? Sandwich;
64+
public LengthOptions? Length;
65+
public BreadOptions? Bread;
66+
public CheeseOptions? Cheese;
67+
public List<ToppingOptions> Toppings;
68+
public List<SauceOptions> Sauce;
69+
70+
public static IForm<SandwichOrder> BuildForm()
71+
{
72+
return new FormBuilder<SandwichOrder>()
73+
.Message("Welcome to the simple sandwich order bot!")
74+
.Build();
75+
}
76+
};
77+
}

CSharp/Tests/FormTest/Program.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
using Microsoft.Bot.Builder.FormFlow.Advanced;
4949
using Microsoft.Bot.Connector;
5050
using Microsoft.Bot.Builder.History;
51-
52-
using AnnotatedSandwichOrder = Microsoft.Bot.Sample.AnnotatedSandwichBot.SandwichOrder;
53-
using SimpleSandwichOrder = Microsoft.Bot.Sample.SimpleSandwichBot.SandwichOrder;
5451
using System.Resources;
5552
using System.Text;
5653
using Newtonsoft.Json.Linq;
@@ -284,11 +281,11 @@ static void Main(string[] args)
284281
return MakeForm(() => PizzaOrder.BuildForm(false, false, true));
285282
}
286283
case DebugOptions.SimpleSandwichBot:
287-
return MakeForm(() => SimpleSandwichOrder.BuildForm());
284+
return MakeForm(() => FormTest.Models.SimpleSandwich.SandwichOrder.BuildForm());
288285
case DebugOptions.AnnotatedSandwichBot:
289-
return MakeForm(() => AnnotatedSandwichOrder.BuildLocalizedForm());
286+
return MakeForm(() => FormTest.Models.AnnotatedSandwich.AnnotatedSandwichOrder.BuildLocalizedForm());
290287
case DebugOptions.JSONSandwichBot:
291-
return MakeForm(() => AnnotatedSandwichOrder.BuildJsonForm());
288+
return MakeForm(() => FormTest.Models.AnnotatedSandwich.AnnotatedSandwichOrder.BuildJsonForm());
292289
default:
293290
throw new NotImplementedException();
294291
}

CSharp/Tests/FormTest/Resource/DynamicSandwich.Designer.cs

Lines changed: 108 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<resheader name="resmimetype">
4+
<value>text/microsoft-resx</value>
5+
</resheader>
6+
<resheader name="version">
7+
<value>2.0</value>
8+
</resheader>
9+
<resheader name="reader">
10+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
11+
</resheader>
12+
<resheader name="writer">
13+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
14+
</resheader>
15+
<data name="BadAddress" xml:space="preserve">
16+
<value>Address must start with a number.</value>
17+
</data>
18+
<data name="Cost" xml:space="preserve">
19+
<value>Total for your sandwich is {0:C2} is that ok?</value>
20+
</data>
21+
<data name="FreeCookie" xml:space="preserve">
22+
<value>Free cookie</value>
23+
</data>
24+
<data name="FreeDrink" xml:space="preserve">
25+
<value>Free drink</value>
26+
</data>
27+
<data name="Processing" xml:space="preserve">
28+
<value>We are currently processing your sandwich. We will message you the status.</value>
29+
</data>
30+
</root>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<resheader name="resmimetype">
4+
<value>text/microsoft-resx</value>
5+
</resheader>
6+
<resheader name="version">
7+
<value>2.0</value>
8+
</resheader>
9+
<resheader name="reader">
10+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
11+
</resheader>
12+
<resheader name="writer">
13+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
14+
</resheader>
15+
<data name="BadAddress" xml:space="preserve">
16+
<value>Adresse doit commencer par un nombre.</value>
17+
</data>
18+
<data name="Cost" xml:space="preserve">
19+
<value>Total pour votre "sandwich" est {0:C2} est ce correct?</value>
20+
</data>
21+
<data name="FreeCookie" xml:space="preserve">
22+
<value>Cookie gratuit</value>
23+
</data>
24+
<data name="FreeDrink" xml:space="preserve">
25+
<value>Boisson gratuite</value>
26+
</data>
27+
<data name="Processing" xml:space="preserve">
28+
<value>Nous traitons actuellement votre "sandwich". Nous seront vous message le statut.</value>
29+
</data>
30+
</root>

0 commit comments

Comments
 (0)