public void TupleKeyInfoHelper_ParseCreate() { TupleKeyInfoHelper builder = new TupleKeyInfoHelper(typeof(Tuple<int, string>)); Expression<Func<Group, Tuple<int, string>>> selector = (Group m) => Tuple.Create(m.Id, m.Name); MemberInfo[] members = null; bool res = builder.TryParseKeySelectorExpression(selector.Body, true, out members); Assert.AreEqual(true, res); Assert.IsNotNull(members); Assert.AreEqual(2, members.Length); Assert.AreEqual("Id", members[0].Name); Assert.AreEqual("Name", members[1].Name); }
public void TupleKeyInfoHelper_ParseLarge() { TupleKeyInfoHelper builder = new TupleKeyInfoHelper(typeof(Tuple<int, string, int, string, int, string, int, Tuple<string, int>>)); Expression<Func<Group, Tuple<int, string, int, string, int, string, int, Tuple<string, int>>>> selector = (Group m) => new Tuple<int, string, int, string, int, string, int, Tuple<string, int>>( m.Id, m.Name, m.Id, m.Name, m.Id, m.Name, m.Id, new Tuple<string, int>( m.Name, m.Id)); MemberInfo[] members = null; bool res = builder.TryParseKeySelectorExpression(selector.Body, true, out members); Assert.AreEqual(true, res); Assert.IsNotNull(members); Assert.AreEqual(9, members.Length); for (int i = 0; i < 9; i++) { string expect = i % 2 == 0 ? "Id" : "Name"; Assert.AreEqual(expect, members[i].Name); } }