public void TypeCheckForSubTypeOfGenericType() { object c12 = new C12(); Assert.True(c12 is C12, "#1"); Assert.True(c12 is C11 <K>, "#2"); Assert.True(c12 is C10 <K>, "#3"); }
static int T1_TypeSwitch() { int sum = 0; for (int i = 0; i < repeats; i++) { foreach (var d in _testDataToSwitchOn) { sum += d switch { //C40 _ => 40, //C39 _ => 39, //C38 _ => 38, //C37 _ => 37, //C36 _ => 36, //C35 _ => 35, //C34 _ => 34, //C33 _ => 33, //C32 _ => 32, //C31 _ => 31, //C30 _ => 30, //C29 _ => 29, //C28 _ => 28, //C27 _ => 27, //C26 _ => 26, //C25 _ => 25, //C24 _ => 24, //C23 _ => 23, //C22 _ => 22, //C21 _ => 21, //C20 _ => 20, //C19 _ => 19, //C18 _ => 18, //C17 _ => 17, //C16 _ => 16, //C15 _ => 15, //C14 _ => 14, //C13 _ => 13, C12 _ => 12, C11 _ => 11, C10 x => 10, C9 x => 9, C8 x => 8, C7 x => 7, C6 x => 6, C5 x => 5, C4 x => 4, C3 x => 3, C2 x => 2, C1 x => 1, _ => - 1 }; } } return(sum); }
public void T10_CovariantStructInterfaceArrays() { using (var ms = new MemoryStream()) { var s = new SlimSerializer(); var dIn = new C12() { FIC12s = new IC12[] { new C12_2(), new C12_1() } }; s.Serialize(ms, dIn); ms.Seek(0, SeekOrigin.Begin); var dOut = (C12)s.Deserialize(ms); Assert.IsInstanceOf <C12_2>(dOut.FIC12s[0]); Assert.IsInstanceOf <C12_1>(dOut.FIC12s[1]); } }
public static void TestI7() { var a = new C10(); I7 <int, string, bool> i = a; Assert.AreEqual(1, i.Foo()); var a1 = new C11 <int, string, bool>(); i = a1; Assert.AreEqual(1, i.Foo()); var a2 = new C12 <int, string, bool>(); I7 <I5 <int>, I5 <string>, I5 <bool> > i2 = a2; Assert.AreEqual(1, i2.Foo()); var a3 = new C13 <int, string, bool>(); I7 <I5 <I5 <int> >, I5 <I5 <string> >, I5 <I5 <bool> > > i3 = a3; Assert.AreEqual(1, i3.Foo()); }