示例#1
0
    public void DetectAllEnumValues()
    {
        var arr  = (AddressTypes[])Enum.GetValues(typeof(AddressTypes));
        var list = new List <string>(1);

        foreach (AddressTypes item in arr)
        {
            list.Clear();
            AddressTypesCollector.CollectValueStrings(item, list);

            Assert.AreEqual(1, list.Count);
            Assert.IsNotNull(list[0]);
        }
    }
示例#2
0
    public void CollectValueStringsTest()
    {
        AddressTypes?adr = AddressTypes.Dom | AddressTypes.Parcel;

        var list = new List <string>();

        AddressTypesCollector.CollectValueStrings(adr, list);

        Assert.AreEqual(2, list.Count);
        Assert.IsTrue(list.Contains(AddressTypesConverter.AdrTypeValue.PARCEL));

        // collector darf die Liste nicht löschen!:
        AddressTypesCollector.CollectValueStrings(adr, list);
        Assert.AreEqual(4, list.Count);

        // auf null testen:
        adr = null;
        list.Clear();

        AddressTypesCollector.CollectValueStrings(adr, list);
        Assert.AreEqual(0, list.Count);
    }
示例#3
0
    public void RoundTrip()
    {
        var arr  = (AddressTypes[])Enum.GetValues(typeof(AddressTypes));
        var list = new List <string>(1);

        foreach (AddressTypes item in arr)
        {
            list.Clear();
            AddressTypesCollector.CollectValueStrings(item, list);

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

            AddressTypes?comp = AddressTypesConverter.Parse(list[0]);

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

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

            Assert.AreEqual(comp, comp2);
        }
    }