Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/28/09 11:19:45 (16 years ago)
Author:
epitzer
Message:

New test cast to experiment with serializing delegates. (#603)

File:
1 edited

Legend:

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

    r1679 r1680  
    3838  }
    3939
     40  public class EventTest {
     41    public delegate object Filter(object o);
     42    public event Filter OnChange;
     43    [Storable]
     44    private Delegate[] OnChangeListener {
     45      get { return OnChange.GetInvocationList(); }
     46      set {
     47        foreach (Delegate d in value) {
     48          OnChange += (Filter)d;
     49        }
     50      }
     51    }
     52  }
     53
    4054  public class PrimitivesTest : NumberTest {
    4155    [Storable]
     
    127141    [TestCleanup()]
    128142    public void ClearTempFile() {     
     143      StreamReader reader = new StreamReader(tempFile);
     144      string s = reader.ReadToEnd();
     145      reader.Close();
    129146      File.Delete(tempFile);
    130147    }
     
    389406    }
    390407
     408    [TestMethod]
     409    public void Events() {
     410      EventTest et = new EventTest();
     411      et.OnChange += (o) => o;
     412      XmlGenerator.Serialize(et, tempFile);
     413      EventTest newEt = (EventTest)XmlParser.DeSerialize(tempFile);
     414    }
     415
    391416
    392417    [ClassInitialize]
Note: See TracChangeset for help on using the changeset viewer.