Exemple #1
0
        public void CompositionRoot_ShouldBeAbleToBuildAllRootTypes()
        {
            // Arrange
            NinjectWebCommon.Start();
            AutoMapConfig.RegisterMappings();

            var writer      = new HtmlTextWriter(TextWriter.Null);
            var req         = new HttpRequest("/asd.png", "http://localhost/asd.png", "");
            var res         = new HttpResponse(writer);
            var httpContext = new HttpContext(req, res);

            HttpContext.Current = httpContext;

            var owinEnv = new Dictionary <string, object>
            {
                { $"{IdentityOwinPrefix}{typeof(IApplicationUserManager).AssemblyQualifiedName}", new Mock <IApplicationUserManager>().Object },
                { $"{IdentityOwinPrefix}{typeof(IApplicationSignInManager).AssemblyQualifiedName}", new Mock <IApplicationSignInManager>().Object }
            };

            httpContext.Items[OwinEnvironmentKey] = owinEnv;

            var mvcAssembly = typeof(HomeController).Assembly;
            var rootTypes   = mvcAssembly.GetExportedTypes()
                              .Where(type => typeof(IController).IsAssignableFrom(type) || typeof(IHub).IsAssignableFrom(type))
                              .Where(type => !type.IsAbstract && !type.IsGenericTypeDefinition)
                              .Where(type => type.Name.EndsWith("Controller") || type.Name.EndsWith("Hub"));

            // Act & Assert
            foreach (var type in rootTypes)
            {
                Assert.DoesNotThrow(() => NinjectWebCommon.Kernel.Get(type));
            }
        }
Exemple #2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     NinjectWebCommon.Start();
     Database.SetInitializer <EFDbContext>(null);
     ModelBinders.Binders.Add(typeof(Cart), new CartModelBinder());
 }
Exemple #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            NinjectWebCommon.Start();
        }
Exemple #4
0
        public void SetupControllerBase()
        {
            NinjectWebCommon.Start();
            MappingConfiguration.Start();

            var config = GlobalConfiguration.Configuration.DependencyResolver;

            Controller = (T)Convert.ChangeType(config.GetService(typeof(T)), typeof(T));

            if (Controller == null)
            {
                return;
            }

            Controller.Request = new HttpRequestMessage();
            Controller.Request.SetConfiguration(new HttpConfiguration());
        }
Exemple #5
0
 public static void Start()
 {
     NinjectWebCommon.Start(new DataModule());
 }
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     NinjectWebCommon.Start();
 }
 public static void ClassStartKernel(TestContext context)
 {
     NinjectWebCommon.Start();
     Utils.GetAgencyData();
 }
Exemple #8
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     AutoMapperConfig.RegisterMappings();
     NinjectWebCommon.Start();
 }
Exemple #9
0
 public Form1()
 {
     InitializeComponent();
     NinjectWebCommon.Start();
 }
 public static void ClassStartKernel(TestContext context)
 {
     AnalyzeSelectedAssemblies();
     NinjectWebCommon.Start();
 }
 public static void ClassStartKernel(TestContext context)
 {
     NinjectWebCommon.Start();
 }