/// <summary> /// Initializes a new instance of the <see cref="DelegatedJoinBuilder{T,TSource,TQuery}" /> class. /// </summary> /// <param name="joinBuilder"> /// The wrapped join builder instance. /// </param> /// <param name="query"> /// The query instance. /// </param> /// <param name="alias"> /// The alias. /// </param> /// <exception cref="ArgumentNullException"> /// The wrapped join builder instance is a null-reference. /// </exception> public DelegatedJoinBuilder ( IJoinBuilder <TSource, TQuery> joinBuilder, IFilterableQuery <T> query, string alias ) { if (joinBuilder == null) { throw new ArgumentNullException("joinBuilder"); } if (query == null) { throw new ArgumentNullException("query"); } _alias = alias; _joinBuilder = joinBuilder; _query = query; _rebaser = new ExpressionRebaser(typeof(T), _alias); }
public void ExpresionRebaserThrowsNothingIfExpressionHasTwoParametersAndSecondParamterIsWhereDelegate() { Expression <Func <Setting, WhereDelegate, bool> > filter = (x, y) => x.Id == 1; var visitor = new ExpressionRebaser(typeof(Setting), "setting"); Assert.That(() => visitor.RebaseTo <UserEntity, WhereDelegate, bool>(filter), Throws.Nothing); }
public void ExpresionRebaserThrowsIfExpressionHasTwoParametersAndSecondParamterIsNotWhereDelegate() { Expression <Func <Setting, string, bool> > filter = (x, y) => x.Id == 1; var visitor = new ExpressionRebaser(typeof(Setting), "setting"); Assert.That(() => visitor.RebaseTo <UserEntity, bool>(filter), Throws.InstanceOf <ArgumentException>()); }
public void ExpresionRebaserThrowsIfExpressionHasMoreThanTwoParameters() { Expression <Func <Setting, string, string, bool> > filter = (x, y, z) => x.Id == 1; var visitor = new ExpressionRebaser(typeof(Setting), "setting"); Assert.That(() => visitor.RebaseTo <UserEntity, bool>(filter), Throws.InstanceOf <ArgumentException>()); }
public void ExpresionRebaserTest() { Expression <Func <Setting, bool> > filter = x => x.Id == 1; var visitor = new ExpressionRebaser(typeof(Setting), "setting"); Expression <Func <UserEntity, bool> > visited = visitor.RebaseTo <UserEntity, bool>(filter); Assert.That(visited, Is.Not.Null); Assert.That(visited.ToString(), Is.EqualTo("x => (setting.Id == 1)")); }
/// <summary> /// Initializes a new instance of the <see cref="DelegatedFilterableQuery{T,TSource,TQuery}" /> class. /// </summary> /// <param name="query"> /// The wrapped query instance. /// </param> /// <param name="alias"> /// The alias. /// </param> /// <exception cref="ArgumentNullException"> /// The wrapped query instance is a null-reference. /// </exception> public DelegatedFilterableQuery ( TQuery query, string alias ) { if (string.IsNullOrWhiteSpace(alias)) { throw new ArgumentException("alias is null or white-space", "alias"); } if (query == null) { throw new ArgumentNullException("query"); } _alias = alias; _query = query; _rebaser = new ExpressionRebaser(typeof(T), _alias); }
public void ExpresionRebaserThrowsIfExpressionIsNull() { var visitor = new ExpressionRebaser(typeof(Setting), "setting"); Assert.That(() => visitor.RebaseTo <UserEntity, bool>(null), Throws.InstanceOf <ArgumentNullException>()); }