コード例 #1
0
        public void AccessingMethodFromNonPublicTypeIsDetected()
        {
            var expr      = new PrivateNestedClass().GenerateExpression();
            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsTrue(processor.NonPublicMembersAccessed);
        }
コード例 #2
0
        public void ExpressionUsingInternalTypesIsDetected()
        {
            Expression <Func <InternalSource, InternalDest, int> > expr = (a, b) => a.Foo + b.Bar;

            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsTrue(processor.NonPublicMembersAccessed);
        }
コード例 #3
0
        public void ExpressionUsingPublicTypesIsNotDetected()
        {
            Expression <Func <PublicSource, PublicDest, int> > expr = (a, b) => a.Foo + b.Bar;

            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsFalse(processor.NonPublicMembersAccessed);
        }
コード例 #4
0
        public void NonPublicInterfaceAccessIsDetected()
        {
            Expression <Func <ISource, Dest, bool> > expr = (a, b) => a.Valid & b.Valid;

            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsTrue(processor.NonPublicMembersAccessed);
        }
コード例 #5
0
        public void ExpressionNotUsingExternalOperationsIsNotDetected()
        {
            Expression <Func <int, int, int> > expr = (a, b) => a + b;

            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsFalse(processor.NonPublicMembersAccessed);
        }
コード例 #6
0
        public void AccessingPublicMethodIsNotDetected()
        {
            Expression <Func <int, int, int> > expr = (a, b) => Bar();

            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsFalse(processor.NonPublicMembersAccessed);
        }
コード例 #7
0
        public void ExpressionUsingGenericTypesIsDetected()
        {
            Expression <Func <GenericSource <int>, GenericDest <int>, int> > expr = (a, b) => a.Foo + b.Bar;

            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsTrue(processor.NonPublicMembersAccessed);
        }
コード例 #8
0
        public void AccessingCapturedVariableIsDetected()
        {
            var i = 1;
            Expression <Func <int, int, int> > expr = (a, b) => a + b + i;

            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsTrue(processor.NonPublicMembersAccessed);
        }
コード例 #9
0
        public void AccessingNonTrivialCapturedVariableIsDetected()
        {
            var info = new CultureInfo("en-US");

            Expression <Func <int, int, int> > expr = (a, b) => a + b + info.EnglishName.Length;

            var processor = new MapProposalProcessor(new MemberMapper());

            processor.Process(expr);

            Assert.IsTrue(processor.NonPublicMembersAccessed);
        }
コード例 #10
0
        public void NonPublicInterfaceAccessIsDetected_1()
        {
            var mapper = new MemberMapper();

            mapper.Options.Debug.DebugInformationEnabled = true;

            mapper.CreateMap <ISource, Dest>(src => new Dest
            {
                Valid = !src.Valid
            });

            var map = mapper.CreateMap <Source, Dest>();

            var processor = new MapProposalProcessor(mapper);

            processor.Process(map.DebugInformation.MappingExpression);

            Assert.IsTrue(processor.NonPublicMembersAccessed);
        }