예제 #1
0
        public void WithFailDependencyContainer_ThrowsDependencyContainerRegistrationException()
        {
            var container = new DependencyContainer();

            Assert.Throws <DependencyContainerRegistrationException>(() =>
                                                                     container.AutoRegister(DependencyContainerDuplicateImplementationActions.Fail));
        }
예제 #2
0
        public void WithAssemblies_ResolvesIAnimal()
        {
            var container = new DependencyContainer();

            container.AutoRegister(Runtime.GetAssemblies());

            Assert.IsTrue(container.CanResolve <ICar>());
        }
예제 #3
0
        public void WithAssembliesAndRegisterMultiple_ResolvesICar()
        {
            var container = new DependencyContainer();

            container.AutoRegister(
                Runtime.GetAssemblies(),
                DependencyContainerDuplicateImplementationActions.RegisterMultiple);

            Assert.IsTrue(container.CanResolve <ICar>());
        }
예제 #4
0
        public void WithNoParams_ThrowsDependencyContainerResolutionException()
        {
            Assert.Throws <DependencyContainerResolutionException>(() =>
            {
                var container = new DependencyContainer();
                container.AutoRegister();

                Assert.IsTrue(container.CanResolve <ICar>());
                Assert.AreEqual(new TheOnlyCar().Name, DependencyContainer.Current.Resolve <ICar>().Name);
            });
        }
예제 #5
0
        public void WithAssembliesAndFunc_ResolvesICar()
        {
            var container = new DependencyContainer();

            container.AutoRegister(
                AppDomain.CurrentDomain.GetAssemblies(),
                DependencyContainerDuplicateImplementationAction.RegisterSingle,
                param => true);

            Assert.IsTrue(container.CanResolve <ICar>());
        }