csharp 77C4F87E-0A95-47CD-BE79-9A7415340364

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 77C4F87E-0A95-47CD-BE79-9A7415340364相关的知识,希望对你有一定的参考价值。

using System.Collections.Generic;
using NUnit.Framework;

namespace Zenject.Tests.BindFeatures
{
    [TestFixture]
    public class TestMultipleContractTypes : ZenjectUnitTestFixture
    {
        public class A
        { }

        public class AA : A
        { }

        public class BA : A
        { }

        public class Test1
        {
            public List<A> tests;

            [Inject]
            public void Construct(List<A> tests)
            {
                this.tests = tests;
            }
        }

        public class Test2
        {
            [Inject] public List<A> tests = null;
        }

        public class Test3
        {
            [Inject] public A tests = null;
        }

        [Test]
        public void Test_multiple_bind()
        {
            Container.Bind<A>().To<AA>().AsSingle().NonLazy();
            Container.Bind<A>().To<BA>().AsSingle().NonLazy();
            Container.Bind<Test1>().AsSingle().NonLazy();

            var test1 = Container.Resolve<Test1>();

            Assert.That(test1.tests.Count == 2);
        }

        [Test]
        public void Test_multiple_bind_list_injection()
        {
            Container.Bind<A>().To<AA>().AsSingle().NonLazy();
            Container.Bind<A>().To<BA>().AsSingle().NonLazy();
            Container.Bind<Test2>().AsSingle().NonLazy();

            var test = Container.Resolve<Test2>();
            Assert.That(test.tests.Count == 2);
        }

        [Test]
        [ExpectedException]
        public void Test_multiple_bind_single_injection()
        {
            Container.Bind<A>().To<AA>().AsSingle().NonLazy();
            Container.Bind<A>().To<BA>().AsSingle().NonLazy();
            Container.Bind<Test3>().AsSingle().NonLazy();

            Container.Resolve<Test3>();
        }
    }
}

以上是关于csharp 77C4F87E-0A95-47CD-BE79-9A7415340364的主要内容,如果未能解决你的问题,请参考以下文章

csharp 431CAA3C-9F87-44B9-BB45-085F62ECFD81

构造字典

『中级篇』docker之CI/CD持续集成-(终结篇)(77)

csharp 摆弄Tridion CD分类法......

csharp 摆弄Tridion CD分类法......

ZetaWare.Genesis.v5.41.KINEX.v4.77.Trinity.v3.51.Trinity.3D.v3.51.ZetaLog.v3.2 5CD