Exemplo n.º 1
0
        public IAsyncResult BeginSubmitQuestionnaire(Questionnaire questionnaire, AsyncCallback callback, object asyncState)
        {
            var result = new AsyncResult<object>(callback, asyncState);
            HandleBeginSubmitResponses(result);

            return result;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public void WhenAgeIsSetToInvalidValue_ThenQuestionnaireIsNotComplete()
        {
            var questionnaire = new Questionnaire(new QuestionnaireTemplate());

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

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

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

            Assert.IsTrue(questionnaire.IsComplete);
        }
Exemplo n.º 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;
        }
Exemplo n.º 6
0
 public void WhenCreated_ProvidesTemplateTitle()
 {
     var questionnaire = new Questionnaire(new QuestionnaireTemplate() { Title = "QuestionnaireTitle" });
     Assert.AreEqual("QuestionnaireTitle", questionnaire.QuestionnaireTitle);
 }
Exemplo n.º 7
0
        public void WhenCreated_TheQuestionnaireIsNotComplete()
        {
            var questionnaire = new Questionnaire(new QuestionnaireTemplate());

            Assert.IsFalse(questionnaire.IsComplete);
        }