public void RaiseIfTypeMismatch() { string name = "foo"; IList <ArgumentInfo> arguments = new List <ArgumentInfo>() { new ArgumentInfo("a", TypeInfo.Int), new ArgumentInfo("b", TypeInfo.Double) }; TypeInfo typeinfo = TypeInfo.String; IExpressionNode expression = new ConstantNode(42); DefNode node = new DefNode(name, arguments, typeinfo, expression); Assert.IsNotNull(node.TypeInfo); Assert.AreSame(TypeInfo.String, node.TypeInfo); try { node.CheckType(null); Assert.Fail(); } catch (Exception ex) { Assert.AreEqual("type mismatch", ex.Message); } }
public void CreateDefNodeWithoutTypeInfo() { string name = "foo"; IList <ArgumentInfo> arguments = new List <ArgumentInfo>() { new ArgumentInfo("a", TypeInfo.Int), new ArgumentInfo("b", TypeInfo.Double) }; TypeInfo typeinfo = TypeInfo.Int; IExpressionNode expression = new ConstantNode(42); DefNode node = new DefNode(name, arguments, null, expression); Assert.IsNull(node.TypeInfo); node.CheckType(null); Assert.AreSame(TypeInfo.Int, node.TypeInfo); }