示例#1
0
        public void DifferentParameters()
        {
            var pattern = new PatternGroup(new Pattern <IEnumerable <GFrom> >(), new Pattern <GTo>());

            Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(int)));
            Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(bool)));
            Assert.IsFalse(pattern.Matches(typeof(int), typeof(IEnumerable <int>)));
        }
示例#2
0
        public void SameParameter()
        {
            var pattern = new PatternGroup(new Pattern <IEnumerable <GAny> >(), new Pattern <GAny>());

            Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(int)));
            Assert.IsFalse(pattern.Matches(typeof(IEnumerable <int>), typeof(bool)));
            Assert.IsFalse(pattern.Matches(typeof(int), typeof(IEnumerable <int>)));
        }
示例#3
0
        public void WhereConditionIsCastable()
        {
            var pattern = new PatternGroup(new Pattern <IEnumerable <GFrom> >(), new Pattern <GTo>());

            pattern.AddWhereCondition(x => x.IsImplicitlyCastable <GFrom, GTo>());

            Assert.IsFalse(pattern.Matches(typeof(IEnumerable <int>), typeof(bool)));
            Assert.IsFalse(pattern.Matches(typeof(IEnumerable <int>), typeof(object)));
            Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(double)));
        }
示例#4
0
        public void WhereConditionIsPrimitive()
        {
            var pattern = new PatternGroup(new Pattern <IEnumerable <GFrom> >(), new Pattern <GTo>());

            pattern.AddWhereCondition(x => x.IsPrimitive <GFrom>() && x.IsPrimitive <GTo>());

            Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(bool)));
            Assert.IsFalse(pattern.Matches(typeof(IEnumerable <int>), typeof(object)));
            Assert.IsFalse(pattern.Matches(typeof(IEnumerable <object>), typeof(int)));
        }