private static Controller CreateController(CommerceControllerActivator activator, Type controllerType) { try { return(activator.Create(controllerType)); } catch (Exception ex) { throw new InvalidOperationException($"Failed resolving {controllerType.FullName}. {ex.Message}", ex); } }
public void AllControllersCanBeCreated() { // Arrange var sut = new CommerceControllerActivator( configuration: new CommerceConfiguration( connectionString: "Some random non-empty value.", productRepositoryTypeName: typeof(SqlProductRepository).GetTypeInfo().AssemblyQualifiedName)); foreach (Type controllerType in GetApplicationControllerTypes()) { // Act Controller controller = CreateController(sut, controllerType); // Assert Assert.True(controller != null, $"Failed resolving {controllerType.FullName}. Create() returned null."); Assert.IsType(controllerType, controller); } }