Example #1
0
        public void Can_Resolve_Unbound_Generics()
        {
            var ioc = new IocContainer();

            ioc.AddTransient <ILogger, Logger>();
            ioc.AddTransient(typeof(IRepository <>), typeof(Repository <>));

            var repo = ioc.Resolve <IRepository <Customer> >();

            Assert.AreEqual(typeof(Repository <Customer>), repo.GetType());
        }
Example #2
0
        public void Can_Resolve_Type_With_Parameters()
        {
            var ioc = new IocContainer();

            ioc.AddTransient <ILogger, Logger>();
            ioc.AddTransient <IRepository <Customer>, Repository <Customer> >();

            var repo = ioc.Resolve <IRepository <Customer> >();

            Assert.AreEqual(typeof(Repository <Customer>), repo.GetType());
        }
Example #3
0
        public void Can_Resolve_Type()
        {
            var ioc = new IocContainer();

            ioc.AddTransient <ILogger, Logger>();

            var logger = ioc.Resolve <ILogger>();

            Assert.AreEqual(typeof(Logger), logger.GetType());
        }
Example #4
0
 private void ConfigureServices()
 {
     container.AddTransient <IWriter, ConsoleWriter>();
     container.AddTransient <IReader, ConsoleReader>();
     container.AddSingleton <ILogger, Logger.Logger>((Logger.Logger)GetLogger());
 }