Пример #1
0
		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);
		}
Пример #2
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 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);
		}
Пример #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);
        }
Пример #8
0
		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);
		}
Пример #9
0
        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);
        }
Пример #10
0
        public void Throws_WhenConstructingUnregisteredType()
        {
            var micro = new MicroConfiguration("Test", null);

            Assert.Throws <MicroResolutionException>(() => micro.Resolve <ITest>());
        }
Пример #11
0
		public void Throws_WhenConstructingUnregisteredType()
		{
			var micro = new MicroConfiguration("Test", null, null);

			Assert.Throws<MicroResolutionException>(() => micro.Resolve<ITest>());
		}