public void TestFindActions()
        {
            ReflectorConfiguration.NoValidate = true;

            var config = new ReflectorConfiguration(new Type[] { }, new Type[] { }, new[] { typeof(Customer34).Namespace });

            var classStrategy = new DefaultClassStrategy(config);

            var methods = typeof(Customer34).GetMethods().ToList();
            var actions = facetFactory.FindActions(methods, classStrategy);

            var expectedNames = new List <string> {
                "ActionWithNoParameters",
                "ActionWithOneGoodParameter",
                "ActionWithTwoGoodParameter",
                "ActionWithNullableParameter",
                "ToString",
                "Equals",
                "GetHashCode"
            };

            Assert.AreEqual(expectedNames.Count, actions.Count);

            expectedNames.ForEach(n => Assert.IsTrue(actions.Select(a => a.Name).Contains(n)));
        }
示例#2
0
        public virtual void SetUp()
        {
            var cache         = new ImmutableInMemorySpecCache();
            var config        = new ReflectorConfiguration(new[] { typeof(List <TestPoco>), typeof(ArrayList) }, new Type[] { }, new Type[] { }, new Type[] { }, new[] { typeof(TestPoco).Namespace });
            var menuFactory   = new NullMenuFactory();
            var classStrategy = new DefaultClassStrategy(config);
            var metamodel     = new Metamodel(classStrategy, cache);
            var reflector     = new Reflector(classStrategy, metamodel, config, menuFactory, new IFacetDecorator[] { }, facetFactories);

            Specification = LoadSpecification(reflector);
            Metamodel     = metamodel;
        }
示例#3
0
        public override void SetUp()
        {
            base.SetUp();
            var cache = new ImmutableInMemorySpecCache();
            var reflectorConfiguration = new ReflectorConfiguration(new Type[] { }, new Type[] { }, new Type[] { }, new Type[] { }, new string[] { });

            facetFactory = new RemoveEventHandlerMethodsFacetFactory(0);
            var menuFactory   = new NullMenuFactory();
            var classStrategy = new DefaultClassStrategy(reflectorConfiguration);
            var metamodel     = new Metamodel(classStrategy, cache);

            Reflector = new Reflector(classStrategy, metamodel, reflectorConfiguration, menuFactory, new IFacetDecorator[] {}, new IFacetFactory[] { facetFactory });
        }
示例#4
0
        public override void SetUp()
        {
            base.SetUp();

            var cache       = new ImmutableInMemorySpecCache();
            var config      = new ReflectorConfiguration(new Type[] { }, new Type[] { }, new Type[] { }, new Type[] { }, new[] { typeof(Customer).Namespace });
            var menuFactory = new NullMenuFactory();

            facetFactory = new UnsupportedMethodFilteringFactory(0);
            var classStrategy = new DefaultClassStrategy(config);
            var metamodel     = new Metamodel(classStrategy, cache);

            Reflector = new Reflector(classStrategy, metamodel, config, menuFactory, new IFacetDecorator[] {}, new IFacetFactory[] { facetFactory });
        }
示例#5
0
        public override void SetUp()
        {
            base.SetUp();
            var cache = new ImmutableInMemorySpecCache();

            ReflectorConfiguration.NoValidate = true;

            var reflectorConfiguration = new ReflectorConfiguration(new Type[] { }, new Type[] { }, new string[] { });

            facetFactory = new RemoveIgnoredMethodsFacetFactory(0, LoggerFactory);
            var menuFactory       = new NullMenuFactory();
            var classStrategy     = new DefaultClassStrategy(reflectorConfiguration);
            var metamodel         = new Metamodel(classStrategy, cache, null);
            var mockLogger        = new Mock <ILogger <Reflector> >().Object;
            var mockLoggerFactory = new Mock <ILoggerFactory>().Object;

            Reflector = new Reflector(classStrategy, metamodel, reflectorConfiguration, menuFactory, new IFacetDecorator[] { }, new IFacetFactory[] { facetFactory }, mockLoggerFactory, mockLogger);
        }
示例#6
0
        public virtual void SetUp()
        {
            var cache = new ImmutableInMemorySpecCache();

            ReflectorConfiguration.NoValidate = true;
            var config            = new ReflectorConfiguration(new[] { typeof(List <TestPoco>), typeof(ArrayList) }, new Type[] { }, new[] { typeof(TestPoco).Namespace });
            var menuFactory       = new NullMenuFactory();
            var classStrategy     = new DefaultClassStrategy(config);
            var mockLogger        = new Mock <ILogger <Metamodel> >().Object;
            var metamodel         = new Metamodel(classStrategy, cache, mockLogger);
            var mockLogger1       = new Mock <ILogger <Reflector> >().Object;
            var mockLoggerFactory = new Mock <ILoggerFactory>().Object;

            var reflector = new Reflector(classStrategy, metamodel, config, menuFactory, new IFacetDecorator[] { }, facetFactories, mockLoggerFactory, mockLogger1);

            Specification = LoadSpecification(reflector);
            Metamodel     = metamodel;
        }
        public override void SetUp()
        {
            base.SetUp();

            var cache = new ImmutableInMemorySpecCache();

            ReflectorConfiguration.NoValidate = true;

            var config      = new ReflectorConfiguration(new Type[] { }, new Type[] { }, new[] { typeof(Customer).Namespace });
            var menuFactory = new NullMenuFactory();

            facetFactory = new SystemClassMethodFilteringFactory(0, LoggerFactory);
            var classStrategy     = new DefaultClassStrategy(config);
            var metamodel         = new Metamodel(classStrategy, cache, null);
            var mockLogger        = new Mock <ILogger <Reflector> >().Object;
            var mockLoggerFactory = new Mock <ILoggerFactory>().Object;

            Reflector = new Reflector(classStrategy, metamodel, config, menuFactory, new IFacetDecorator[] { }, new IFacetFactory[] { facetFactory }, mockLoggerFactory, mockLogger);
        }
        public void TestFilterActions()
        {
            ReflectorConfiguration.NoValidate = true;

            var config = new ReflectorConfiguration(new Type[] { }, new Type[] { }, new[] { typeof(Customer).Namespace });

            var classStrategy = new DefaultClassStrategy(config);

            var methods            = typeof(Customer).GetMethods().ToList();
            var filteredActions    = methods.Where(m => facetFactory.Filters(m, classStrategy)).ToArray();
            var notFilteredActions = methods.Where(m => !facetFactory.Filters(m, classStrategy)).ToArray();


            var filteredNames = new List <string> {
                "ToString",
                "Equals",
                "GetHashCode",
                "GetType",
            };

            var notFilteredNames = new List <string> {
                "ActionWithNoParameters",
                "ActionWithOneGoodParameter",
                "ActionWithTwoGoodParameter",
                "ActionWithOneBadParameter",
                "ActionWithOneGoodOneBadParameter",
                "ActionWithGenericParameter",
                "ActionWithNullableParameter",
                "ActionWithDictionaryParameter"
            };

            Assert.AreEqual(notFilteredNames.Count, notFilteredActions.Count());
            notFilteredNames.ForEach(n => Assert.IsTrue(notFilteredActions.Select(a => a.Name).Contains(n)));

            Assert.AreEqual(filteredNames.Count, filteredActions.Count());
            filteredNames.ForEach(n => Assert.IsTrue(filteredActions.Select(a => a.Name).Contains(n)));
        }