public HashSet <string> NamesForType(ITypeReference type, HashSet <IExpression> exprs) { Contract.Requires(type != null); Contract.Requires(exprs != null); Contract.Requires(InstanceExpressions.ContainsKey(type)); Contract.Ensures(Contract.ForAll(Contract.Result <HashSet <string> >(), n => NameTable.ContainsValue(n))); return(new HashSet <string>(Names(InstanceExpressions[type].Intersect(exprs)))); }
public void Expression_from_instance_method_with_parameter() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products.Where(testInstance.MethodWithParameter(1)); Assert.DoesNotThrow(() => products.ToList()); } }
public void Expression_from_instance_delegate() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products.Where(testInstance.Delegate()); Assert.DoesNotThrow(() => products.ToList()); } }
public void Expression_from_instance_method_with_variable() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products.Where(testInstance.MethodWithVariable()); products.ToList(); } }
public void Expression_from_instance_delegate_with_parameter() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products.Where(testInstance.DelegateWithParameter(1)); products.ToList(); } }
public void Expression_from_instance_property() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products.Where(testInstance.Property); products.ToList(); } }
public void Non_expression_embedded_instance_method_throws() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => p.Id == testInstance.NonExpressionMethod()); Assert.Throws <NotSupportedException>(() => products.ToList()); } }
public HashSet <string> InstanceNames(INamedTypeDefinition type) { Contract.Requires(type != null); Contract.Ensures(Contract.Result <HashSet <string> >() != null); Contract.Ensures((!InstanceExpressions.ContainsKey(type)).Implies(Contract.Result <HashSet <string> >().Count == 0)); Contract.Ensures(Contract.ForAll(Contract.Result <HashSet <string> >(), n => NameTable.ContainsValue(n))); return(InstanceExpressions.ContainsKey(type) ? new HashSet <string>(InstanceExpressions[type].Select(x => NameTable[x])) : new HashSet <string>()); }
public void Non_expression_embedded_static_delegate_throws() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => p.Id == StaticExpressions.NonExpressionDelegate()); Assert.Throws <NotSupportedException>(() => products.ToList()); } }
public void Expression_embedded_instance_method_with_variable() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => context.Products.Where(testInstance.MethodWithVariable()) .Contains(p)); Assert.DoesNotThrow(() => products.ToList()); } }
public void Expression_from_instance_delegate_with_variable_parameter() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var foo = 1; var products = context.Products.Where(testInstance.DelegateWithParameter(foo)); Assert.DoesNotThrow(() => products.ToList()); } }
public void Expression_embedded_instance_method_with_parameter() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => context.Products.Where(testInstance.MethodWithParameter(1)) .Contains(p)); products.ToList(); } }
public void Expression_embedded_instance_delegate() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => context.Products.Where(testInstance.Delegate()) .Contains(p)); products.ToList(); } }
public void Expression_embedded_instance_delegate_with_parameter() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => context.Products.Where(testInstance.DelegateWithParameter(1)) .Contains(p)); Assert.DoesNotThrow(() => products.ToList()); } }
private void AddInstanceExpr(ITypeReference type, IExpression expr) { Contract.Requires(type != null); Contract.Requires(expr != null); Contract.Ensures(InstanceExpressions.ContainsKey(type)); Contract.Ensures(InstanceExpressions[type].Contains(expr)); Contract.Ensures(InstanceExpressionsReferredTypes.ContainsKey(expr)); Contract.Ensures(InstanceExpressionsReferredTypes[expr] == type); if (!InstanceExpressions.ContainsKey(type)) { InstanceExpressions.Add(type, new HashSet <IExpression>()); } InstanceExpressions[type].Add(expr); if (!InstanceExpressionsReferredTypes.ContainsKey(expr)) { InstanceExpressionsReferredTypes.Add(expr, type); } else { Debug.Assert(InstanceExpressionsReferredTypes[expr] == type); } }
public void Non_expression_embedded_instance_method_throws() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => p.Id == testInstance.NonExpressionMethod()); Assert.Throws<NotSupportedException>(() => products.ToList()); } }
public void Non_expression_embedded_static_delegate_throws() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => p.Id == StaticExpressions.NonExpressionDelegate()); Assert.Throws<NotSupportedException>(() => products.ToList()); } }
public void Expression_embedded_instance_method_with_parameter() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => context.Products.Where(testInstance.MethodWithParameter(1)) .Contains(p)); Assert.DoesNotThrow(() => products.ToList()); } }
public void Expression_embedded_instance_delegate() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products .Where(p => context.Products.Where(testInstance.Delegate()) .Contains(p)); Assert.DoesNotThrow(() => products.ToList()); } }
public void Expression_from_instance_method_with_variable() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products.Where(testInstance.MethodWithVariable()); Assert.DoesNotThrow(() => products.ToList()); } }
public void Expression_from_instance_property() { using (var context = new SimpleModelContext()) { var testInstance = new InstanceExpressions(); var products = context.Products.Where(testInstance.Property); Assert.DoesNotThrow(() => products.ToList()); } }