• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TestClassDefaultCtor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Resolve_NamedFactoryRegistrationFollowedByNormal_CanResolveNamed

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

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

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


示例17: ChildContainerResolve_TypeRegisteredWithParentAndChild_ResolvesChildVersion

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

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

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


示例18: RegisterNonGeneric_BasicTypeAndInstance_RegistersAndCanResolve

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

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

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


示例19: ResolveAll_ChildContainerRegistrationOverridesParentContainerRegistration_ReturnsChildRegistrations

        public void ResolveAll_ChildContainerRegistrationOverridesParentContainerRegistration_ReturnsChildRegistrations()
        {
            var parentContainer = UtilityMethods.GetContainer();
            var childContainer = parentContainer.GetChildContainer();
            var parentInstance = new TestClassDefaultCtor();
            var childInstance = new TestClassDefaultCtor();
            parentContainer.Register<ITestInterface>(parentInstance, "1");
            childContainer.Register<ITestInterface>(childInstance, "1");

            var result = childContainer.ResolveAll<ITestInterface>();

            Assert.AreEqual(1, result.Count());
            Assert.AreSame(childInstance, result.Single());
        }
开发者ID:bangq,项目名称:TinyIoC,代码行数:14,代码来源:TinyIoCTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TestClassGenerationContext类代码示例发布时间:2022-05-24
下一篇:
C# TestClass类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap