public async Task TestGetById(string id) { var repository = new MongoDBRepository(); var entity = await repository.Get <BaseEntity>(Guid.Parse(id)); Assert.Equal <Guid>(Guid.Parse(id), entity.Id); }
public async Task TestMultiInsert(int max) { var repository = new MongoDBRepository(); var tasks = new List <Task <BaseEntity> >(); for (int count = 0; count < max; count++) { tasks.Add(repository.Insert(new BaseEntity() { Name = String.Format("Alice{0}", count) })); } var names = new List <string>(); // Run collection of Inserts concurrently foreach (var bucket in TaskProcessor.Interleaved(tasks)) { var t = await bucket; try { var entity = await t; names.Add(entity.Name); } catch (OperationCanceledException) { } catch (Exception exc) { Debug.WriteLine(exc); } } Assert.Equal(max, names.Count); }
public async Task TestGet() { var repository = new MongoDBRepository(); var entities = await repository.Get <BaseEntity>(); Assert.NotNull(entities); Assert.NotEmpty(entities); }
public async Task TestInsert() { var repository = new MongoDBRepository(); var entity = await repository.Insert(new BaseEntity() { Name = "Alice" }); Assert.Equal <string>("Alice", entity.Name); }
public async Task TestDelete(string id) { var repository = new MongoDBRepository(); await repository.Delete <BaseEntity>(Guid.Parse(id)); Assert.Throws(typeof(AggregateException), delegate { var entity = repository.Get <BaseEntity>(Guid.Parse(id)).Result; }); }