public void TestCircularProtection2()
        {
            var conf = new AutoModuleConfiguration(ApplicationContext.Instance.ScanComponents("Archimedes.*"));
            var container = new ElderBox(conf);

            container.Resolve<ServiceY2>();
        }
        public override object CreateInstance(ElderBox ctx, ISet<Type> unresolvedDependencies, object[] providedParameters = null)
        {
            var factoryInstance = ctx.Resolve(_factoryMethodReference.FactoryImplementation);

            var parameters = ctx.AutowireParameters(null, _factoryMethodReference.Method.GetParameters(), unresolvedDependencies, providedParameters);

            return _factoryMethodReference.Method.Invoke(factoryInstance, parameters);
        }
        public void TestPostConstructAttr1()
        {
            var container = new ElderBox();

            var instance = container.Create<ServiceWithInitialisation>();

            Assert.AreEqual("PostConstruct", instance.Value);
        }
Example #4
0
        public void TestSimpleInstanceWiring()
        {
            var context = new ElderBox(GetConfiguration());

            context.Autowire(this);

            Assert.IsNotNull(_serviceA, "Failed to autowire instance!");
            Assert.IsNotNull(_serviceB, "Failed to autowire instance!");
        }
        public void TestSingletonBehaviour1()
        {
            var context = new ElderBox(GetConfiguration());

            var instance1 = context.Resolve<ServiceSingletonA>();
            var instance2 = context.Resolve<ServiceSingletonB>();

            long actualInstances = Interlocked.Read(ref _instanceCount);
            Assert.AreEqual(1, actualInstances, "Must only create a single instance!");
        }
        protected ApplicationContext()
        {
            _container = new ElderBox();

            var textArt = string.Format(@"
                    _     _                    _           
     /\            | |   (_)                  | |          
    /  \   _ __ ___| |__  _ _ __ ___   ___  __| | ___  ___ 
   / /\ \ | '__/ __| '_ \| | '_ ` _ \ / _ \/ _` |/ _ \/ __|
  / ____ \| | | (__| | | | | | | | | |  __/ (_| |  __/\__ \
 /_/    \_\_|  \___|_| |_|_|_| |_| |_|\___|\__,_|\___||___/
            v{0}                                               
                                                           ", typeof(ApplicationContext).Assembly.GetName().Version);

            Log.Info("Starting Archimedes.Framework ...\n" + textArt);

        }
        public void TestSingletonBehaviour1()
        {
            _instanceCount = 0;
            Assert.AreEqual(0, InstanceCount);

            try
            {
                var context = new ElderBox(GetConfiguration());

                var instance1 = context.Resolve<ServiceAbstractSingletonA>();
                var instance2 = context.Resolve<ServiceAbstractSingletonB>();
                //var instance3 = context.Resolve<ServiceAbstractSingletonImplementation>();



            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }


            Assert.AreEqual(1, InstanceCount, "Must only create a single instance!");
        }
        public void TestConstructorByPassing()
        {
            var context = new ElderBox(GetConfiguration());

            var imp = context.Resolve<ServiceX>();
        }
        public void TestAmbigous()
        {
            var context = new ElderBox(GetConfiguration());

            Assert.Throws<AmbiguousMappingException>(() => context.Resolve<IServiceAmbig>());
        }
 public void TestInterfaceConstructorWiring()
 {
     var context = new ElderBox(GetConfiguration());
     var instance = context.Resolve<ServiceD>();
 }
 public abstract object CreateInstance(ElderBox ctx, ISet<Type> unresolvedDependencies, object[] providedParameters = null);
Example #12
0
        public void TestAmbigous()
        {
            var context = new ElderBox(GetConfiguration());

            var imp = context.Resolve<IServiceAmbig>();
        }
        public void TestCircularProtection()
        {
            var container = new ElderBox(GetConfiguration());

            Assert.Throws<CircularDependencyException>(() => container.Resolve<ServiceY1>());
        }
Example #14
0
 public void TestPrimaryScoped()
 {
     var context = new ElderBox(GetConfiguration());
     var serviceA = context.Resolve<ServiceB>();
 }
Example #15
0
        public void TestSimpleConstructorWiring()
        {
            var context = new ElderBox(GetConfiguration());

            var instance = context.Resolve <ServiceC>();
        }
Example #16
0
 public void TestPrimaryScoped()
 {
     var context  = new ElderBox(GetConfiguration());
     var serviceA = context.Resolve <ServiceB>();
 }