LoadFromBaseDirectory() public method

Loads a dependency map using the assemblies located in the base application directory.
public LoadFromBaseDirectory ( string filePattern ) : DependencyMap
filePattern string The search pattern that describes which assemblies will be loaded.
return DependencyMap
示例#1
0
        public void ShouldBeAbleToLoadSampleAssemblyWithoutRunningIntoConstructorNotFoundException()
        {
            var loader = new DependencyMapLoader();
            var map = loader.LoadFromBaseDirectory("SampleAssembly.dll");

            var container = map.CreateContainer();
            var result = container.GetInstance<object>("Sample");

            Assert.AreEqual(42, result);
        }
示例#2
0
        public void ShouldBeAbleToGetAServiceThatImplementsSimpleProperties()
        {
            var loader = new DependencyMapLoader();
            var map = loader.LoadFromBaseDirectory("SampleAssembly.dll");
            //var map = new DependencyMap();
            //map.AddService<IFalseDependency>(x=>new SampleFalseDependency());
            var container = map.CreateContainer();
            var result = container.GetInstance<IFalseDependency>();

            Assert.IsNotNull(result,"The container did not create IFalseDependency instance");
        }
示例#3
0
        public void ShouldBeAbleToAutomaticallyInjectBaseGenericInterfaceTypes()
        {
            var loader = new DependencyMapLoader();
            var map = loader.LoadFromBaseDirectory("Sample*.dll");
            map.AddService<IFoo<int>, SampleGenericImplementation>();

            var dependencies = map.Dependencies;

            var container = map.CreateContainer();
            Assert.IsTrue(container.Contains(typeof(IBaz<int>), "SampleGenericImplementation"));
            Assert.IsTrue(container.Contains(typeof(IFoo<int>), "SampleGenericImplementation"));
        }
示例#4
0
        public void ShouldLoadAndCreateContainerFromBaseDirectory()
        {
            var loader = new DependencyMapLoader();

            var map = loader.LoadFromBaseDirectory("*.UnitTests.dll");
            var container = map.CreateContainer();

            Assert.IsNotNull(container);

            var vehicle = container.GetInstance<IVehicle>();
            Assert.IsNotNull(vehicle);
        }
示例#5
0
        public void ShouldReturnNullWhenTryingToInstantiateAnIncompleteDependency()
        {
            var loader = new DependencyMapLoader();
            var map = loader.LoadFromBaseDirectory("SampleAssembly.dll");

            var container = map.CreateContainer();
            var result = container.GetInstance<IMissing>();

            Assert.IsNull(result,"The container created an incomplete instance");
        }