コード例 #1
0
    public void RoundTrip()
    {
        var arr = (TelTypes[])Enum.GetValues(typeof(TelTypes));

        var list = new List <string>(1);

        foreach (TelTypes item in arr)
        {
            list.Clear();
            TelTypesCollector.CollectValueStrings(item, list);

            Assert.AreEqual(1, list.Count);
            Assert.IsNotNull(list[0]);

            //TelTypes? comp = (TelTypes)Enum.Parse(typeof(TelTypes), list[0], true);

            //Assert.IsTrue(comp.HasValue);
            //Assert.AreEqual(comp.Value, item);


            TelTypes?comp = TelTypesConverter.Parse(list[0]);

            Assert.IsTrue(comp.HasValue);
            Assert.AreEqual(comp !.Value, item);

            var comp2 = (TelTypes)Enum.Parse(typeof(TelTypes), list[0], true);

            Assert.AreEqual(comp, comp2);
        }
    }
コード例 #2
0
 public void ParseTest() => Assert.IsNull(TelTypesConverter.Parse(null));