コード例 #1
0
 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);
     }
 }
コード例 #2
0
        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);
            }
        }