public void TestApplyToVariant3T2() { var variant = Variant <int, int, int> .Make2(5); variant.Apply( _ => Assert.Fail(), _ => { }, _ => Assert.Fail()); var variantT = new Variant <T1, T2, T3>(new T2()); int result = variantT.Apply( item => 0, item => 42, item => 0); Assert.AreEqual(42, result); var variantResult = variantT.Map( item => 0, item => 42, item => 0); Assert.AreEqual(1, variantResult.Index); Assert.AreEqual(42, variantResult.Get <int>()); }
public void TestApplyToVariant6T6() { var variant = Variant <int, int, int, int, int, int> .Make6(5); variant.Apply( _ => Assert.Fail(), _ => Assert.Fail(), _ => Assert.Fail(), _ => Assert.Fail(), _ => Assert.Fail(), _ => { }); var variantT = new Variant <T1, T2, T3, T4, T5, T6>(new T6()); int result = variantT.Apply( item => 0, item => 0, item => 0, item => 0, item => 0, item => 42); Assert.AreEqual(42, result); var variantResult = variantT.Map( item => 0, item => 0, item => 0, item => 0, item => 0, item => 42); Assert.AreEqual(5, variantResult.Index); Assert.AreEqual(42, variantResult.Get <int>()); }