public void SetUp()
        {
            _ministryPlatformService = new Mock<IMinistryPlatformService>();
            _authService = new Mock<IAuthenticationService>();
            _configWrapper = new Mock<IConfigurationWrapper>();
            _dbConnection = new Mock<IDbConnection>();

            _configWrapper.Setup(m => m.GetEnvironmentVarAsString("API_USER")).Returns("uid");
            _configWrapper.Setup(m => m.GetEnvironmentVarAsString("API_PASSWORD")).Returns("pwd");
            _authService.Setup(m => m.Authenticate(It.IsAny<string>(), It.IsAny<string>())).Returns(new Dictionary<string, object> { { "token", "ABC" }, { "exp", "123" } });

            _fixture = new FormSubmissionService(_ministryPlatformService.Object, _dbConnection.Object, _authService.Object, _configWrapper.Object);

            _mockAnswer1 = new FormAnswer
            {
                FieldId = 375,
                FormResponseId = responseId,
                OpportunityResponseId = 7329,
                Response = "Test Last Name"
            };

            _mockAnswer2 = new FormAnswer
            {
                FieldId = 376,
                FormResponseId = responseId,
                OpportunityResponseId = 7329,
                Response = "Test First Name"
            };

            _mockAnswer3 = new FormAnswer
            {
                FieldId = 377,
                FormResponseId = responseId,
                OpportunityResponseId = 7329,
                Response = "Test Middle Initial"
            };

            _mockForm = new FormResponse
            {
                FormId = 17,
                ContactId = 2389887,
                OpportunityId = 313,
                OpportunityResponseId = 7329,
                FormAnswers = new List<FormAnswer>
                {
                    _mockAnswer1,
                    _mockAnswer2,
                    _mockAnswer3
                }
            };
        }
        private void CreateFormAnswer(FormAnswer answer, string token)
        {
            var formAnswer = new Dictionary<string, object>
            {
                {"Form_Response_ID", answer.FormResponseId},
                {"Form_Field_ID", answer.FieldId},
                {"Response", answer.Response},
                {"Opportunity_Response", answer.OpportunityResponseId}
            };

            try
            {
                _ministryPlatformService.CreateRecord(_formAnswerPageId, formAnswer, token, true);
            }
            catch (Exception exception)
            {
                throw new ApplicationException(string.Format("CreateFormAnswer failed.  Field Id: {0}", answer.FieldId), exception);
            }
        }
 private FormAnswer SetCustomField(CustomField customField, int opportunityResponseId)
 {
     int fieldId;
     try
     {
         fieldId = _formFields.Single(f => f.CrossroadsId == customField.CrossroadsId).FormFieldId;
     }
     catch
     {
         throw new ApplicationException(string.Format("Failed to locate id for crossroads field {0}",
             customField.CrossroadsId));
     }
     var answer = new FormAnswer();
     answer.FieldId = fieldId;
     answer.OpportunityResponseId = opportunityResponseId;
     answer.Response = customField.Value;
     return answer;
 }