/// <summary> /// Initializes the manager by pulling the authenticated player /// from session and database /// (may not perform initialization if the type does not match the id) /// </summary> /// <typeparam name="T">Type of the requested entity</typeparam> private void Initialize <T>() where T : Entity { string id = Id(); if (id == null) { // there's no authenticated player authenticatedPlayer = null; initialized = true; } else { // if the id belongs to a different type, // do not initialize var docId = DocumentId.Parse(id); if (docId.Collection != EntityUtils.CollectionFromType(typeof(T))) { return; } // here we have the authenticated player authenticatedPlayer = entityManager.Find <T>(id); initialized = true; } }
public static EntityQuery <TEntity> TakeAll(IArango arango) { var query = new EntityQuery <TEntity>(arango); query.Query.For("entity").In( EntityUtils.CollectionFromType(typeof(TEntity)) ).Do(); return(query); }
public void DeletingNonExistingCollectionThrows() { arango.Collections.Remove( EntityUtils.CollectionFromType(typeof(PlayerEntity)) ); Assert.Throws <EntityPersistenceException>(() => { manager.Delete(new PlayerEntity { EntityKey = "john" }); }); }
public void UpdatingInNonExistingCollectionThrows() { arango.Collections.Remove( EntityUtils.CollectionFromType(typeof(PlayerEntity)) ); Assert.Throws <EntityPersistenceException>(() => { manager.Update(new PlayerEntity { Name = "Johnny", EntityKey = "john", }); }); }