public void Should_access_no_level_property() { Expression <Func <A, A> > propertyExpression = (A a) => a; PropertyExpressionVisitor visitor = new PropertyExpressionVisitor <A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsNull(selector.Next); }
public void Should_access_no_level_property() { Expression<Func<A, A>> propertyExpression = (A a) => a; PropertyExpressionVisitor visitor = new PropertyExpressionVisitor<A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf<TypeNodeSelector<A>>(selector); Assert.IsNull(selector.Next); }
public void Should_access_first_level_property() { Expression <Func <A, B> > propertyExpression = (A a) => a.TheB; PropertyExpressionVisitor visitor = new PropertyExpressionVisitor <A>(_configurator); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, B, B> >(selector.Next); Assert.IsNull(selector.Next.Next); }
public void Should_access_first_level_property() { Expression<Func<A, B>> propertyExpression = (A a) => a.TheB; PropertyExpressionVisitor visitor = new PropertyExpressionVisitor<A>(_configurator); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf<TypeNodeSelector<A>>(selector); Assert.IsInstanceOf<PropertyNodeSelector<A, B,B>>(selector.Next); Assert.IsNull(selector.Next.Next); }
public void Should_get_list_getters() { Expression <Func <A, double> > propertyExpression = (A a) => a.Amounts[1]; var visitor = new PropertyExpressionVisitor <A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, IList <double> > >(selector.Next); Assert.IsInstanceOf <ListNodeSelector <Token <A, IList <double> >, double> >(selector.Next.Next); Assert.IsNull(selector.Next.Next.Next); }
public void Should_access_third_level_property() { Expression <Func <A, string> > propertyExpression = (A a) => a.TheB.TheC.Value; var visitor = new PropertyExpressionVisitor <A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, B> >(selector.Next); Assert.IsInstanceOf <PropertyNodeSelector <A, B, C> >(selector.Next.Next); Assert.IsInstanceOf <PropertyNodeSelector <Token <A, B>, C, string> >(selector.Next.Next.Next); Assert.IsNull(selector.Next.Next.Next.Next); }
public void Should_get_indexers() { Expression <Func <A, int> > propertyExpression = (A a) => a.TheB.Values[1]; var visitor = new PropertyExpressionVisitor <A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, B> >(selector.Next); Assert.IsInstanceOf <PropertyNodeSelector <A, B, int[]> >(selector.Next.Next); Assert.IsInstanceOf <ArrayNodeSelector <Token <Token <A, B>, int[]>, int> >(selector.Next.Next.Next); Assert.IsNull(selector.Next.Next.Next.Next); }
public void Should_access_fourth_level_property() { Expression <Func <A, int> > propertyExpression = (A a) => a.TheB.TheC.Value.Length; var visitor = new PropertyExpressionVisitor <A>(_configurator); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, B, B> >(selector.Next); Assert.IsInstanceOf <PropertyNodeSelector <A, B, C, C> >(selector.Next.Next); Assert.IsInstanceOf <PropertyNodeSelector <Token <A, B>, C, string, string> >(selector.Next.Next.Next); Assert.IsInstanceOf <PropertyNodeSelector <Token <Token <A, B>, C>, string, int, int> >( selector.Next.Next.Next.Next); Assert.IsNull(selector.Next.Next.Next.Next.Next); }
public void Should_access_fourth_level_property() { Expression<Func<A, int>> propertyExpression = (A a) => a.TheB.TheC.Value.Length; var visitor = new PropertyExpressionVisitor<A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf<TypeNodeSelector<A>>(selector); Assert.IsInstanceOf<PropertyNodeSelector<A, B>>(selector.Next); Assert.IsInstanceOf<PropertyNodeSelector<A, B, C>>(selector.Next.Next); Assert.IsInstanceOf<PropertyNodeSelector<Token<A, B>, C, string>>(selector.Next.Next.Next); Assert.IsInstanceOf<PropertyNodeSelector<Token<Token<A, B>, C>, string, int>>( selector.Next.Next.Next.Next); Assert.IsNull(selector.Next.Next.Next.Next.Next); }
public void Should_get_list_getters() { Expression<Func<A, double>> propertyExpression = (A a) => a.Amounts[1]; var visitor = new PropertyExpressionVisitor<A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf<TypeNodeSelector<A>>(selector); Assert.IsInstanceOf<PropertyNodeSelector<A, IList<double>>>(selector.Next); Assert.IsInstanceOf<ListNodeSelector<Token<A, IList<double>>, double>>(selector.Next.Next); Assert.IsNull(selector.Next.Next.Next); }
public void Should_get_indexers() { Expression<Func<A, int>> propertyExpression = (A a) => a.TheB.Values[1]; var visitor = new PropertyExpressionVisitor<A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf<TypeNodeSelector<A>>(selector); Assert.IsInstanceOf<PropertyNodeSelector<A, B>>(selector.Next); Assert.IsInstanceOf<PropertyNodeSelector<A, B, int[]>>(selector.Next.Next); Assert.IsInstanceOf<ArrayNodeSelector<Token<Token<A, B>, int[]>, int>>(selector.Next.Next.Next); Assert.IsNull(selector.Next.Next.Next.Next); }