コード例 #1
0
        public void WhenQueryingForQuestionnaires_ThenInvokesCallback()
        {
            AsyncResult<Questionnaire> ar = null;

            var serviceMock = new MockQuestionnaireService();
            serviceMock.HandleBeginGetQuestionnaire = (r) => ar = r;

            var repository = new QuestionnaireRepository(serviceMock);

            bool calledBack = false;

            repository.GetQuestionnaireAsync((result) => { calledBack = true; });

            serviceMock.ProceedGetQuestionnaire(ar, new Questionnaire());

            EnqueueConditional(() => calledBack);

            EnqueueCallback(() => { Assert.IsTrue(calledBack); });
            EnqueueTestComplete();
        }
コード例 #2
0
        public void WhenQueryingForQuestionnares_ThenProvidesQuestionnaireResult()
        {
            AsyncResult<Questionnaire> ar = null;
            Questionnaire suppliedQuestionnaire = new Questionnaire();

            var serviceMock = new MockQuestionnaireService();
            serviceMock.HandleBeginGetQuestionnaire = (r) => ar = r;

            var repository = new QuestionnaireRepository(serviceMock);

            IOperationResult<Questionnaire> getResult = null;
            repository.GetQuestionnaireAsync((result) => getResult = result);

            serviceMock.ProceedGetQuestionnaire(ar, suppliedQuestionnaire);

            EnqueueConditional(() => getResult != null);
            EnqueueCallback(() =>
            {
                Assert.AreSame(suppliedQuestionnaire, getResult.Result);
            });

            EnqueueTestComplete();
        }
コード例 #3
0
        public void WhenSubmittingQuestionnare_ThenInvokesCallback()
        {
            AsyncResult<object> ar = null;

            var serviceMock = new MockQuestionnaireService();
            serviceMock.HandleBeginSubmitResponses = (r) => ar = r;

            var repository = new QuestionnaireRepository(serviceMock);

            bool calledBack = false;

            repository.SubmitQuestionnaireAsync(new Questionnaire(), (result) => { calledBack = true; });

            serviceMock.ProceedSubmitResponses(ar);

            EnqueueConditional(() => calledBack);

            EnqueueCallback(() => { Assert.IsTrue(calledBack); });
            EnqueueTestComplete();
        }