static void Main(string[] args) { IntToBool intToBoolDelagate = ConvertHelper.ToBool; IntToNullableBool intToNullableBoolDelegate = ConvertHelper.ToNullableBool; Console.WriteLine("------------Before conversion------------"); Console.WriteLine("---------Positive Int to Bool------------"); Console.WriteLine(intToBoolDelagate(1)); Console.WriteLine("-----Positive Int to Nullable Bool-------"); Console.WriteLine(intToNullableBoolDelegate(1)); Console.WriteLine("------------After conversion-------------"); Console.WriteLine("-----------Positive Int to Bool----------"); Console.WriteLine(intToBoolDelagate.ToNullableBool()(1)); Console.WriteLine("------Positive Int to Nullable Bool------"); Console.WriteLine(intToNullableBoolDelegate.ToBool()(1)); Console.WriteLine("------------Before conversion------------"); Console.WriteLine("---------------Zero to Bool--------------"); Console.WriteLine(intToBoolDelagate(0)); Console.WriteLine("----------Zero to Nullable Bool----------"); Console.WriteLine(intToNullableBoolDelegate(0)); Console.WriteLine("------------After conversion-------------"); Console.WriteLine("---------------Zero to Bool--------------"); Console.WriteLine(intToBoolDelagate.ToNullableBool()(0)); Console.WriteLine("----------Zero to Nullable Bool----------"); Console.WriteLine(intToNullableBoolDelegate.ToBool()(0)); Console.WriteLine("------------Before conversion------------"); Console.WriteLine("----------Negative Int to Bool-----------"); Console.WriteLine(intToBoolDelagate(-1)); Console.WriteLine("-------Negative Int to Nullable Bool-----"); Console.WriteLine(intToNullableBoolDelegate(-1)); Console.WriteLine("------------After conversion-------------"); Console.WriteLine("---------Negative Int to Bool------------"); Console.WriteLine(intToBoolDelagate.ToNullableBool()(-1)); Console.WriteLine("------Negative Int to Nullable Bool------"); Console.WriteLine(intToNullableBoolDelegate.ToBool()(-1)); Console.ReadKey(); }
public void ZeroIntToNullableBool() { IntToBool dFrom = ConvertHelper.ToBool; Assert.AreEqual(false, dFrom.ToNullableBool()(0)); }
public void PositiveIntToNullableBool() { IntToBool dFrom = ConvertHelper.ToBool; Assert.AreEqual(true, dFrom.ToNullableBool()(1)); }
public void NegativeIntToNullableBool() { IntToBool dFrom = ConvertHelper.ToBool; Assert.AreEqual(null, dFrom.ToNullableBool()(-1)); }