Beispiel #1
0
 public void Drop_IfHaveCollection_ReturnTrue()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Insert(TestModel.CreateInstance());
     var result = repository.Drop();
     Assert.IsTrue(result);
 }
Beispiel #2
0
 public void ExistsUniqueItem_Own_ReturnItem()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     repository.Insert(item);
     item.IntValue = 5;
     var result = repository.ExistsUniqueItem(item);
     Assert.IsFalse(result);
 }
Beispiel #3
0
 public void ExistsUniqueItem_OnlySelf_ReturnNull()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = new TestModel { StringValue = "sinan" };
     var item2 = new TestModel { StringValue = "sinan" };
     repository.Insert(item);
     var result = repository.ExistsUniqueItem(item2);
     Assert.IsTrue(result);
 }
Beispiel #4
0
 public void AsQueryable_InserThreeItem_ReturnTwo()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     repository.Insert(new TestModel4 { StringValue = "sinan" });
     repository.Insert(new TestModel4 { StringValue = "sinan" });
     repository.Insert(new TestModel4 { StringValue = "ali" });
     var list = repository.AsQueryable().Where(x => x.StringValue == "sinan");
     Assert.AreEqual(2, list.Count());
 }
Beispiel #5
0
 public void ExistsUniqueItem_SelfAndWithOtherProperties_ReturnNull()
 {
     var repository = new MongoRepository<TestModel3>();
     repository.Drop();
     var item = new TestModel3 { StringValue = "sinan", StringValue2 = "akyazıcı", DateTimeValue = DateTime.Parse("01/01/1967") };
     var item2 = new TestModel3 { StringValue = "sinan", StringValue2 = "akyazıcı", DateTimeValue = DateTime.Parse("01/01/1967") };
     repository.Insert(item);
     var result = repository.ExistsUniqueItem(item2);
     Assert.IsTrue(result);
 }
Beispiel #6
0
 public void Drop_IfDontHaveCollection_ReturnFalse()
 {
     var repository = new MongoRepository<TestModel>();
     var result = repository.Drop();
     Assert.IsFalse(result);
 }
Beispiel #7
0
 public void Save_IfHaveTheSameRecord_ReturnNull()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     repository.Insert(item);
     repository.Insert(new TestModel { StringValue = "sinan" });
     item.StringValue = "sinan";
     var res3 = repository.Save(item);
     Assert.IsNull(res3);
 }
Beispiel #8
0
 public void Save_IfDontHaveTheSameRecord_ReturnItem()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     var res = repository.Insert(item);
     item.StringValue2 = "sinan";
     var res2 = repository.Save(item);
     Assert.IsNotNull(res2);
 }
Beispiel #9
0
 public void Insert_IfHaveTheSameRecord_ReturnNull()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     var item2 = TestModel.CreateInstance();
     var res = repository.Insert(item);
     var res2 = repository.Insert(item2);
     Assert.IsNull(res2);
 }
Beispiel #10
0
 public void GetItemsByQuery_InserThreeItem_ReturnTwo()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     repository.Insert(new TestModel4 { StringValue = "sinan" });
     repository.Insert(new TestModel4 { StringValue = "sinan" });
     repository.Insert(new TestModel4 { StringValue = "ali" });
     var list = repository.GetItemsByQuery(Query.EQ("StringValue", "sinan"));
     Assert.AreEqual(2, list.Count());
 }
Beispiel #11
0
 public void GetItemById_SendObjectId_ReturnItem()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     repository.Insert(item);
     var res = repository.GetItemById(item.Id);
     Assert.IsNotNull(res);
 }
Beispiel #12
0
 public void GetAll_InserTwoItem_ReturnTwo()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     repository.Insert(new TestModel4());
     repository.Insert(new TestModel4());
     var list = repository.GetAll();
     Assert.AreEqual(2, list.Count());
 }
Beispiel #13
0
 public void ExistsUniqueItem_WithOutBsonUnique_ReturnItem()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     var item = new TestModel4 { StringValue = "sinan", StringValue2 = "akyazıcı", DateTimeValue = DateTime.Parse("01/01/1967") };
     var item2 = new TestModel4 { StringValue = "sinan", StringValue2 = "akyazıcıx", DateTimeValue = DateTime.Parse("02/01/1967") };
     repository.Insert(item);
     var result = repository.ExistsUniqueItem(item2);
     Assert.IsFalse(result);
 }
Beispiel #14
0
 public void ExistsUniqueItem_WithOtherProperties_ReturnNull()
 {
     var repository = new MongoRepository<TestModel2>();
     repository.Drop();
     var item = new TestModel2 { StringValue = "sinan", StringValue2 = "akyazıcı", IntValue = 5 };
     var item2 = new TestModel2 { StringValue = "sinan", StringValue2 = "akyazıcı", IntValue = 5 };
     repository.Insert(item);
     var result = repository.ExistsUniqueItem(item2);
     Assert.IsTrue(result);
 }