Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15878


Ignore:
Timestamp:
03/30/18 13:56:55 (6 years ago)
Author:
jkarder
Message:

#2520: worked on new persistence

  • updated tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCasesPersistenceNew.cs

    r15857 r15878  
    25602560    [StorableType("41108958-227D-43C4-B049-80AD0D3DB7F6")]
    25612561    private class InheritanceB0 : InheritanceA0 {
    2562       //[Storable]
    2563       //public int x;
     2562      [Storable]
     2563      public int x;
     2564
     2565      [StorableConstructor]
     2566      private InheritanceB0(StorableConstructorFlag flag) { }
     2567      public InheritanceB0(int x) {
     2568        this.x = x;
     2569        base.x = x;
     2570      }
    25642571    }
    25652572
     
    25902597      private static Dictionary<string, object> ConvertC0_C1(Dictionary<string, object> values) {
    25912598        var newValues = new Dictionary<string, object>();
    2592         newValues["41108958-227D-43C4-B049-80AD0D3DB7F6.x"] = (int)values["41108958-227D-43C4-B049-80AD0D3DB7F6.x"] * 2;
     2599        newValues["28A5F6B8-49AF-4C6A-AF0E-F92EB4511722.x"] = (int)values["28A5F6B8-49AF-4C6A-AF0E-F92EB4511722.x"] * 2;
    25932600        return newValues;
    25942601      }
     2602    }
     2603
     2604    private static class InheritanceConversionsWithNamesDemo {
     2605      [StorableConversion("A", 1)]
     2606      private static Dictionary<string, object> ConvertA1_A2(Dictionary<string, object> values) {
     2607        var newValues = new Dictionary<string, object>();
     2608        newValues["y"] = values["x"];
     2609        return newValues;
     2610      }
     2611
     2612      [StorableConversion("B", 1, baseGuid: "A", baseVersion: 2)]
     2613      private static Dictionary<string, object> ConvertB1_B2(Dictionary<string, object> values, out List<Tuple<string, uint>> typeChain) {
     2614        typeChain = new List<Tuple<string, uint>> {
     2615          Tuple.Create("C", 1u)
     2616        };
     2617
     2618        var newValues = new Dictionary<string, object>();
     2619        newValues["x"] = values["A.y"];
     2620        newValues["C.x"] = values["A.y"];
     2621        return newValues;
     2622      }
     2623
     2624      [StorableConversion("C", 1)]
     2625      private static Dictionary<string, object> ConvertC1_C2(Dictionary<string, object> values) {
     2626        var newValues = new Dictionary<string, object>();
     2627        newValues["x"] = (int)values["x"] * 2;
     2628        return newValues;
     2629      }
     2630
     2631      [StorableConversion("C", 1, "D", 1)]
     2632      [StorableConversion("D", 1, "E", 1)]
     2633      private static string Rename() { return "D"; }
    25952634    }
    25962635
     
    26002639    public void TestInheritanceConversionCase1() {
    26012640      var test = new Func<InheritanceB0>(() => {
    2602         return new InheritanceB0() { x = 17 };
     2641        return new InheritanceB0(17);
    26032642      });
    26042643
     
    26292668      var restoredC1 = (InheritanceC1)o;
    26302669      var restoredB1 = (InheritanceB1)o;
    2631       Assert.AreEqual(old.x, restoredB1.x);
    26322670      Assert.AreEqual(old.x * 2, restoredC1.x);
    26332671    }
Note: See TracChangeset for help on using the changeset viewer.