Ejemplo n.º 1
0
    public MappedEntityGraph Get(MappedIdentifier identifier, int traversalDepth)
    {
      /*
       * Get the repository with the given key
       * Get the entity with the given key (to depth)
       * Check with the Hive Store whether other providers have children for this repo-entity pair
       * If so, get the repo-entity keypairs from Hive Store
       * For each repo, get the entities
       * Walk the lists adding the entities to a graph
       * 
       */

      var providerTuple = _dependencyResolver.TryResolve<IPersistenceProvider>(identifier.ProviderKey);

      MappedEntityGraph mappedEntityGraph = null;

      if (providerTuple.Success)
      {
        PersistedEntity entity = providerTuple.Value.Reader.Get(identifier.Value);

        if (entity != null)
        {
          //TODO: Replace with AutoMapper
          //TODO: Pad-out attributes etc.
          //TODO: Find children from other providers
          mappedEntityGraph = new MappedEntityGraph();
          mappedEntityGraph.Id = identifier;
          mappedEntityGraph.Value = entity.Value;
        }
      }

      return mappedEntityGraph;
    }
Ejemplo n.º 2
0
    public void GetTest()
    {
      HiveRepository target = DependencyResolver.Current.Resolve<HiveRepository>();

      string persistenceProviderKey = "in-memory-01";

      MappedIdentifier identifier = new MappedIdentifier() {ProviderKey = persistenceProviderKey, Value = 100};

      PersistedEntity persistedEntity = TestHelper.CreatePersistedEntity(persistenceProviderKey);
      persistedEntity.Key = "100";

      var mockedInMemoryRepo = DependencyResolver.Current.TryResolve<IPersistenceProvider>(identifier.ProviderKey);
      mockedInMemoryRepo.Value.Reader.Add(persistedEntity);

      int traversalDepth = 0;

      var actual = target.Get(identifier, traversalDepth);

      Assert.IsNotNull(actual);
      Assert.AreEqual(persistedEntity.Value, actual.Value);
      Assert.AreEqual(identifier, actual.Id);
    }