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(); }
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(); }
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(); }