Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/28/09 13:58:49 (15 years ago)
Author:
epitzer
Message:

Fix EnumDecomposer to be applicable for flag enums and enums without names. (#603)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/UnitTests/UseCases.cs

    r1683 r1684  
    100100    [Storable(DefaultValue = "default")]
    101101    public string uninitialized;
     102  }
     103
     104  public enum SimpleEnum { one, two, three }
     105  public enum ComplexEnum { one = 1, two = 2, three = 3 }
     106  [FlagsAttribute]
     107  public enum TrickyEnum { zero = 0, one = 1, two = 2 }
     108
     109  public class EnumTest {
     110    [Storable]
     111    public SimpleEnum simpleEnum = SimpleEnum.one;
     112    [Storable]
     113    public ComplexEnum complexEnum = (ComplexEnum)2;
     114    [Storable]
     115    public TrickyEnum trickyEnum = (TrickyEnum)15;
    102116  }
    103117
     
    422436    }
    423437
     438    [TestMethod]
     439    public void Enums() {
     440      EnumTest et = new EnumTest();
     441      et.simpleEnum = SimpleEnum.two;
     442      et.complexEnum = ComplexEnum.three;
     443      et.trickyEnum = TrickyEnum.two | TrickyEnum.one;
     444      XmlGenerator.Serialize(et, tempFile);
     445      EnumTest newEt = (EnumTest)XmlParser.DeSerialize(tempFile);
     446      Assert.AreEqual(et.simpleEnum, SimpleEnum.two);
     447      Assert.AreEqual(et.complexEnum, ComplexEnum.three);
     448      Assert.AreEqual(et.trickyEnum, (TrickyEnum)3);
     449    }
     450
    424451
    425452    [ClassInitialize]
Note: See TracChangeset for help on using the changeset viewer.