Ejemplo n.º 1
0
        public void SimpleSelector_should_work()
        {
            var selector = ExpressionChain <User> .New(u => u.TwitterUri);

            Assert.True(selector.Contains(u => u.TwitterUri));

            Assert.Equal("TwitterUri", selector.Name);
        }
        public void ComparingTheSameReferencedPropertyShouldWork()
        {
            var dictionary = new Dictionary <IExpression, int>(new RddExpressionEqualityComparer());
            var p1         = ExpressionChain <FakeClass> .New(fc => fc.A);

            var p1Val = 42;

            dictionary.Add(p1, p1Val);

            Assert.Equal(p1Val, dictionary[p1]);
        }
        public void ComparingPropertiesWithTheSameNameFromTwoDifferentClassesShouldFail()
        {
            var dictionary = new Dictionary <IExpression, int>(new RddExpressionEqualityComparer());
            var p1         = ExpressionChain <FakeClass> .New(fc => fc.A);

            var p1Val = 42;

            dictionary.Add(p1, p1Val);

            var p2 = ExpressionChain <FakeClass2> .New(fc => fc.A);

            Assert.False(dictionary.ContainsKey(p2));
        }
        public void ComparingPropertyInstancesWithDifferentEntityNameButSamePropertyShouldWork()
        {
            var dictionary = new Dictionary <IExpression, int>(new RddExpressionEqualityComparer());
            var p1         = ExpressionChain <FakeClass> .New(fc => fc.A);

            var p1Val = 42;

            dictionary.Add(p1, p1Val);

            var p2 = ExpressionChain <FakeClass> .New(fakeClass => fakeClass.A);

            Assert.Equal(p1Val, dictionary[p2]);
        }
Ejemplo n.º 5
0
        public bool HasProperty <TProp>(Expression <Func <TEntity, TProp> > expression)
        {
            var selector = ExpressionChain <TEntity> .New(expression);

            return(ContainsPath(_structure, selector));
        }
        public void SubAbstractContainsShouldWork()
        {
            var collection = ExpressionChain <DummyClass> .New(d => d.Children.Select(c => c.DummySubSubClass));

            Assert.True(collection.Contains(d => d.Children.Select(c => c.DummySubSubClass)));
        }
        public void SimpleContainsWithDifferentPropsShouldFail()
        {
            var collection = ExpressionChain <DummyClass> .New(d => d.DummyProp);

            Assert.False(collection.Contains(d => d.DummyProp2));
        }
        public void SimpleContainsWithDifferentVariableNameShouldWork()
        {
            var collection = ExpressionChain <DummyClass> .New(d => d.DummyProp);

            Assert.True(collection.Contains(c => c.DummyProp));
        }
        public void SimpleContainsShouldWork()
        {
            var collection = ExpressionChain <DummyClass> .New(d => d.DummyProp);

            Assert.True(collection.Contains(d => d.DummyProp));
        }
        public void ExtractionOnListSubPropertyShouldWork()
        {
            var ps = ExpressionChain <DummyClass> .New(d => d.Children.Select(c => c.DummySubProp));

            Assert.Equal("DummySubProp", ps.Next.ToString());
        }
        public void ExtractionOnSubPropertyShouldWork()
        {
            var ps = ExpressionChain <DummyClass> .New(d => d.BestChild.DummySubProp);

            Assert.Equal("DummySubProp", ps.Next.ToString());
        }