public void TryGetInstance_NoServiceFound_ReturnsFalseAndNull()
        {
            var autofacContainerBuilder = new ContainerBuilder();

            var container = new AutofacDiContainer(autofacContainerBuilder.Build());

            new DiContainerTestHelper().TryGetInstance_NoServiceFound_ReturnsFalseAndNull <ITestService>(container);
        }
        public void GetInstances_NoServicesFound_ReturnsEmptyArray()
        {
            var autofacContainerBuilder = new ContainerBuilder();

            var container = new AutofacDiContainer(autofacContainerBuilder.Build());

            new DiContainerTestHelper().GetInstances_NoServicesFound_ReturnsEmptyArray <ITestService>(container);
        }
        public void GetInstanceTestThrowsException()
        {
            var autofacContainerBuilder = new ContainerBuilder();

            var container = new AutofacDiContainer(autofacContainerBuilder.Build());

            new DiContainerTestHelper().TestGetInstanceThrowsException <ITestService>(container);
        }
        public void TryGetInstance_ServiceFound_ReturnsTrueAndInstance()
        {
            var autofacContainerBuilder = new ContainerBuilder();

            autofacContainerBuilder.RegisterType <TestService2>().As <ITestService>();
            var container = new AutofacDiContainer(autofacContainerBuilder.Build());

            new DiContainerTestHelper().TryGetInstance_ServiceFound_ReturnsTrueAndInstance <ITestService>(container);
        }
        public void CreateScopeTest()
        {
            var autofacContainerBuilder = new ContainerBuilder();

            autofacContainerBuilder.RegisterType <TestServiceWithNoCtorParam>().As <ITestService>().InstancePerLifetimeScope();
            var container = new AutofacDiContainer(autofacContainerBuilder.Build());

            new DiContainerTestHelper().TestCreateScope <ITestService, TestServiceWithNoCtorParam>(container);

            new DiContainerTestHelper().TestScopeDisposeDouble(container);
        }
        public void GetInstanceTest()
        {
            var autofacContainerBuilder = new ContainerBuilder();

            autofacContainerBuilder.RegisterType <TestServiceWithNoCtorParam>().As <ITestService>();
            autofacContainerBuilder.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource());

            var container = new AutofacDiContainer(autofacContainerBuilder.Build());

            new DiContainerTestHelper().TestGetInstance <ITestService, TestServiceWithNoCtorParam>(container);
        }
        public void GetInstancesTest()
        {
            var _ = new[] { typeof(TestServiceWithNoCtorParam).Assembly };

            var autofacContainerBuilder = new ContainerBuilder();

            autofacContainerBuilder.RegisterType <TestService2>().As <ITestService>();
            autofacContainerBuilder.RegisterType <TestServiceWithNoCtorParam>().As <ITestService>();

            var container = new AutofacDiContainer(autofacContainerBuilder.Build());

            new DiContainerTestHelper().TestGetInstances <ITestService>(container, typeof(TestService2), typeof(TestServiceWithNoCtorParam));
        }
        public void CtorTest()
        {
            Assert.Throws <ArgumentNullException>(() => new AutofacDiContainer(null));

            var _ = new AutofacDiContainer(new ContainerBuilder().Build());
        }