Exemplo n.º 1
0
        public void GivenAnyCondition_ActiveByIndex_MustBeActived()
        {
            var prov = new NullIProposalProvider();
            var f    = new ValueServiceScopeFactory
            {
                Factory = new Dictionary <Type, Func <object> >
                {
                    [typeof(NullIProposalProvider)] = () => prov
                }
            };
            var eng = new ProposalEngine(f);

            eng.Add(new NullProposalDescription
            {
                DescritionUri = new Uri("http://localhost:4200"),
                Name          = "any",
                ProviderType  = typeof(NullIProposalProvider)
            });
            Assert.AreEqual(1, eng.Count);
            var obj = eng.Active(0);

            Assert.IsNotNull(obj.Provider);
            Assert.AreEqual(prov, obj.Provider);
            obj.Dispose();
        }
Exemplo n.º 2
0
        public void ActiveType_TypeMustActived()
        {
            var prov = new NullIProposalProvider();
            var f    = new ValueServiceScopeFactory
            {
                Factory = new Dictionary <Type, Func <object> >
                {
                    [typeof(NullIProposalProvider)] = () => prov
                }
            };
            var eng = new ProposalEngine(f);

            Assert.AreEqual(f, eng.ServiceScopeFactory);
            var obj = eng.Active(typeof(NullIProposalProvider));

            Assert.IsNotNull(obj.Provider);
            Assert.IsNotNull(obj.Scope);
            Assert.AreEqual(prov, obj.Provider);
            obj.Dispose();
        }
Exemplo n.º 3
0
        public void GivenAnyCondition_ActiveOutOfRang_MustThrowException(int count, int index)
        {
            var prov = new NullIProposalProvider();
            var f    = new ValueServiceScopeFactory
            {
                Factory = new Dictionary <Type, Func <object> >
                {
                    [typeof(NullIProposalProvider)] = () => prov
                }
            };
            var eng = new ProposalEngine(f);

            for (int i = 0; i < count; i++)
            {
                eng.Add(new NullProposalDescription
                {
                    DescritionUri = new Uri("http://localhost:420" + i),
                    Name          = "any" + i,
                    ProviderType  = typeof(NullIProposalProvider)
                });
            }
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => eng.Active(index));
        }