コード例 #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));
            }
        }
コード例 #2
0
ファイル: Global.asax.cs プロジェクト: spotuk/Lab1
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     NinjectWebCommon.Start();
     Database.SetInitializer <EFDbContext>(null);
     ModelBinders.Binders.Add(typeof(Cart), new CartModelBinder());
 }
コード例 #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            NinjectWebCommon.Start();
        }
コード例 #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());
        }
コード例 #5
0
 public static void Start()
 {
     NinjectWebCommon.Start(new DataModule());
 }
コード例 #6
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     NinjectWebCommon.Start();
 }
コード例 #7
0
 public static void ClassStartKernel(TestContext context)
 {
     NinjectWebCommon.Start();
     Utils.GetAgencyData();
 }
コード例 #8
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     AutoMapperConfig.RegisterMappings();
     NinjectWebCommon.Start();
 }
コード例 #9
0
 public Form1()
 {
     InitializeComponent();
     NinjectWebCommon.Start();
 }
コード例 #10
0
 public static void ClassStartKernel(TestContext context)
 {
     AnalyzeSelectedAssemblies();
     NinjectWebCommon.Start();
 }
コード例 #11
0
 public static void ClassStartKernel(TestContext context)
 {
     NinjectWebCommon.Start();
 }