Ejemplo n.º 1
0
        public void TestAddingConstructorResolvers()
        {
            StandardEvaluationContext ctx = new StandardEvaluationContext();

            // reflective constructor accessor is the only one by default
            List <IConstructorResolver> constructorResolvers = ctx.ConstructorResolvers;

            Assert.Single(constructorResolvers);

            var dummy = new DummyConstructorResolver();

            ctx.AddConstructorResolver(dummy);
            Assert.Equal(2, ctx.ConstructorResolvers.Count);

            var copy = new List <IConstructorResolver>(ctx.ConstructorResolvers);

            Assert.True(ctx.RemoveConstructorResolver(dummy));
            Assert.False(ctx.RemoveConstructorResolver(dummy));
            Assert.Single(ctx.ConstructorResolvers);

            ctx.ConstructorResolvers = copy;
            Assert.Equal(2, ctx.ConstructorResolvers.Count);
        }