public void ServiceModule_Load() { //Arrange var kernel = new Mock <IKernel>(); kernel.SetupGet(k => k.Settings).Returns(new Mock <INinjectSettings>().Object); //Act var bindings = new ServiceBindings(); bindings.OnLoad(kernel.Object); //Asset Assert.Pass(); }
/// <summary> /// 创建指定服务对象 /// </summary> /// <typeparam name="T">服务类型</typeparam> /// <returns></returns> public T CreateService <T>() { var type = typeof(T); if (!ServiceBindings.ContainsKey(type)) { return(default(T)); } type = ServiceBindings[type] as Type; if (type == null) { return(default(T)); } return((T)Activator.CreateInstance(type)); }