public void ZeroValueTupleTests() { var info = TupleInfo.GetInfo <ValueTuple>(); info.TupleType.Should().Be(typeof(ValueTuple)); info.ItemTypes.Should().BeEmpty(); info.CreateNew(new object[0]).Should().Be(ValueTuple.Create()); }
public void EightTupleTests() { var info = TupleInfo.GetInfo <Tuple <int, int, int, int, int, int, int, Tuple <int> > >(); info.TupleType.Should().Be(typeof(Tuple <int, int, int, int, int, int, int, Tuple <int> >)); info.ItemTypes.Should().Equal(Enumerable.Repeat(typeof(int), 8)); info.CreateNew(new object[] { 1, 2, 3, 4, 5, 6, 7, 8 }).Should().Be(Tuple.Create(1, 2, 3, 4, 5, 6, 7, 8)); }
public void OneTupleTests() { var info = TupleInfo.GetInfo <Tuple <int> >(); info.TupleType.Should().Be(typeof(Tuple <int>)); info.ItemTypes.Should().Equal(typeof(int)); info.CreateNew(new object[] { 1 }).Should().Be(new Tuple <int>(1)); }
public void IsTuple() { TupleInfo.IsTuple(null).Should().BeFalse(); TupleInfo.IsTuple("ValueTuple").Should().BeFalse(); TupleInfo.IsTuple(ValueTuple.Create(true)).Should().BeTrue(); TupleInfo.IsTuple(default(ValueTuple)).Should().BeTrue(); TupleInfo.IsTuple(Tuple.Create(true)).Should().BeTrue(); TupleInfo.IsTuple(default(ValueTuple?)).Should().BeFalse(); }
public void IsTupleType() { TupleInfo.IsTupleType(typeof(object)).Should().BeFalse(); TupleInfo.IsTupleType(typeof(string)).Should().BeFalse(); TupleInfo.IsTupleType(typeof(ValueTuple <bool>)).Should().BeTrue(); TupleInfo.IsTupleType(typeof(ValueTuple)).Should().BeTrue(); TupleInfo.IsTupleType(typeof(Tuple <bool>)).Should().BeTrue(); TupleInfo.IsTupleType(typeof(Tuple)).Should().BeFalse(); }
internal static DbValueTypeStrategy GetStrategy(Type type) { if (s_strategies.TryGetValue(type, out var strategy)) { return(strategy); } if (TupleInfo.IsTupleType(type)) { return(DbValueTypeStrategy.Tuple); } if (type.GetTypeInfo().IsEnum) { return(DbValueTypeStrategy.Enum); } return(DbValueTypeStrategy.DtoProperties); }
void Tuple(out TupleInfo ti, string locality) { object val = null; List <object> items = new List <object>(); Expect(7); Constant(out val); items.Add(val); while (la.kind == 8) { Get(); Constant(out val); items.Add(val); } Expect(9); ti = new TupleInfo() { Items = items, Locality = locality }; }
void LocatedItem() { TupleInfo ti = null; Process p = null; Expect(1); string locality = t.val; Expect(6); if (la.kind == 7) { Tuple(out ti, locality); this.tuples.Add(ti); } else if (StartOf(1)) { Process(out p, locality); this.Processes.Add(new ProcessDefinition(p, GetProcName(locality), true)); } else { SynErr(25); } }
void Tuple(out TupleInfo ti, string locality) { object val = null; List<object> items = new List<object>(); Expect(7); Constant(out val); items.Add(val); while (la.kind == 8) { Get(); Constant(out val); items.Add(val); } Expect(9); ti = new TupleInfo(){Items = items, Locality = locality}; }
public void IsNullableValueTupleType() { TupleInfo.IsTupleType(typeof(ValueTuple <bool>?)).Should().BeTrue(); TupleInfo.IsTupleType(typeof(ValueTuple?)).Should().BeTrue(); }
public void WeakNonTupleType() { Invoking(() => TupleInfo.GetInfo(typeof(int))) .Should().Throw <InvalidOperationException>(); }
public void StrongNonTupleType() { Invoking(() => TupleInfo.GetInfo <int>()) .Should().Throw <InvalidOperationException>(); }