public void TestIntegration() { try { var some = from c in new TestClientDataContext().Companies where c.Employees.Count == 2 select c; var tf = new TransformationFramework(); tf.Integration.AllowDuplicateRules = false; tf.Integration.RegisterCSharp(o => o is IBean, o => "bean"); tf.Integration.RegisterCSharp(o => o is IBean, o => "bean2"); tf.CSharpToJS(some.Expression); } catch (Exception ex) { var ex0 = ex; Assert.AreEqual(typeof(CSharpToJSException), ex0.GetType()); Assert.IsNotNull(ex0.InnerException); var ex0_kvps = ((RelinqException)ex0).PrettyProperties; Assert.AreEqual("Integration", ex0_kvps["Type"]); Assert.AreEqual("value(Relinq.Infrastructure.Client.Beans.Bean`1[Relinq.Playground.Domain.Company]).Where(c => (c.Employees.Count = 2))", ex0_kvps["Input"]); var ex1 = ex0.InnerException; Assert.AreEqual(typeof(LinqVisitorException), ex1.GetType()); Assert.IsNotNull(ex1.InnerException); var ex1_kvps = ((RelinqException)ex1).PrettyProperties; Assert.AreEqual("value(Relinq.Infrastructure.Client.Beans.Bean`1[Relinq.Playground.Domain.Company]).Where(c => (c.Employees.Count = 2))", ex1_kvps["Root"]); Assert.AreEqual("value(Relinq.Infrastructure.Client.Beans.Bean`1[Relinq.Playground.Domain.Company])", ex1_kvps["Expression"]); Assert.AreEqual("Constant", ex1_kvps["ExpressionType"]); var ex2 = ex1.InnerException; Assert.AreEqual(typeof(CSharpToJSIntegrationException), ex2.GetType()); Assert.IsNull(ex2.InnerException); var ex2_kvps = ((RelinqException)ex2).PrettyProperties; Assert.AreEqual("Relinq.Infrastructure.Client.Beans.Bean`1[Relinq.Playground.Domain.Company]", ex2_kvps["CSharpObject"]); Assert.AreEqual("Relinq.Playground.Domain.Company", ex2_kvps["CSharpObject[0]"]); Assert.AreEqual("Relinq.Playground.Domain.Company", ex2_kvps["CSharpObject[1]"]); Assert.AreEqual("Relinq.Playground.Domain.Company", ex2_kvps["CSharpObject[2]"]); Assert.AreEqual("MultipleSuitableRules", ex2_kvps["Type"]); Assert.AreEqual("Relinq.Script.Integration.IntegrationContext", ex2_kvps["Context"]); return; } Assert.Fail("Expected exception wasn't thrown"); }
public void TestStaticMember_Method() { try { IConvertible cnv = 2; var some = from c in new TestClientDataContext().Companies where cnv.GetTypeCode() == Type.GetTypeCode(c.GetType()) select c; var tf = new TransformationFramework(); tf.CSharpToJS(some.Expression); } catch (Exception ex) { var ex0 = ex; Assert.AreEqual(typeof(CSharpToJSException), ex0.GetType()); Assert.IsNotNull(ex0.InnerException); var ex0_kvps = ((RelinqException)ex0).PrettyProperties; Assert.AreEqual("StaticMember", ex0_kvps["Type"]); Assert.AreEqual("value(Relinq.Infrastructure.Client.Beans.Bean`1[Relinq.Playground.Domain.Company]).Where(c => (Convert(value(Relinq.Playground.RelinqScriptBuilderExceptionsTests+<>c__DisplayClassa).cnv.GetTypeCode()) = Convert(GetTypeCode(c.GetType()))))", ex0_kvps["Input"]); Assert.AreEqual("False", ex0_kvps["IsUnexpected"]); var ex1 = ex0.InnerException; Assert.AreEqual(typeof(ScriptBuilderException), ex1.GetType()); Assert.IsNull(ex1.InnerException); var ex1_kvps = ((RelinqException)ex1).PrettyProperties; Assert.AreEqual("StaticMember", ex1_kvps["Type"]); Assert.AreEqual("False", ex1_kvps["IsUnexpected"]); Assert.AreEqual("value(Relinq.Infrastructure.Client.Beans.Bean`1[Relinq.Playground.Domain.Company]).Where(c => (9 = Convert(GetTypeCode(c.GetType()))))", ex1_kvps["Root"]); Assert.AreEqual("GetTypeCode(c.GetType())", ex1_kvps["Expression"]); Assert.AreEqual("Call", ex1_kvps["ExpressionType"]); return; } Assert.Fail("Expected exception wasn't thrown"); }