Example #1
0
        public void ResolvesType()
        {
            var micro = new MicroConfiguration("Test", null);

            micro.Register(typeof(ITest), () => new Test(), true);

            var instance = micro.Resolve <ITest>();

            Assert.NotNull(instance);
        }
		public void ResolvesType()
		{
			var micro = new MicroConfiguration("Test", null, null);

			micro.Register(typeof(ITest), () => new Test(), true);

			var instance = micro.Resolve<ITest>();

			Assert.NotNull(instance);
		}
        public void Activator_ResolvesType_WithDependency()
        {
            var micro = new MicroConfiguration("Test", null);

            micro.Register(typeof(ITest), () => new Test(), true);

            var instance = (IDependency)micro.Activate(typeof(TestDependencyParameter), new KeyValuePair <string, object>[] { });

            Assert.NotNull(instance);

            Assert.NotNull(instance.TestInstance);
        }
        public void Activator_ResolvesType_WithDependency_AndParameter()
        {
            var micro = new MicroConfiguration("Test", null);

            micro.Register(typeof(ITest), () => new Test(), true);

            var instance = (IDependency)micro.Activate(typeof(TestDependencyParameterStatic), new[] { new KeyValuePair <string, object>("value", "hello") });

            Assert.NotNull(instance);

            Assert.Equal("hello", ((TestDependencyParameterStatic)instance).Value);
        }
		public void Activator_ResolvesType_WithDependency()
		{
			var micro = new MicroConfiguration("Test", null, null);

			micro.Register(typeof(ITest), () => new Test(), true);

			var instance = (IDependency)micro.Activate(typeof(TestDependencyParameter), new KeyValuePair<string, object>[] { });

			Assert.NotNull(instance);

			Assert.NotNull(instance.TestInstance);
		}
		public void Activator_ResolvesType_WithDependency_AndParameter()
		{
			var micro = new MicroConfiguration("Test", null, null);

			micro.Register(typeof(ITest), () => new Test(), true);

			var instance = (IDependency)micro.Activate(typeof(TestDependencyParameterStatic), new[] { new KeyValuePair<string, object>("value", "hello") });

			Assert.NotNull(instance);

			Assert.Equal("hello", ((TestDependencyParameterStatic)instance).Value);
		}
Example #7
0
        public void ResolvesType_AsSingleton()
        {
            var micro = new MicroConfiguration("Test", null);

            micro.Register(typeof(IInstance), () => new TestInstance(), true);

            var instance = micro.Resolve <IInstance>();

            Assert.NotNull(instance);

            var instance2 = micro.Resolve <IInstance>();

            Assert.Equal(instance.InstanceGuid, instance2.InstanceGuid);
        }
		public void ResolvesType_AsSingleton()
		{
			var micro = new MicroConfiguration("Test", null, null);

			micro.Register(typeof(IInstance), () => new TestInstance(), true);
			
			var instance = micro.Resolve<IInstance>();

			Assert.NotNull(instance);

			var instance2 = micro.Resolve<IInstance>();

			Assert.Equal(instance.InstanceGuid, instance2.InstanceGuid);
		}
        public void Micro_ResolvesType_AsInstance()
        {
            var micro = new MicroConfiguration("Test");

            micro.Register(typeof(IInstance), () => new TestInstance(), false);

            var instance = micro.Resolve <IInstance>();

            Assert.IsNotNull(instance);

            var instance2 = micro.Resolve <IInstance>();

            Assert.AreNotEqual(instance.InstanceGuid, instance2.InstanceGuid);
        }