/// <summary> /// Create a new controller based on the parameters provided, allows DI. /// </summary> /// <param name="request">The HTTP request.</param> /// <param name="controllerDescriptor">The controller descriptor.</param> /// <param name="controllerType">The type of the controller.</param> /// <returns>A new controller based on the parameters provided.</returns> public IHttpController Create( HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) { IHttpController controller = null; PlayCustomerMigration databaseContext = null; // Create appropriate controller based on the controller name switch (controllerDescriptor.ControllerName) { case "Customer": databaseContext = new PlayCustomerMigration(); controller = new CustomerController( new VerifyCustomer( new GetCustomerFromDatabase(databaseContext), new HashEmailAddress(), new UpdateFirstLoginDate(databaseContext), new VerifyPassword())); break; } return controller; }
public async Task InvalidSiteReturns400() { // Arrange var verifyCommand = new StubICommand<VerifyCustomerParameters, Task<bool>> { ExecuteT0 = (p) => { throw new InvalidSiteException(); } }; var controller = new CustomerController(verifyCommand); // Act IHttpActionResult result = await controller.VerifyCredentialsAsync("256", "*****@*****.**", "whatever"); // Assert Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult)); }
public async Task InCorrectCredentialsReturns404() { // Arrange var verifyCommand = new StubICommand<VerifyCustomerParameters, Task<bool>> { ExecuteT0 = (p) => Task.Run(() => false) }; var controller = new CustomerController(verifyCommand); // Act IHttpActionResult result = await controller.VerifyCredentialsAsync("256", "*****@*****.**", "whatever"); // Assert Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }