public IAsyncResult BeginSubmitQuestionnaire(Questionnaire questionnaire, AsyncCallback callback, object asyncState)
        {
            var result = new AsyncResult<object>(callback, asyncState);
            HandleBeginSubmitResponses(result);

            return result;
        }
        public void SubmitQuestionnaireAsync(Questionnaire questionnaire, Action<IOperationResult> callback)
        {
            this.service.BeginSubmitQuestionnaire(
                questionnaire,
                (ar) =>
                {
                    var operationResult = new OperationResult();

                    try
                    {
                        this.service.EndSubmitQuestionnaire(ar);
                    }
                    catch (Exception ex)
                    {
                        operationResult.Error = ex;
                    }

                    synchronizationContext.Post(
                        (state) =>
                        {
                            callback(operationResult);
                        },
                        null);
                },
                null);
        }
Example #3
0
        public void WhenAgeIsSetToInvalidValue_ThenQuestionnaireIsNotComplete()
        {
            var questionnaire = new Questionnaire(new QuestionnaireTemplate());

            questionnaire.Name = "name";
            questionnaire.Age = 200;

            Assert.IsFalse(questionnaire.IsComplete);
        }
Example #4
0
        public void WhenNameAndAgeAreSetToValidValues_TheQuestionnaireIsComplete()
        {
            var questionnaire = new Questionnaire(new QuestionnaireTemplate());

            questionnaire.Name = "name";
            questionnaire.Age = 25;

            Assert.IsTrue(questionnaire.IsComplete);
        }
Example #5
0
        public IAsyncResult BeginSubmitQuestionnaire(Questionnaire questionnaire, AsyncCallback callback, object userState)
        {
            var asyncResult = new AsyncResult<object>(callback, userState);
            ThreadPool.QueueUserWorkItem(
                o =>
                {
                    // simulated processing time
                    Thread.Sleep(2000);

                    if (!FailOnSubmit)
                    {
                        asyncResult.SetComplete((object)null, false);
                    }
                    else
                    {
                        asyncResult.SetComplete(new InvalidOperationException("Not authorized"), false);
                    }
                });

            return asyncResult;
        }
Example #6
0
 public void WhenCreated_ProvidesTemplateTitle()
 {
     var questionnaire = new Questionnaire(new QuestionnaireTemplate() { Title = "QuestionnaireTitle" });
     Assert.AreEqual("QuestionnaireTitle", questionnaire.QuestionnaireTitle);
 }
Example #7
0
        public void WhenCreated_TheQuestionnaireIsNotComplete()
        {
            var questionnaire = new Questionnaire(new QuestionnaireTemplate());

            Assert.IsFalse(questionnaire.IsComplete);
        }