Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/29/09 13:52:20 (15 years ago)
Author:
epitzer
Message:

Replace value comparison with references comparison in serializer. (#605)

File:
1 edited

Legend:

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

    r1684 r1701  
    3636    [Storable]
    3737    private ulong _ulong = 123456;
     38  }
     39
     40  public class IntWrapper {
     41
     42    [Storable]
     43    public int Value;
     44
     45    private IntWrapper() { }
     46
     47    public IntWrapper(int value) {
     48      this.Value = value;
     49    }
     50
     51    public override bool Equals(object obj) {
     52      if (obj as IntWrapper == null)
     53        return false;
     54      return Value.Equals(((IntWrapper)obj).Value);
     55    }
     56    public override int GetHashCode() {
     57      return Value.GetHashCode();
     58    }
     59
    3860  }
    3961
     
    449471    }
    450472
     473    [TestMethod]
     474    public void TestAliasingWithOverriddenEquals() {
     475      List<IntWrapper> ints = new List<IntWrapper>();
     476      ints.Add(new IntWrapper(1));
     477      ints.Add(new IntWrapper(1));
     478      Assert.AreEqual(ints[0], ints[1]);
     479      Assert.AreNotSame(ints[0], ints[1]);
     480      XmlGenerator.Serialize(ints, tempFile);
     481      List<IntWrapper> newInts = (List<IntWrapper>)XmlParser.DeSerialize(tempFile);
     482      Assert.AreEqual(newInts[0].Value, 1);
     483      Assert.AreEqual(newInts[1].Value, 1);
     484      Assert.AreEqual(newInts[0], newInts[1]);
     485      Assert.AreNotSame(newInts[0], newInts[1]);
     486    }
    451487
    452488    [ClassInitialize]
Note: See TracChangeset for help on using the changeset viewer.