public void SubmitFormResponse() { var expectedAnswerDict1 = new Dictionary <string, object> { { "Form_Response_ID", responseId }, { "Form_Field_ID", _mockAnswer1.FieldId }, { "Response", _mockAnswer1.Response }, { "Opportunity_Response", _mockAnswer1.OpportunityResponseId }, { "Event_Participant_ID", null } }; var expectedAnswerDict2 = new Dictionary <string, object> { { "Form_Response_ID", responseId }, { "Form_Field_ID", _mockAnswer2.FieldId }, { "Response", _mockAnswer2.Response }, { "Opportunity_Response", _mockAnswer2.OpportunityResponseId }, { "Event_Participant_ID", null } }; var expectedAnswerDict3 = new Dictionary <string, object> { { "Form_Response_ID", responseId }, { "Form_Field_ID", _mockAnswer3.FieldId }, { "Response", _mockAnswer3.Response }, { "Opportunity_Response", _mockAnswer3.OpportunityResponseId }, { "Event_Participant_ID", null } }; _configWrapper.Setup(m => m.GetConfigIntValue("FormResponsePageId")).Returns(formResponsePageId); _ministryPlatformService.Setup(m => m.CreateRecord(formResponsePageId, It.IsAny <Dictionary <string, object> >(), It.IsAny <string>(), true)).Returns(responseId); _ministryPlatformService.Setup(m => m.CreateRecord(formAnswerPageId, expectedAnswerDict1, It.IsAny <string>(), true)); _ministryPlatformService.Setup(m => m.CreateRecord(formAnswerPageId, expectedAnswerDict2, It.IsAny <string>(), true)); _ministryPlatformService.Setup(m => m.CreateRecord(formAnswerPageId, expectedAnswerDict3, It.IsAny <string>(), true)); _ministryPlatformRest.Setup(m => m.UsingAuthenticationToken(It.IsAny <string>())).Returns(_ministryPlatformRest.Object); _ministryPlatformRest.Setup(m => m.Search <MpFormResponse>(It.IsAny <string>(), It.IsAny <string>(), null, true)).Returns(new List <MpFormResponse>()); _ministryPlatformRest.Setup(m => m.Search <MpFormAnswer>(It.IsAny <string>(), It.IsAny <string>(), null, true)).Returns(new List <MpFormAnswer>()); var result = _fixture.SubmitFormResponse(_mockForm); Assert.AreEqual(responseId, result); _ministryPlatformRest.VerifyAll(); }
public void SubmitFormResponse() { var expectedResponseDict = new Dictionary <string, object> { { "Form_ID", _mockForm.FormId }, { "Response_Date", DateTime.Today }, { "Contact_ID", _mockForm.ContactId }, { "Opportunity_ID", _mockForm.OpportunityId }, { "Opportunity_Response", _mockForm.OpportunityResponseId }, { "Pledge_Campaign_ID", null } }; var expectedAnswerDict1 = new Dictionary <string, object> { { "Form_Response_ID", _mockAnswer1.FormResponseId }, { "Form_Field_ID", _mockAnswer1.FieldId }, { "Response", _mockAnswer1.Response }, { "Opportunity_Response", _mockAnswer1.OpportunityResponseId }, { "Event_Participant_ID", null } }; var expectedAnswerDict2 = new Dictionary <string, object> { { "Form_Response_ID", _mockAnswer2.FormResponseId }, { "Form_Field_ID", _mockAnswer2.FieldId }, { "Response", _mockAnswer2.Response }, { "Opportunity_Response", _mockAnswer2.OpportunityResponseId }, { "Event_Participant_ID", null } }; var expectedAnswerDict3 = new Dictionary <string, object> { { "Form_Response_ID", _mockAnswer3.FormResponseId }, { "Form_Field_ID", _mockAnswer3.FieldId }, { "Response", _mockAnswer3.Response }, { "Opportunity_Response", _mockAnswer3.OpportunityResponseId }, { "Event_Participant_ID", null } }; _ministryPlatformService.Setup(m => m.CreateRecord(formResponsePageId, expectedResponseDict, It.IsAny <string>(), true)).Returns(responseId); _ministryPlatformService.Setup(m => m.CreateRecord(formAnswerPageId, expectedAnswerDict1, It.IsAny <string>(), true)); _ministryPlatformService.Setup(m => m.CreateRecord(formAnswerPageId, expectedAnswerDict2, It.IsAny <string>(), true)); _ministryPlatformService.Setup(m => m.CreateRecord(formAnswerPageId, expectedAnswerDict3, It.IsAny <string>(), true)); _ministryPlatformRest.Setup(m => m.UsingAuthenticationToken(It.IsAny <string>())).Returns(_ministryPlatformRest.Object); var formResult = new List <MpFormResponse>(); var f = new MpFormResponse { FormResponseId = 0 }; formResult.Add(f); _ministryPlatformRest.Setup(m => m.Search <MpFormResponse>(It.IsAny <string>(), It.IsAny <string>(), null, true)).Returns(formResult); var ansResult = new List <MpFormAnswer>(); var a = new MpFormAnswer { FormResponseAnswerId = 0 }; _ministryPlatformRest.Setup(m => m.Search <MpFormAnswer>(It.IsAny <string>(), It.IsAny <string>(), null, true)).Returns(ansResult); var result = _fixture.SubmitFormResponse(_mockForm); Assert.AreEqual(responseId, result); _ministryPlatformService.VerifyAll(); }