コード例 #1
0
        void RegisterTransientDifferentContractAndImplementationWithDependencyCreator_ReturnsTwoDifferentObjectsForTwoResolutions()
        {
            var container = new ExtendedSimpleContainerAdapter();

            container.RegisterTransient <ITestDependency, TestDependencyA>(() => new TestDependencyA());

            var firstResolution  = container.Resolve <ITestDependency>();
            var secondResolution = container.Resolve <ITestDependency>();

            firstResolution.Should().NotBeSameAs(secondResolution);
        }
コード例 #2
0
        void RegisterTransientExplicitTypesWithDependencyCreator_ReturnsTwoDifferentObjectsForTwoResolutions()
        {
            var container = new ExtendedSimpleContainerAdapter();

            container.RegisterTransient(typeof(ITestDependency), typeof(TestDependencyA), () => new TestDependencyA());

            var firstResolution  = container.Resolve <ITestDependency>();
            var secondResolution = container.Resolve <ITestDependency>();

            firstResolution.Should().NotBeSameAs(secondResolution);
        }