public void Register_AssemblyWithFunc_CallsAssemblyScanner()
 {
     var scannerMock = new AssemblyScannerMock();
     var serviceContainer = new ServiceContainer();
     serviceContainer.AssemblyScanner = scannerMock;
     serviceContainer.RegisterAssembly(typeof(IFoo).Assembly, (s,t) => true);
     scannerMock.Assert(a => a.Scan(typeof(IFoo).Assembly, The<IServiceRegistry>.IsAnyValue, The<Func<ILifetime>>.IsAnyValue, The<Func<Type, Type, bool>>.IsAnyValue), Invoked.Once);
 }
        public void Register_AssemblyWithFuncAndLifeCycle_CallsAssemblyScanner()
        {
            var scannerMock      = new AssemblyScannerMock();
            var serviceContainer = new ServiceContainer();

            serviceContainer.AssemblyScanner = scannerMock;
            serviceContainer.RegisterAssembly(typeof(IFoo).GetTypeInfo().Assembly, () => new PerContainerLifetime(), (s, t) => true);
            scannerMock.Assert(a => a.Scan(typeof(IFoo).GetTypeInfo().Assembly, The <IServiceRegistry> .IsAnyValue, The <Func <ILifetime> > .IsAnyValue, The <Func <Type, Type, bool> > .IsAnyValue), Invoked.Once);
        }
示例#3
0
        public void Register_SearchPattern_CallsAssemblyScanner()
        {
            var mockContext      = new MockContext <IAssemblyScanner>();
            var scannerMock      = new AssemblyScannerMock(mockContext);
            var serviceContainer = new ServiceContainer();

            serviceContainer.AssemblyScanner = scannerMock;
            serviceContainer.RegisterAssembly("LightInject.SampleLibrary.dll");
            mockContext.Assert(a => a.Scan(typeof(IFoo).Assembly, The <IServiceRegistry> .IsAnyValue, The <Func <ILifetime> > .IsAnyValue, The <Func <Type, Type, bool> > .IsAnyValue), Invoked.Once);
        }
示例#4
0
        public void Register_Assembly_CallsAssemblyScanner()
        {
            var mockContext      = new MockContext <IAssemblyScanner>();
            var scannerMock      = new AssemblyScannerMock(mockContext);
            var serviceContainer = new ServiceContainer();

            serviceContainer.AssemblyScanner = scannerMock;
            serviceContainer.RegisterAssembly(typeof(IFoo).Assembly);
            mockContext.Assert(a => a.Scan(typeof(IFoo).Assembly, The <IServiceRegistry> .IsAnyValue, The <Func <ILifetime> > .IsAnyValue, The <Func <Type, Type, bool> > .IsAnyValue), Invoked.Once);
        }
示例#5
0
        public void Register_AssemblyFileWithoutCompositionRoot_CallsAssemblyScanner()
        {
            var mockContext      = new MockContext <IAssemblyScanner>();
            var scannerMock      = new AssemblyScannerMock(mockContext);
            var serviceContainer = new ServiceContainer();

            serviceContainer.AssemblyScanner = scannerMock;
            serviceContainer.RegisterAssembly("*SampleLibrary.dll");
            mockContext.Assert(a => a.Scan(typeof(IFoo).Assembly, The <IServiceRegistry> .IsAnyValue, The <Func <ILifetime> > .IsAnyValue, The <Func <Type, Type, bool> > .IsAnyValue), Invoked.Once);
        }
        public void Register_SearchPattern_CallsAssemblyScanner()
        {
            var scannerMock                  = new AssemblyScannerMock();
            var serviceContainer             = new ServiceContainer();
            var compositionRootExtractorMock = new TypeExtractorMock();

            compositionRootExtractorMock.Arrange(c => c.Execute(The <Assembly> .IsAnyValue)).Returns(Type.EmptyTypes);
            serviceContainer.CompositionRootTypeExtractor = compositionRootExtractorMock;
            serviceContainer.AssemblyScanner = scannerMock;
            serviceContainer.RegisterAssembly("LightInject.Tests.dll");
            scannerMock.Assert(a => a.Scan(typeof(IFoo).Assembly, The <IServiceRegistry> .IsAnyValue, The <Func <ILifetime> > .IsAnyValue, The <Func <Type, Type, bool> > .IsAnyValue), Invoked.Once);
        }
        public void Register_Assembly_CallsAssemblyScanner()
        {
            var scannerMock = new AssemblyScannerMock();
            var compositionRootExtractorMock = new TypeExtractorMock();
            compositionRootExtractorMock.Arrange(c => c.Execute(The<Assembly>.IsAnyValue)).Returns(Type.EmptyTypes);

            var serviceContainer = new ServiceContainer();
            serviceContainer.CompositionRootTypeExtractor = compositionRootExtractorMock;
            serviceContainer.AssemblyScanner = scannerMock;
            serviceContainer.RegisterAssembly(typeof(IFoo).Assembly);
            scannerMock.Assert(a => a.Scan(typeof(IFoo).Assembly, The<IServiceRegistry>.IsAnyValue, The<Func<ILifetime>>.IsAnyValue, The<Func<Type, Type, bool>>.IsAnyValue), Invoked.Once);
        }
        public void Scan_AssemblyFileWithCompositionRoot_CallsScanMethodMethod()
        {
            var container = new ServiceContainer();
            var compositionRootTypeExtractorMock = new TypeExtractorMock();

            compositionRootTypeExtractorMock.Arrange(t => t.Execute(The <Assembly> .IsAnyValue)).Returns(new [] { typeof(CompositionRootMock) });
            container.CompositionRootTypeExtractor = compositionRootTypeExtractorMock;
            var assemblyScannerMock = new AssemblyScannerMock();

            container.AssemblyScanner = assemblyScannerMock;

            container.RegisterAssembly("LightInject.Tests.dll");
            assemblyScannerMock.Assert(a => a.Scan(The <Assembly> .IsAnyValue, container), Invoked.Once);
        }
        public void Scan_AssemblyFileWithCompositionRoot_CallsScanMethodMethod()
        {
            var container = new ServiceContainer();
            var compositionRootTypeExtractorMock = new TypeExtractorMock();
            compositionRootTypeExtractorMock.Arrange(t => t.Execute(The<Assembly>.IsAnyValue)).Returns(new [] {typeof(CompositionRootMock)});
            container.CompositionRootTypeExtractor = compositionRootTypeExtractorMock;
            var assemblyScannerMock = new AssemblyScannerMock();
            container.AssemblyScanner = assemblyScannerMock;

            container.RegisterAssembly("LightInject.Tests.dll");
            assemblyScannerMock.Assert(a => a.Scan(The<Assembly>.IsAnyValue, container), Invoked.Once);
        }
 public void Register_SearchPattern_CallsAssemblyScanner()
 {
     var mockContext = new MockContext<IAssemblyScanner>();
     var scannerMock = new AssemblyScannerMock(mockContext);            
     var serviceContainer = new ServiceContainer();
     serviceContainer.AssemblyScanner = scannerMock;
     serviceContainer.RegisterAssembly("LightInject.SampleLibrary.dll");
     mockContext.Assert(a => a.Scan(typeof(IFoo).Assembly, The<IServiceRegistry>.IsAnyValue, The<Func<ILifetime>>.IsAnyValue, The<Func<Type, Type, bool>>.IsAnyValue), Invoked.Once);
 }
 public void Register_AssemblyWithFuncAndLifeCycle_CallsAssemblyScanner()
 {
     var mockContext = new MockContext<IAssemblyScanner>();
     var scannerMock = new AssemblyScannerMock(mockContext);
     var serviceContainer = new ServiceContainer();
     serviceContainer.AssemblyScanner = scannerMock;
     serviceContainer.RegisterAssembly(typeof(IFoo).Assembly, () => new PerContainerLifetime(), (s, t) => true);
     mockContext.Assert(a => a.Scan(typeof(IFoo).Assembly, The<IServiceRegistry>.IsAnyValue, The<Func<ILifetime>>.IsAnyValue, The<Func<Type, Type, bool>>.IsAnyValue), Invoked.Once);
 }
        public void Register_AssemblyFileWithoutCompositionRoot_CallsAssemblyScanner()
        {
	        var mockContext = new MockContext<IAssemblyScanner>();
			var scannerMock = new AssemblyScannerMock(mockContext);
            var serviceContainer = new ServiceContainer();
            serviceContainer.AssemblyScanner = scannerMock;
            serviceContainer.RegisterAssembly("*SampleLibrary.dll");
            mockContext.Assert(a => a.Scan(typeof(IFoo).Assembly,The<IServiceRegistry>.IsAnyValue, The<Func<ILifetime>>.IsAnyValue, The<Func<Type, Type, bool>>.IsAnyValue), Invoked.Once);
        }