示例#1
0
        public async Task VerifyFormScript <T>(string filePath,
                                               string locale, BuildFormDelegate <T> buildForm, FormOptions options, T initialState, IEnumerable <EntityRecommendation> entities,
                                               params string[] inputs)
            where T : class
        {
            var newPath = Script.NewScriptPathFor(filePath);

            File.Delete(newPath);
            var currentState = JsonConvert.DeserializeObject <T>(JsonConvert.SerializeObject(initialState));

            try
            {
                using (var stream = new StreamReader(filePath))
                    using (var container = Build(Options.Reflection))
                    {
                        Func <IDialog <object> > makeRoot = () => new FormDialog <T>(currentState, buildForm, options, entities);
                        Assert.AreEqual(locale, stream.ReadLine());
                        Assert.AreEqual(SerializeToJson(initialState), stream.ReadLine());
                        Assert.AreEqual(SerializeToJson(entities), stream.ReadLine());
                        await Script.VerifyScript(container, makeRoot, false, stream, (stack, state) =>
                        {
                            var form = ((FormDialog <T>)stack.Frames[0].Target);
                            Assert.AreEqual(state, SerializeToJson(form.State));
                        }, inputs, locale);
                    }
            }
            catch (Exception)
            {
                // There was an error, so record new script and pass on error
                await RecordFormScript(newPath, locale, buildForm, options, initialState, entities, inputs);

                TestContext.AddResultFile(newPath);
                throw;
            }
        }
示例#2
0
 public LUISDialog(BuildFormDelegate <PersonalBanking> personalBanking) : base(new LuisService(new LuisModelAttribute(
                                                                                                   ConfigurationManager.AppSettings["LuisAppId"],
                                                                                                   ConfigurationManager.AppSettings["LuisAPIKey"],
                                                                                                   domain: ConfigurationManager.AppSettings["LuisAPIHostName"])))
 {
     this.Banking = personalBanking;
     loan         = new Loan();
 }
示例#3
0
        internal static FormDialog <LeadRegisterForm> MakeRootDialog(string channelId)
        {
            BuildFormDelegate <LeadRegisterForm> MakeLeadRegisterForm = null;
            var isSkype = channelId.ToLowerInvariant() == "skypeforbusiness";

            if (isSkype)
            {
                MakeLeadRegisterForm = () => LeadRegisterForm.BuildFormSkype();
            }
            else
            {
                MakeLeadRegisterForm = () => LeadRegisterForm.BuildForm();
            }
            return(FormDialog.FromForm(MakeLeadRegisterForm, options: FormOptions.PromptInStart));
        }
示例#4
0
 public async Task RecordFormScript <T>(string filePath,
                                        string locale, BuildFormDelegate <T> buildForm, FormOptions options, T initialState, IEnumerable <EntityRecommendation> entities,
                                        params string[] inputs)
     where T : class
 {
     using (var stream = new StreamWriter(filePath))
         using (var container = Build(Options.ResolveDialogFromContainer | Options.Reflection))
         {
             var root = new FormDialog <T>(initialState, buildForm, options, entities, CultureInfo.GetCultureInfo(locale));
             stream.WriteLine($"{locale}");
             stream.WriteLine($"{SerializeToJson(initialState)}");
             stream.WriteLine($"{SerializeToJson(entities)}");
             var builder = new ContainerBuilder();
             builder
             .RegisterInstance(root)
             .AsSelf()
             .As <IDialog <object> >();
             builder.Update(container);
             await Script.RecordScript(container, false, stream, () => "State:" + SerializeToJson(initialState), inputs);
         }
 }
示例#5
0
        public async Task VerifyFormScript <T>(string filePath,
                                               string locale, BuildFormDelegate <T> buildForm, FormOptions options, T initialState, IEnumerable <EntityRecommendation> entities,
                                               params string[] inputs)
            where T : class
        {
            var newPath = Script.NewScriptPathFor(filePath);

            File.Delete(newPath);
            var currentState = JsonConvert.DeserializeObject <T>(JsonConvert.SerializeObject(initialState));

            try
            {
                using (var stream = new StreamReader(filePath))
                    using (var container = Build(Options.ResolveDialogFromContainer | Options.Reflection))
                    {
                        var root    = new FormDialog <T>(currentState, buildForm, options, entities, CultureInfo.GetCultureInfo(locale));
                        var builder = new ContainerBuilder();
                        builder
                        .RegisterInstance(root)
                        .AsSelf()
                        .As <IDialog <object> >();
                        builder.Update(container);
                        Assert.AreEqual(locale, stream.ReadLine());
                        Assert.AreEqual(SerializeToJson(initialState), stream.ReadLine());
                        Assert.AreEqual(SerializeToJson(entities), stream.ReadLine());
                        await Script.VerifyScript(container, false, stream, (state) => Assert.AreEqual(state, SerializeToJson(currentState)), inputs);
                    }
            }
            catch (Exception)
            {
                // There was an error, so record new script and pass on error
                await RecordFormScript(newPath, locale, buildForm, options, initialState, entities, inputs);

                TestContext.AddResultFile(newPath);
                throw;
            }
        }
示例#6
0
 public SoftwareRequestDialog(BuildFormDelegate <SoftwareRequest> newSoftwareRequest)
 {
     this._newSoftwareRequest = newSoftwareRequest;
 }
示例#7
0
 public LaptopFaultDialog(BuildFormDelegate <LaptopFault> newLaptopFault)
 {
     this._newLaptopFault = newLaptopFault;
 }
示例#8
0
 public SoftwareFaultDialog(BuildFormDelegate <SoftwareFault> newSoftwareFault)
 {
     this._newSoftwareFault = newSoftwareFault;
 }
示例#9
0
 public HotelBotLuisDialog(BuildFormDelegate <RoomReservation> reserveRoom)
 {
     this.ReserveRoom = reserveRoom;
 }
示例#10
0
 public LUISDialog(BuildFormDelegate <Order> newOrder)
 {
     this.NewOrder = newOrder;
 }
示例#11
0
 public RootDialog(BuildFormDelegate <BookingFlow> bookMeetingRoom,
                   Func <IBotContext, IAwaitable <BookingFlow>, Task> onAfterBooking)
 {
     BookMeetingRoom = bookMeetingRoom;
     OnAfterBooking  = onAfterBooking;
 }
示例#12
0
 public LuisDialog(BuildFormDelegate <ParcelTracking> parcelTrackingForm, ParcelService parcelService)
 {
     this.parcelTrackingForm = parcelTrackingForm;
     this.parcelService      = parcelService;
 }
示例#13
0
 public LUISDialog(BuildFormDelegate <MessageBox> configureMessageBox)
 {
     _configureMessageBox = configureMessageBox;
 }
示例#14
0
 public AccessResetDialog(BuildFormDelegate <AccessReset> newAccessReset)
 {
     this._newAccessReset = newAccessReset;
 }
示例#15
0
 public AccessRequestDialog(BuildFormDelegate <AccessRequest> newAccessRequest)
 {
     this._newAccessRequest = newAccessRequest;
 }
示例#16
0
 internal InteractionWithLuis(BuildFormDelegate <Pedido> criarPedido)
 {
     this.CriarPedido = criarPedido;
 }
示例#17
0
 public HotelDialogLUIS(BuildFormDelegate <RoomReservation> ireserveRoom)
 {
     _reserveRoom = ireserveRoom;
 }
示例#18
0
 public static IFormDialog <T> MakeForm <T>(BuildFormDelegate <T> buildForm) where T : class, new()
 {
     return(new FormDialog <T>(new T(), buildForm, options: FormOptions.PromptInStart));
 }
示例#19
0
 public RootDialog(BuildFormDelegate <Cakes> orderCake)
 {
     OrderCake = orderCake;
 }
示例#20
0
 internal LuisForm(BuildFormDelegate <Pedido> criarPedido)
 {
     CriarPedido = criarPedido;
 }
示例#21
0
 public LuisDialog(BuildFormDelegate <UserOrder> pizzaorder)
 {
     this.OrderPizza = pizzaorder;
 }
示例#22
0
 public PeripheralsRequestDialog(BuildFormDelegate <PeripheralsRequest> newPeripheralsRequest)
 {
     this._newPeripheralsRequest = newPeripheralsRequest;
 }
 internal PizzaOrderDialog(BuildFormDelegate <PizzaOrder> makePizzaForm)
 {
     this.MakePizzaForm = makePizzaForm;
 }
示例#24
0
 /// <summary>
 /// Create an <see cref="IFormDialog{T}"/> using the <see cref="BuildFormDelegate{T}"/> parameter.
 /// </summary>
 /// <typeparam name="T">The form type.</typeparam>
 /// <param name="buildForm">The delegate to build the form.</param>
 /// <param name="options">The form options.</param>
 /// <returns>The form dialog.</returns>
 public static IFormDialog <T> FromForm <T>(BuildFormDelegate <T> buildForm, FormOptions options = FormOptions.None) where T : class, new()
 {
     return(new FormDialog <T>(new T(), buildForm, options));
 }
示例#25
0
 public LUISDialog(BuildFormDelegate <UserFeedBack> UserFB)
 {
     this.UserFB = UserFB;
 }
示例#26
0
 public IncidentDialog(BuildFormDelegate <IncidenceReport> newIncidentReport)
 {
     this.newIncidentReport_ = newIncidentReport;
 }
示例#27
0
 public LuisDialog(BuildFormDelegate <RoomsReservation> reserveRoom)
 {
     this._reserveRoom = reserveRoom;
 }
示例#28
0
 public AutoNationLuisDialog(BuildFormDelegate <LeadForm> submitLeadForm, BuildFormDelegate <UserActivityType> submitActivityType)
 {
     SubmitLeadForm     = submitLeadForm;
     SubmitActivityType = submitActivityType;
 }
示例#29
0
 public LUISDialog(BuildFormDelegate <RoomReservation> reserveRoom)
 {
     this.reserveform = reserveRoom;
 }
示例#30
0
 internal BatterySelectorDialog(BuildFormDelegate <BatterySelector> MakeBatteryForm)
 {
     this.MakeBatteryForm = MakeBatteryForm;
 }