public void ResolveAsIUsersServiceHandler_WithTeacherHiringModule_DependenciesShouldBeResolved() { NinjectDependencyResolver resolver = new NinjectDependencyResolver(kernel); object resolved = resolver.Resolve <IUsersService>(); Assert.IsNotNull(resolved); }
static void Main() { NinjectDependencyResolver.Wire(new ServiceModule()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(NinjectDependencyResolver.Resolve <HomeForm>()); }
public void ResolveAsIAlertDisplayer_WithTeacherHiringModule_DependenciesShouldBeResolved() { NinjectDependencyResolver resolver = new NinjectDependencyResolver(kernel); object resolved = resolver.Resolve <IAlertDisplayer>(); Assert.IsNotNull(resolved); }
public void Unresolveable_Should_Return_Null() { var resolver = new NinjectDependencyResolver(); var result = resolver.Resolve <IFace1>(); Assert.IsNull(result); }
public void Array_Injector_Should_Inject_All_Registed_Types() { var resolver = new NinjectDependencyResolver(); resolver.RegisterType<IFace1, Class1>(); resolver.RegisterType<IFace1, Class2>(); resolver.RegisterInstance<IFace1>(new Class3()); var resolve = resolver.Resolve<Class4>(); Assert.AreEqual(3, resolve.Ifaces.Count()); Assert.IsTrue(resolve.Ifaces.OfType<Class1>().Any()); Assert.IsTrue(resolve.Ifaces.OfType<Class2>().Any()); Assert.IsTrue(resolve.Ifaces.OfType<Class3>().Any()); }
public void Array_Injector_Should_Inject_All_Registed_Types() { var resolver = new NinjectDependencyResolver(); resolver.RegisterType <IFace1, Class1>(); resolver.RegisterType <IFace1, Class2>(); resolver.RegisterInstance <IFace1>(new Class3()); var resolve = resolver.Resolve <Class4>(); Assert.AreEqual(3, resolve.Ifaces.Count()); Assert.IsTrue(resolve.Ifaces.OfType <Class1>().Any()); Assert.IsTrue(resolve.Ifaces.OfType <Class2>().Any()); Assert.IsTrue(resolve.Ifaces.OfType <Class3>().Any()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MapperConfig.Configure(); NinjectDependencyResolver.Resolve(); var config = GlobalConfiguration.Configuration; FluentValidationModelValidatorProvider.Configure(config); config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; }
private static StatelessService ServiceFactory(StatelessServiceContext context) { var kernel = new StandardKernel() .WithBsonIds() .WithActorsClient(); IDependencyResolver resolver = new NinjectDependencyResolver(kernel); kernel.Bind <UsersStreamObserver>().ToSelf().InSingletonScope(); kernel.Bind <IHubConnectionContext <IUserClient> >() .ToMethod(ctx => resolver.Resolve <IConnectionManager>() .GetHubContext <UserHub, IUserClient>().Clients ) .WhenInjectedInto <UsersStreamObserver>(); AppBuilder appBuilder = new DefaultAppBuilder(); appBuilder = new GoogleOAuth2AppDecorator(appBuilder, kernel.Get <IUserManager>()); appBuilder = new CorsAppDecorator(appBuilder); appBuilder = new SignalRAppDecorator(appBuilder, resolver, kernel, new AuthorizedRequestModule()); return(new OwinStatelessService(context, appBuilder, "public")); }
public UserManager() { _userDAL = NinjectDependencyResolver.Resolve <IUserDAL>(); }
public ProductManager() { _productDAL = NinjectDependencyResolver.Resolve <IProductDAL>(); }
public void Unresolveable_Should_Return_Null() { var resolver = new NinjectDependencyResolver(); var result = resolver.Resolve<IFace1>(); Assert.IsNull(result); }