public void BuildsBasicForm() { var request = new WhisperForm { CancelLabel = "cancel", Markdown = "Markdown", SubmitLabel = "Submit", Config = new WhisperConfig { Label = "Config.Label", }, Inputs = new Dictionary <string, IBase>() { { "first", new Checkbox { Value = true, Label = "CheckboxLabel", Tooltip = "CheckboxTooltip", Order = 0, } } }, }; var result = Builder.BuildRequest(request, Session); var expected = new Proto.WhisperFormRequest() { CancelLabel = request.CancelLabel, SubmitLabel = request.SubmitLabel, Markdown = request.Markdown, Meta = new WhisperMeta { Label = "Config.Label", }, Inputs = { { "first", new WhisperFormInput { Checkbox = new WhisperFormInput.Types.Checkbox { Value = true, Label = "CheckboxLabel", Tooltip = "CheckboxTooltip", Order = 0, } } } }, Session = Session }; Assert.That(result, Is.EqualTo(expected)); }
private void FormStream() { var whisperForm = new WhisperForm { CancelLabel = "Cancel", SubmitLabel = "Submit", Config = new WhisperConfig { Label = "C# Whisper Form" }, Inputs = new Dictionary <string, IBase> { ["Checkbox"] = new Checkbox { Label = "checkbox", Tooltip = "checkbox tooltip", Value = true }, ["Email"] = new Email { Label = "email", Tooltip = "email tooltip", Value = "*****@*****.**" }, ["Markdown"] = new Markdown { Label = "markdown", Tooltip = "markdown tooltip", Value = "# Hello\n\n How are you" }, ["Number"] = new Number { Label = "number", Tooltip = "number tooltip", Value = 5, Max = 10, Min = 0 }, ["Password"] = new Password { Label = "password", Tooltip = "password tooltip" }, ["Radio"] = new Radio { Label = "radio", Tooltip = "radio tooltip", Options = new[] { "Radio1", "Radio2" } }, ["Select"] = new Select { Label = "select", Tooltip = "select tooltip", Options = new[] { "Select1", "Select2" } }, ["Telephone"] = new Telephone { Label = "telephone", Tooltip = "telephone tooltip", Value = "888-777-6666", Pattern = "XXX-XXX-XXXX" }, ["Text"] = new Text { Label = "text", Tooltip = "text tooltip", Value = "Text" }, ["Time"] = new Time { Label = "time", Tooltip = "time tooltip", Value = DateTimeOffset.Now }, } }; var stream = _services.Whisper.FormAsync(whisperForm); Task.Run(async() => { while (await stream.MoveNext()) { switch (stream.Current()) { case WhisperUpdate u: LogFormUpdate(u); break; case WhisperResult r: Logger.Info("Received Form Response"); Logger.Info(r.IsSubmitted ? "Form Submitted" : "Form Rejected", r.Outputs as IDictionary <string, object>); break; } } Logger.Info("Form Ended"); }); }