private void AutomateInput()
        {
            FormManagerServiceSettings settings = new FormManagerServiceSettings {
                AutomatedInput = true, MaxRepeaterIterations = 4
            };
            const string uri     = "http://localhost:8089/FormManagerService/form/manager/settings";
            var          request = this.CreatePostRequest(uri, Json.Serialize(settings), method: "PUT", contentType: "application/json");

            var responseStatus = this.GetWebResponse <bool>(request);

            Assert.IsTrue(responseStatus.Value, "The response payload was null or empty");
        }
 //[ValidateAntiForgeryToken]
 public ActionResult <ResponseStatus <bool> > SetFormManagerServiceSettings([FromBody] FormManagerServiceSettings settings)
 {
     try
     {
         return(this.Service.SetFormManagerServiceSettings(settings));
     }
     catch (Exception exc)
     {
         Logger.Error(exc);
         this.Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(null);
     }
 }
        public void TestCreateAndRunDIYOnboardingForm()
        {
            var serviceSettings = new FormManagerServiceSettings
            {
                AutomatedInput        = true,
                NoCreateRestService   = true,
                NoMessaging           = true,
                NoPersistence         = true,
                MaxRepeaterIterations = 1
            };

            using (FormManagerService service = new FormManagerService(serviceSettings))
            {
                // Load the form definition
                var loadDefResponse = service.LoadFormDefinitionFromFile("./DIYOnboardingForm.json");
                Assert.IsNotNull(loadDefResponse);
                Assert.AreEqual(loadDefResponse.StatusCode, ResponseStatusCodes.OK);

                var createRequest = Json.Deserialize <FormCreateRequest>(loadDefResponse.Value);
                Assert.IsNotNull(createRequest);

                // Create the internal form definition
                var createResponse = service.CreateForm(createRequest);
                Assert.IsNotNull(createResponse);
                Assert.AreEqual(createResponse.StatusCode, ResponseStatusCodes.OK);
                Assert.IsNotNull(createResponse.Value);

                // We should get back an array of name/value pairs
                var formDefId = createResponse.Value[0].Id;

                // Create an instance of the DIYOnboarding form from the template
                var newformResponse = service.NewForm(formDefId);
                Assert.IsNotNull(newformResponse);
                Assert.AreEqual(newformResponse.StatusCode, ResponseStatusCodes.OK);

                // Read the instance and make sure it really exists
                var idFormInstance = newformResponse.Value;
                var formInstance   = SBSFormModel.Instance.GetFormInstance(idFormInstance);
                Assert.IsNotNull(formInstance);

                // Detect when the form is done running
                ManualResetEvent eventStop = new ManualResetEvent(false);
                formInstance.Submitted += form =>
                {
//                    eventStop.Set();
                };
                formInstance.Cancelled += form =>
                {
                    eventStop.Set();
                };
                service.RunFormEnded += form =>
                {
                    if (form.Id == idFormInstance)
                    {
                        eventStop.Set();
                    }
                };

                // Run the form asynchronously
                var runformResponse = service.RunForm(idFormInstance);
                Assert.IsNotNull(runformResponse);
                Assert.AreEqual(runformResponse.StatusCode, ResponseStatusCodes.OK);

                // Wait for the form to end
                bool rc = eventStop.WaitOne();
                eventStop.Dispose();
                Assert.IsTrue(rc, "The test timed out");
            }

            Console.WriteLine("TestCreateAndRunDIYOnboardingForm: We reached the end of the test");
        }