Example #1
0
        public void TestAddingMethodResolvers()
        {
            var ctx = new StandardEvaluationContext();

            // reflective method accessor is the only one by default
            var methodResolvers = ctx.MethodResolvers;

            Assert.Single(methodResolvers);

            var dummy = new DummyMethodResolver();

            ctx.AddMethodResolver(dummy);
            Assert.Equal(2, ctx.MethodResolvers.Count);

            var copy = new List <IMethodResolver>(ctx.MethodResolvers);

            Assert.True(ctx.RemoveMethodResolver(dummy));
            Assert.False(ctx.RemoveMethodResolver(dummy));
            Assert.Single(ctx.MethodResolvers);

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