public void ParallelCreateCollectionFile()
        {
            var tasks = new List <Task> ();

            tasks.Add(Task.Run(() => {
                var collection = _collectionFile.Collection <Product, Guid> ("products", p => p.Id);
            }));
            tasks.Add(Task.Run(() => {
                var collection = _collectionFile.Collection <Product, Guid> ("products", p => p.Id);
            }));


            Task.WaitAll(tasks.ToArray());
        }
Exemplo n.º 2
0
 public void Setup()
 {
     _platform       = new TestPlatform();
     _session        = new Session(_platform, "/");
     _collectionFile = _session["articles"];
     _products       = _collectionFile.Collection <Product, Guid>("products", p => p.Id);
 }
Exemplo n.º 3
0
 public void Setup()
 {
     _platform       = new TestPlatform();
     _session        = new Session(_platform, "/");
     _provider       = (InMemoryStreamProvider)_session.StreamProvider;
     _collectionFile = _session["articles"];
     _articles       = _collectionFile.Collection <Article, int>("articles", a => a.ID);
 }
Exemplo n.º 4
0
        public void Contains_Find_Single_Item()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, TestIndexDefinition>("indexables", i => i.ID);

            indexables.Persist(Indexable.Create(1));
            var tagged1 = indexables.Indexes.Tags.Contains("Tag1").ToList();

            Assert.AreEqual(1, tagged1[0].ID);
        }
Exemplo n.º 5
0
 public Collection <T, string> GetCollection <T>() where T : IObjectIdentifier
 {
     try
     {
         var collectionName = $"{typeof(T).Name}s";
         return(CollectionFile.Collection <T, string>(collectionName, x => x.Identifier));
     }
     catch (Exception ex)
     {
         throw new Exception($"Error getting collection {ex.Message}");
     }
 }
Exemplo n.º 6
0
        public void Can_Use_Multiple_Collections()
        {
            var locations = _collectionFile.Collection <Location, string>("locations", l => l.ID);

            _articles.Persist(Article.SpinalTapDvd);
            locations.Persist(Location.Harrods);
            _articles.Persist(Article.BarbieDoll);
            locations.Persist(Location.MandS);

            Assert.AreEqual(Article.SpinalTapDvd.Name, _articles.All.First().Name);
            Assert.AreEqual(Article.BarbieDoll.Name, _articles.All.Last().Name);

            Assert.AreEqual(Location.Harrods.Name, locations.All.First().Name);
            Assert.AreEqual(Location.MandS.Name, locations.All.Last().Name);

            _articles.Destroy(Article.SpinalTapDvd.ID);
            locations.Destroy(Location.Harrods.ID);

            Assert.AreEqual(1, _articles.All.Count());
            Assert.AreEqual(1, locations.All.Count());
            Assert.AreEqual(Article.BarbieDoll.Name, _articles.All.Last().Name);
            Assert.AreEqual(Location.MandS.Name, locations.All.Last().Name);
        }
Exemplo n.º 7
0
        public void InsertCompoundOf2()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinition2>("indexables2", i => i.ID);

            indexables.Persist(Indexable.CreateIndexable(1));
            indexables.Persist(Indexable.CreateIndexable(2));
            indexables.Persist(Indexable.CreateIndexable(3));

            var item2 = indexables.Indexes.Compound1And2.Equals(2, 2).First();

            Assert.AreEqual(2, item2.ID);
        }
Exemplo n.º 8
0
 public Collection <TEntity, TKey, TIndexDef> GetCollection <TEntity, TKey, TIndexDef>()
     where TIndexDef : IndexDefinition <TEntity>, new()
     where TEntity : IEntity <TKey>
 {
     return(database.Collection <TEntity, TKey, TIndexDef>(typeof(TEntity).Name, e => e.Id));
 }