private static Areas.Admin.Controllers.RegistrationController GetMockAccountController(object viewModel) { var oauth = A.Fake<IOAuthClient>(); var iwsClient = A.Fake<IIwsClient>(); var registrationController = new Areas.Admin.Controllers.RegistrationController(() => oauth, iwsClient, null); // Mimic the behaviour of the model binder which is responsible for Validating the Model var validationContext = new ValidationContext(viewModel, null, null); var validationResults = new List<ValidationResult>(); Validator.TryValidateObject(viewModel, validationContext, validationResults, true); foreach (var validationResult in validationResults) { registrationController.ModelState.AddModelError(validationResult.MemberNames.First(), validationResult.ErrorMessage); } return registrationController; }
private static Areas.Admin.Controllers.RegistrationController GetMockAccountController(object viewModel) { var oauth = A.Fake <IOAuthClient>(); var iwsClient = A.Fake <IIwsClient>(); var clientCredentialsClient = A.Fake <IOAuthClientCredentialClient>(); var registrationController = new Areas.Admin.Controllers.RegistrationController(() => oauth, iwsClient, null, () => clientCredentialsClient); // Mimic the behaviour of the model binder which is responsible for Validating the Model var validationContext = new ValidationContext(viewModel, null, null); var validationResults = new List <ValidationResult>(); Validator.TryValidateObject(viewModel, validationContext, validationResults, true); foreach (var validationResult in validationResults) { registrationController.ModelState.AddModelError(validationResult.MemberNames.First(), validationResult.ErrorMessage); } return(registrationController); }