当前位置: 首页>>代码示例>>C#>>正文


C# TestClassDefaultCtor类代码示例

本文整理汇总了C#中TestClassDefaultCtor的典型用法代码示例。如果您正苦于以下问题:C# TestClassDefaultCtor类的具体用法?C# TestClassDefaultCtor怎么用?C# TestClassDefaultCtor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestClassDefaultCtor类属于命名空间,在下文中一共展示了TestClassDefaultCtor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Resolve_RegisteredInstanceWithFluentMultiInstanceCall_ReturnsMultipleInstance

        public void Resolve_RegisteredInstanceWithFluentMultiInstanceCall_ReturnsMultipleInstance()
        {
            var container = UtilityMethods.GetContainer();
            var input = new TestClassDefaultCtor();
            container.Register<TestClassDefaultCtor>(input).AsMultiInstance();

            var result = container.Resolve<TestClassDefaultCtor>();

            Assert.IsFalse(object.ReferenceEquals(result, input));
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:10,代码来源:TinyIoCTests.cs

示例2: BuildUp_ObjectWithPropertyDependenciesWithSomeSet_SetsOnlyUnsetDependencies

        public void BuildUp_ObjectWithPropertyDependenciesWithSomeSet_SetsOnlyUnsetDependencies()
        {
            var container = UtilityMethods.GetContainer();
            container.Register<ITestInterface, TestClassDefaultCtor>();
            container.Register<ITestInterface2, TestClass2>();
            var preset = new TestClassDefaultCtor();
            var input = new TestClassPropertyDependencies();
            input.Property1 = preset;

            container.BuildUp(input);

            Assert.ReferenceEquals(preset, input.Property1);
            Assert.IsNotNull(input.Property2);
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:14,代码来源:TinyIoCTests.cs

示例3: Resolve_NormalInstanceRegistrationFollowedByNamed_CanResolveNormal

        public void Resolve_NormalInstanceRegistrationFollowedByNamed_CanResolveNormal()
        {
            var container = UtilityMethods.GetContainer();
            var instance1 = new TestClassDefaultCtor();
            var instance2 = new TestClassDefaultCtor();
            container.Register<TestClassDefaultCtor>(instance1);
            container.Register<TestClassDefaultCtor>(instance2, "TestName");

            var result = container.Resolve<TestClassDefaultCtor>();

            Assert.ReferenceEquals(instance1, result);
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:12,代码来源:TinyIoCTests.cs

示例4: TestClassDefaultCtor

        public void Resolve_NotAlreadyResolvedSingletonTypeInParentContainerButDependencyInChildContainer_GetsDependencyFromParent()
        {
            var container = UtilityMethods.GetContainer();
            container.Register<ITestInterface2, TestClassWithInterfaceDependency>().AsSingleton();
            var parentInstance = new TestClassDefaultCtor();
            container.Register<ITestInterface>(parentInstance);
            var child = container.GetChildContainer();
            var childInstance = new TestClassDefaultCtor();
            child.Register<ITestInterface>(childInstance);

            var result = child.Resolve<ITestInterface2>() as TestClassWithInterfaceDependency;

            Assert.IsTrue(object.ReferenceEquals(result.Dependency, parentInstance));
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:14,代码来源:TinyIoCTests.cs

示例5: NamedLazyFactory_CalledByDependantClass_ReturnsCorrectInstanceOfType

        public void NamedLazyFactory_CalledByDependantClass_ReturnsCorrectInstanceOfType()
        {
            var container = UtilityMethods.GetContainer();
            var item1 = new TestClassDefaultCtor();
            var item2 = new TestClassDefaultCtor();
            container.Register<TestClassDefaultCtor>(item1, "Testing");
            container.Register<TestClassDefaultCtor>(item2);
            container.Register<TestClassWithNamedLazyFactory>();

            var item = container.Resolve<TestClassWithNamedLazyFactory>();

            item.Method1();
            item.Method2();

            Assert.ReferenceEquals(item.Prop1, item1);
            Assert.ReferenceEquals(item.Prop2, item2);
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:17,代码来源:TinyIoCTests.cs

示例6: Resolved_InterfaceAndImplementationWithInstance_ReturnsCorrectInstance

        public void Resolved_InterfaceAndImplementationWithInstance_ReturnsCorrectInstance()
        {
            var container = UtilityMethods.GetContainer();
            var item = new TestClassDefaultCtor();
            container.Register<ITestInterface, TestClassDefaultCtor>(item);

            var result = container.Resolve<ITestInterface>();

            Assert.AreSame(item, result);
        }
开发者ID:chenzuo,项目名称:TinyIoC,代码行数:10,代码来源:TinyIoCTests.cs

示例7: ChildContainerResolve_NamedOnlyRegisteredWithParent_ResolvesFromParent

        public void ChildContainerResolve_NamedOnlyRegisteredWithParent_ResolvesFromParent()
        {
            var container = UtilityMethods.GetContainer();
            var containerInstance = new TestClassDefaultCtor();
            var child = container.GetChildContainer();
            var childInstance = new TestClassDefaultCtor();
            container.Register<ITestInterface>(containerInstance, "Testing");
            child.Register<ITestInterface>(childInstance);

            var result = child.Resolve<ITestInterface>("Testing");

            Assert.ReferenceEquals(result, containerInstance);
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:13,代码来源:TinyIoCTests.cs

示例8: Register_NamedInstanceRegistration_CanRegister

        public void Register_NamedInstanceRegistration_CanRegister()
        {
            var container = UtilityMethods.GetContainer();
            var item = new TestClassDefaultCtor();

            container.Register<TestClassDefaultCtor>(item, "TestName");
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:7,代码来源:TinyIoCTests.cs

示例9: Resolve_ContainerHierarchy_ResolvesCorrectlyUsingHierarchy

        public void Resolve_ContainerHierarchy_ResolvesCorrectlyUsingHierarchy()
        {
            var rootContainer = UtilityMethods.GetContainer();
            var firstChildContainer = rootContainer.GetChildContainer();
            var secondChildContainer = firstChildContainer.GetChildContainer();
            var rootInstance = new TestClassDefaultCtor();
            var firstChildInstance = new TestClassDefaultCtor();
            var secondChildInstance = new TestClassDefaultCtor();
            rootContainer.Register<ITestInterface2, TestClassWithInterfaceDependency>().AsMultiInstance();
            rootContainer.Register<ITestInterface>(rootInstance);
            firstChildContainer.Register<ITestInterface>(firstChildInstance);
            secondChildContainer.Register<ITestInterface>(secondChildInstance);
            rootContainer.Resolve<ITestInterface2>();

            var result = secondChildContainer.Resolve<ITestInterface2>() as TestClassWithInterfaceDependency;

            Assert.IsTrue(object.ReferenceEquals(result.Dependency, secondChildInstance));
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:18,代码来源:TinyIoCTests.cs

示例10: Register_InterfaceAndImplementationWithInstance_Registers

 public void Register_InterfaceAndImplementationWithInstance_Registers()
 {
     var container = UtilityMethods.GetContainer();
     var item = new TestClassDefaultCtor();
     container.Register<ITestInterface, TestClassDefaultCtor>(item);
 }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:6,代码来源:TinyIoCTests.cs

示例11: RegisterNonGeneric_TypeImplementingInterfaceInstanceAndName_RegistersAndCanResolve

        public void RegisterNonGeneric_TypeImplementingInterfaceInstanceAndName_RegistersAndCanResolve()
        {
            var container = UtilityMethods.GetContainer();
            var instance = new TestClassDefaultCtor();

            container.Register(typeof(ITestInterface), typeof(TestClassDefaultCtor), instance, "TestClass");
            var result = container.Resolve<ITestInterface>("TestClass", ResolveOptions.FailUnregisteredAndNameNotFound);

            Assert.IsInstanceOfType(result, typeof(ITestInterface));
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:10,代码来源:TinyIoCTests.cs

示例12: Resolve_NamedInstanceRegistrationFollowedByNormal_CanResolveNamed

        public void Resolve_NamedInstanceRegistrationFollowedByNormal_CanResolveNamed()
        {
            var container = UtilityMethods.GetContainer();
            var instance1 = new TestClassDefaultCtor();
            var instance2 = new TestClassDefaultCtor();
            container.Register<TestClassDefaultCtor>(instance1, "TestName");
            container.Register<TestClassDefaultCtor>(instance2);

            var result = container.Resolve<TestClassDefaultCtor>("TestName");

            Assert.AreSame(instance1, result);
        }
开发者ID:chenzuo,项目名称:TinyIoC,代码行数:12,代码来源:TinyIoCTests.cs

示例13: ChildContainerCanResolve_NamedOnlyRegisteredWithParent_ReturnsTrue

        public void ChildContainerCanResolve_NamedOnlyRegisteredWithParent_ReturnsTrue()
        {
            var container = UtilityMethods.GetContainer();
            var containerInstance = new TestClassDefaultCtor();
            var child = container.GetChildContainer();
            var childInstance = new TestClassDefaultCtor();
            container.Register<ITestInterface>(containerInstance, "Testing");
            child.Register<ITestInterface>(childInstance);

            var result = child.CanResolve<ITestInterface>("Testing");

            Assert.IsTrue(result);
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:13,代码来源:TinyIoCTests.cs

示例14: Resolve_InterfaceAndImplementationNamedWithInstance_ReturnsCorrectInstance

        public void Resolve_InterfaceAndImplementationNamedWithInstance_ReturnsCorrectInstance()
        {
            var container = UtilityMethods.GetContainer();
            var item = new TestClassDefaultCtor();
            var item2 = new TestClassDefaultCtor();
            container.Register<ITestInterface, TestClassDefaultCtor>(item, "TestName");
            container.Register<ITestInterface, TestClassDefaultCtor>(item2);

            var result = container.Resolve<ITestInterface>("TestName");

            Assert.ReferenceEquals(item, result);
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:12,代码来源:TinyIoCTests.cs

示例15: ChildContainerResolve_NamedOnlyRegisteredWithParentUnnamedFallbackOn_ResolvesFromChild

        public void ChildContainerResolve_NamedOnlyRegisteredWithParentUnnamedFallbackOn_ResolvesFromChild()
        {
            var container = UtilityMethods.GetContainer();
            var containerInstance = new TestClassDefaultCtor();
            var child = container.GetChildContainer();
            var childInstance = new TestClassDefaultCtor();
            container.Register<ITestInterface>(containerInstance, "Testing");
            child.Register<ITestInterface>(childInstance);

            var result = child.Resolve<ITestInterface>("Testing", new ResolveOptions() { NamedResolutionFailureAction = NamedResolutionFailureActions.AttemptUnnamedResolution });

            Assert.ReferenceEquals(result, childInstance);
        }
开发者ID:kvervo,项目名称:TinyIoC,代码行数:13,代码来源:TinyIoCTests.cs


注:本文中的TestClassDefaultCtor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。