public void Delete_Should_Wait_To_Remove_Item_If_Item_Exists_In_BatchMode(ICompoundKeyRepository <User, string, int> repository) { var item = new User { Username = "******", Age = 11, FullName = "Test User - 11" }; repository.Add(item); var result = repository.Get(item.Username, item.Age); result.ShouldNotBeNull(); using (var batch = repository.BeginBatch()) { batch.Delete(item);// not really delete until call Save, because in BatchMode result = repository.Get(item.Username, item.Age); result.ShouldNotBeNull(); batch.Commit(); // actually do the delete } result = repository.Get(item.Username, item.Age); result.ShouldBeNull(); }
public void Join_GetAll_Should_Return_All_Items(ICompoundKeyRepository <User, string, int> repository) { for (var i = 1; i <= 5; i++) { var item = new User { Username = "******" + i.ToString(), Age = (i % 2) + 1, ContactTypeId = i == 1 ? 1 : 2 }; repository.Add(item); } var contactTypeRepository = new InMemoryRepository <ContactType, int>(); contactTypeRepository.Add(new ContactType() { ContactTypeId = 1, Abbreviation = "T1" }); contactTypeRepository.Add(new ContactType() { ContactTypeId = 2, Abbreviation = "T2" }); var compositeRepos = repository.Join(contactTypeRepository, c => c.ContactTypeId, ct => ct.ContactTypeId, (c, ct) => new { Name = c.Username, TypeAbbrev = ct.Abbreviation }); var all = compositeRepos.GetAll().ToList(); all.Count.ShouldBe(5); all.Single(c => c.Name == "Test User 1").TypeAbbrev.ShouldBe("T1"); all.Single(c => c.Name == "Test User 2").TypeAbbrev.ShouldBe("T2"); all.Single(c => c.Name == "Test User 3").TypeAbbrev.ShouldBe("T2"); all.Single(c => c.Name == "Test User 4").TypeAbbrev.ShouldBe("T2"); all.Single(c => c.Name == "Test User 5").TypeAbbrev.ShouldBe("T2"); }
public void TryGet_Should_Return_False_And_Null_If_Item_Does_Not_Exists(ICompoundKeyRepository <User, string, int> repository) { User result; repository.TryGet(string.Empty, 0, out result).ShouldBeFalse(); result.ShouldBeNull(); }
public void Add_Should_Result_In_Proper_Total_Items(ICompoundKeyRepository<User, string, int> repository) { repository.Add(new User { Username = "******", Age = 11, FullName = "Test User - 11"}); var result = repository.GetAll(); result.Count().ShouldEqual(1); }
public void Update_Should_Update_Multiple_Items(ICompoundKeyRepository <User, string, int> repository) { var users = new List <User> { new User { Username = "******", Age = 11, FullName = "Test User - 11" }, new User { Username = "******", Age = 21, FullName = "Test User - 21" }, new User { Username = "******", Age = 11, FullName = "Test User 2- 11" }, }; repository.Add(users); var items = repository.GetAll().ToList(); items.Count().ShouldBe(3); foreach (var user in users.Take(2)) { user.FullName += "UPDATED"; } repository.Update(users); items = repository.GetAll().ToList(); items.Count(x => x.FullName.EndsWith("UPDATED")).ShouldBe(2); }
public void Delete_Should_Remove_Multiple_Items(ICompoundKeyRepository <User, string, int> repository) { IList <User> users = new List <User> { new User { Username = "******", Age = 11, FullName = "Test User - 11" }, new User { Username = "******", Age = 21, FullName = "Test User - 21" }, new User { Username = "******", Age = 11, FullName = "Test User 2- 11" }, }; repository.Add(users); var items = repository.GetAll().ToList(); items.Count().ShouldBe(3); repository.Delete(users.Take(2)); items = repository.GetAll().ToList(); items.Count().ShouldBe(1); items.First().Username.ShouldBe("Test User 2"); }
public void Get_With_String_Selector_Should_Return_Item_If_Item_Exists(ICompoundKeyRepository<User, string, int> repository) { var item = new User { Username = "******", Age = 21 }; repository.Add(item); var result = repository.Get(item.Username, item.Age, c => c.Username); result.ShouldEqual("Test User"); }
public void Add_Should_Result_In_Proper_Total_Items(ICompoundKeyRepository <User, string, int> repository) { repository.Add(new User { Username = "******", Age = 11, FullName = "Test User - 11" }); var result = repository.GetAll(); result.Count().ShouldBe(1); }
public void Find_Should_Return_Single_Item_Which_Satisfies_Composite_Predicate(ICompoundKeyRepository<User, string, int> repository) { for (var i = 1; i <= 3; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.Find(p => p.Username == "Test User 1" || p.Username == "Test User 1000"); result.Username.ShouldEqual("Test User 1"); }
public void GetAll_With_Selector_Should_Return_Every_Item(ICompoundKeyRepository<User, string, int> repository) { for (var i = 1; i <= 5; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.GetAll(c => c.Username); result.Count().ShouldEqual(5); }
public void TryGet_Should_Return_True_If_Item_Exists(ICompoundKeyRepository <User, string, int> repository) { var item = new User { Username = "******", Age = 21 }; repository.Add(item); repository.Exists(item.Username, item.Age).ShouldBeTrue(); }
public void Using_TransactionScope_Without_Complete_Should_Not_Add(ICompoundKeyRepository<User, string, int> repository) { repository.Get("test", 1); // used to create the SqlCe database before being inside the transaction scope since that throws an error using (var trans = new TransactionScope()) { repository.Add(new User { Username = "******", Age = 11, FullName = "Test User - 11" }); } repository.GetAll().Count().ShouldEqual(0); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Composite_Specification(ICompoundKeyRepository<User, string, int> repository) { for (var i = 1; i <= 3; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } var result = repository.FindAll(new Specification<User>(p => p.Username == "Test User 1").OrElse(new Specification<User>(p => p.Username == "Test User 2"))); result.Count().ShouldEqual(2); }
public void Delete_Should_Remove_Item(ICompoundKeyRepository<User, string, int> repository) { var item = new User {Username = "******", Age = 11, FullName = "Test User - 11"}; repository.Add(item); //var result = repository.Get(contact.ContactId); //result.ShouldNotBeNull(); repository.Delete(item); //result = repository.Get(contact.ContactId); //result.ShouldBeNull(); }
public void Get_With_Int_Selector_Should_Return_Item_If_Item_Exists(ICompoundKeyRepository <User, string, int> repository) { var item = new User { Username = "******", Age = 21 }; repository.Add(item); var result = repository.Get(item.Username, item.Age, c => c.Age); result.ShouldBe(21); }
public void Get_Should_Return_Item_If_Item_Exists(ICompoundKeyRepository <User, string, int> repository) { var item = new User { Username = "******", Age = 21 }; repository.Add(item); var result = repository.Get(item.Username, item.Age); result.Username.ShouldEqual(item.Username); result.Age.ShouldEqual(item.Age); }
public void GetAll_With_Selector_Should_Return_Every_Item(ICompoundKeyRepository <User, string, int> repository) { for (var i = 1; i <= 5; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.GetAll(c => c.Username); result.Count().ShouldBe(5); }
public void Delete_Should_Remove_Item_By_Key(ICompoundKeyRepository<User, string, int> repository) { var item = new User { Username = "******", Age = 11, FullName = "Test User - 11" }; repository.Add(item); var result = repository.Get(item.Username, item.Age); result.ShouldNotBeNull(); repository.Delete(item.Username, item.Age); result = repository.Get(item.Username, item.Age); result.ShouldBeNull(); }
public void Find_Should_Return_First_Ordered_Item_Which_Satisfies_Specification_WIth_Sorting_Predicate(ICompoundKeyRepository<User, string, int> repository) { for (var i = 1; i <= 3; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.Find(new Specification<User>(p => p.Username.StartsWith("Test")), new SortingOptions<User, string>(c => c.Username, true)); result.Username.ShouldEqual("Test User 3"); var result2 = repository.Find(new Specification<User>(p => p.Username.StartsWith("Test")), new SortingOptions<User, string>(c => c.Username, false)); result2.Username.ShouldEqual("Test User 1"); }
public void GetAll_Should_Return_Every_Item(ICompoundKeyRepository <User, string, int> repository) { for (var i = 1; i <= 5; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.GetAll().ToList(); result.Count().ShouldEqual(5); }
public void Using_TransactionScope_Without_Complete_Should_Not_Add(ICompoundKeyRepository <User, string, int> repository) { repository.Get("test", 1); // used to create the SqlCe database before being inside the transaction scope since that throws an error using (var trans = new TransactionScope()) { repository.Add(new User { Username = "******", Age = 11, FullName = "Test User - 11" }); } repository.GetAll().Count().ShouldBe(0); }
public void Find_Should_Return_Single_Item_Which_Satisfies_Predicate(ICompoundKeyRepository <User, string, int> repository) { for (var i = 1; i <= 3; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.Find(p => p.Username == "Test User 1"); result.Username.ShouldEqual("Test User 1"); }
public void TryGet_Should_Return_True_And_Item_If_Item_Exists(ICompoundKeyRepository <User, string, int> repository) { var item = new User { Username = "******", Age = 21 }; repository.Add(item); User result; repository.TryGet(item.Username, item.Age, out result).ShouldBeTrue(); result.Username.ShouldEqual(item.Username); result.Age.ShouldEqual(item.Age); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Specification(ICompoundKeyRepository <User, string, int> repository) { for (var i = 1; i <= 3; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } var result = repository.FindAll(new Specification <User>(p => p.Username == "Test User 1")); result.Count().ShouldEqual(1); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Predicate(ICompoundKeyRepository <User, string, int> repository) { for (var i = 1; i <= 3; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } var result = repository.FindAll(p => p.Username == "Test User 1"); // Note: Raven doesn't like p.Name.Equals("..."); result.Count().ShouldEqual(1); }
public void Delete_Should_Remove_Item(ICompoundKeyRepository <User, string, int> repository) { var item = new User { Username = "******", Age = 11, FullName = "Test User - 11" }; repository.Add(item); //var result = repository.Get(contact.ContactId); //result.ShouldNotBeNull(); repository.Delete(item); //result = repository.Get(contact.ContactId); //result.ShouldBeNull(); }
public void Update_Should_Save_Modified_Business_Name(ICompoundKeyRepository<User, string, int> repository) { var item = new User { Username = "******", Age = 22, FullName = "Test User - 22" }; repository.Add(item); var item2 = new User { Username = "******", Age = 22, FullName = "Test User 2 - 22" }; repository.Add(item2); item.FullName = "Test User - 22 - Updated"; repository.Update(item); var updated = repository.Get(item.Username, item.Age); var notUpdated = repository.Get(item2.Username, item2.Age); updated.FullName.ShouldEqual("Test User - 22 - Updated"); notUpdated.FullName.ShouldEqual("Test User 2 - 22"); }
public void Add_InBatchMode_Should_Delay_The_Action(ICompoundKeyRepository<User, string, int> repository) { using (var batch = repository.BeginBatch()) { batch.Add(new User { Username = "******", Age = 11, FullName = "Test User - 11" }); repository.GetAll().Count().ShouldEqual(0); // shouldn't have really been added yet batch.Add(new User { Username = "******", Age = 21, FullName = "Test User - 21" }); repository.GetAll().Count().ShouldEqual(0); // shouldn't have really been added yet batch.Commit(); } repository.GetAll().Count().ShouldEqual(2); }
public void Find_Should_Return_First_Ordered_Item_Which_Satisfies_Predicate(ICompoundKeyRepository <User, string, int> repository) { for (var i = 1; i <= 3; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.Find(p => p.Username.StartsWith("Test"), new SortingOptions <User>("Username", true)); result.Username.ShouldEqual("Test User 3"); var result2 = repository.Find(p => p.Username.StartsWith("Test"), new SortingOptions <User>("Username", false)); result2.Username.ShouldEqual("Test User 1"); }
public void Delete_Should_Remove_Item_By_Key(ICompoundKeyRepository <User, string, int> repository) { var item = new User { Username = "******", Age = 11, FullName = "Test User - 11" }; repository.Add(item); var result = repository.Get(item.Username, item.Age); result.ShouldNotBeNull(); repository.Delete(item.Username, item.Age); result = repository.Get(item.Username, item.Age); result.ShouldBeNull(); }
public void GetAll_With_Selector_Should_Return_Every_Items_With_Paging(ICompoundKeyRepository<User, string, int> repository) { const int resultingPage = 2; const int pageSize = 2; const int totalItems = 5; var queryOptions = new PagingOptions<User>(resultingPage, pageSize, "Username"); for (var i = 1; i <= totalItems; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.GetAll(c => c.Username, queryOptions).ToList(); result.Count().ShouldEqual(pageSize); queryOptions.TotalItems.ShouldEqual(totalItems); result.First().ShouldEqual("Test User 3"); }
public void GetAll_With_Anonymous_Selector_Should_Return_Every_Item(ICompoundKeyRepository<User, string, int> repository) { for (var i = 1; i <= 5; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var results = repository.GetAll(c => new {c.Username, c.Age}); var total = 0; foreach (var result in results) { result.Username.ShouldStartWith("Test User"); total++; } total.ShouldEqual(5); }
public void Delete_Should_Remove_Multiple_Items(ICompoundKeyRepository<User, string, int> repository) { IList<User> users = new List<User> { new User { Username = "******", Age = 11, FullName = "Test User - 11" }, new User { Username = "******", Age = 21, FullName = "Test User - 21" }, new User { Username = "******", Age = 11, FullName = "Test User 2- 11" }, }; repository.Add(users); var items = repository.GetAll().ToList(); items.Count().ShouldEqual(3); repository.Delete(users.Take(2)); items = repository.GetAll().ToList(); items.Count().ShouldEqual(1); items.First().Username.ShouldEqual("Test User 2"); }
public void GetAll_With_Selector_Should_Return_Every_Items_With_Paging(ICompoundKeyRepository <User, string, int> repository) { const int resultingPage = 2; const int pageSize = 2; const int totalItems = 5; var queryOptions = new PagingOptions <User>(resultingPage, pageSize, "Username"); for (var i = 1; i <= totalItems; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var result = repository.GetAll(c => c.Username, queryOptions).ToList(); result.Count().ShouldBe(pageSize); queryOptions.TotalItems.ShouldBe(totalItems); result.First().ShouldBe("Test User 3"); }
public void Add_InBatchMode_Should_Delay_The_Action(ICompoundKeyRepository <User, string, int> repository) { using (var batch = repository.BeginBatch()) { batch.Add(new User { Username = "******", Age = 11, FullName = "Test User - 11" }); repository.GetAll().Count().ShouldBe(0); // shouldn't have really been added yet batch.Add(new User { Username = "******", Age = 21, FullName = "Test User - 21" }); repository.GetAll().Count().ShouldBe(0); // shouldn't have really been added yet batch.Commit(); } repository.GetAll().Count().ShouldBe(2); }
public void Delete_Should_Wait_To_Remove_Item_If_Item_Exists_In_BatchMode(ICompoundKeyRepository<User, string, int> repository) { var item = new User { Username = "******", Age = 11, FullName = "Test User - 11" }; repository.Add(item); var result = repository.Get(item.Username, item.Age); result.ShouldNotBeNull(); using (var batch = repository.BeginBatch()) { batch.Delete(item);// not really delete until call Save, because in BatchMode result = repository.Get(item.Username, item.Age); result.ShouldNotBeNull(); batch.Commit(); // actually do the delete } result = repository.Get(item.Username, item.Age); result.ShouldBeNull(); }
public void GetAll_With_Anonymous_Selector_Should_Return_Every_Item(ICompoundKeyRepository <User, string, int> repository) { for (var i = 1; i <= 5; i++) { repository.Add(new User { Username = "******" + i, Age = i }); } var results = repository.GetAll(c => new { c.Username, c.Age }); var total = 0; foreach (var result in results) { result.Username.ShouldStartWith("Test User"); total++; } total.ShouldBe(5); }
public void Update_Should_Update_Multiple_Items(ICompoundKeyRepository<User, string, int> repository) { var users = new List<User> { new User { Username = "******", Age = 11, FullName = "Test User - 11" }, new User { Username = "******", Age = 21, FullName = "Test User - 21" }, new User { Username = "******", Age = 11, FullName = "Test User 2- 11" }, }; repository.Add(users); var items = repository.GetAll().ToList(); items.Count().ShouldEqual(3); foreach (var user in users.Take(2)) { user.FullName += "UPDATED"; } repository.Update(users); items = repository.GetAll().ToList(); items.Count(x => x.FullName.EndsWith("UPDATED")).ShouldEqual(2); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Composite_Specification_With_Paging_MagicString(ICompoundKeyRepository<User, string, int> repository) { const int resultingPage = 2; const int pageSize = 2; var queryOptions = new PagingOptions<User>(resultingPage, pageSize, "Username"); for (var i = 1; i <= 10; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } IEnumerable<User> result = repository .FindAll(new Specification<User>(p => p.Username == "Test User 1") .OrElse(new Specification<User>(p => p.Username == "Test User 5") .OrElse(new Specification<User>(p => p.Username == "Test User 8"))), queryOptions); result.Count().ShouldEqual(1); queryOptions.TotalItems.ShouldEqual(3); result.First().Username.ShouldEqual("Test User 8"); }
public void Update_Should_Save_Modified_Business_Name(ICompoundKeyRepository <User, string, int> repository) { var item = new User { Username = "******", Age = 22, FullName = "Test User - 22" }; repository.Add(item); var item2 = new User { Username = "******", Age = 22, FullName = "Test User 2 - 22" }; repository.Add(item2); item.FullName = "Test User - 22 - Updated"; repository.Update(item); var updated = repository.Get(item.Username, item.Age); var notUpdated = repository.Get(item2.Username, item2.Age); updated.FullName.ShouldBe("Test User - 22 - Updated"); notUpdated.FullName.ShouldBe("Test User 2 - 22"); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Predicate(ICompoundKeyRepository<User, string, int> repository) { for (var i = 1; i <= 3; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } var result = repository.FindAll(p => p.Username == "Test User 1"); // Note: Raven doesn't like p.Name.Equals("..."); result.Count().ShouldEqual(1); }
public void TryGet_Should_Return_True_And_Item_If_Item_Exists(ICompoundKeyRepository<User, string, int> repository) { var item = new User { Username = "******", Age = 21 }; repository.Add(item); User result; repository.TryGet(item.Username, item.Age, out result).ShouldBeTrue(); result.Username.ShouldEqual(item.Username); result.Age.ShouldEqual(item.Age); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Specification_With_Paging(ICompoundKeyRepository<User, string, int> repository) { const int resultingPage = 2; const int pageSize = 2; const int totalItems = 10; var queryOptions = new PagingOptions<User, string>(resultingPage, pageSize, m => m.Username); for (var i = 1; i <= totalItems; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } var result = repository.FindAll(new Specification<User>(p => p.Age <= totalItems / 2), queryOptions); result.Count().ShouldEqual(pageSize); queryOptions.TotalItems.ShouldEqual(totalItems / 2); result.First().Username.ShouldEqual("Test User 3"); }
public void Get_With_Anonymouse_Class_Selector_Should_Return_Null_If_Item_Does_Not_Exists(ICompoundKeyRepository<User, string, int> repository) { var result = repository.Get(string.Empty, 0, c => new { c.Age, c.Username }); result.ShouldBeNull(); }
public void Get_Should_Return_Null_If_Item_Does_Not_Exists(ICompoundKeyRepository<User, string, int> repository) { var result = repository.Get(string.Empty, 0); result.ShouldBeNull(); }
public void TryGet_Should_Return_False_If_Item_Does_Not_Exists(ICompoundKeyRepository<User, string, int> repository) { repository.Exists(string.Empty, 0).ShouldBeFalse(); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Specification_With_Paging_MagicString(ICompoundKeyRepository <User, string, int> repository) { const int resultingPage = 2; const int pageSize = 2; const int totalItems = 10; var queryOptions = new PagingOptions <User>(resultingPage, pageSize, "Username"); for (var i = 1; i <= totalItems; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } // this fails for RavenDb because the ContactId is an int but is being used as the key, so the check on ContactId <= 5 is doing a string comparison and including ContactId = 10 as well // need to look into why this happens and how to get around it var result = repository.FindAll(new Specification <User>(p => p.Age <= totalItems / 2), queryOptions); result.Count().ShouldEqual(pageSize); queryOptions.TotalItems.ShouldEqual(totalItems / 2); result.First().Username.ShouldEqual("Test User 3"); }
public void Get_With_Int_Selector_Should_Return_Default_If_Item_Does_Not_Exists(ICompoundKeyRepository <User, string, int> repository) { var result = repository.Get(string.Empty, 0, c => c.Age); result.ShouldBe(default(int)); }
public void Get_With_String_Selector_Should_Return_Default_If_Item_Does_Not_Exists(ICompoundKeyRepository<User, string, int> repository) { var result = repository.Get(string.Empty, 0, c => c.Username); result.ShouldEqual(default(string)); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Composite_Specification_With_Paging_MagicString_And_Sort_Descending(ICompoundKeyRepository <User, string, int> repository) { const int resultingPage = 2; const int pageSize = 2; var queryOptions = new PagingOptions <User>(resultingPage, pageSize, "Username", true); for (var i = 1; i <= 10; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } IEnumerable <User> result = repository .FindAll(new Specification <User>(p => p.Username == "Test User 1") .OrElse(new Specification <User>(p => p.Username == "Test User 5") .OrElse(new Specification <User>(p => p.Username == "Test User 8"))), queryOptions); result.Count().ShouldEqual(1); queryOptions.TotalItems.ShouldEqual(3); result.First().Username.ShouldEqual("Test User 1"); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Specification_With_Paging_MagicString(ICompoundKeyRepository<User, string, int> repository) { const int resultingPage = 2; const int pageSize = 2; const int totalItems = 10; var queryOptions = new PagingOptions<User>(resultingPage, pageSize, "Username"); for (var i = 1; i <= totalItems; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } // this fails for RavenDb because the ContactId is an int but is being used as the key, so the check on ContactId <= 5 is doing a string comparison and including ContactId = 10 as well // need to look into why this happens and how to get around it var result = repository.FindAll(new Specification<User>(p => p.Age <= totalItems / 2), queryOptions); result.Count().ShouldEqual(pageSize); queryOptions.TotalItems.ShouldEqual(totalItems / 2); result.First().Username.ShouldEqual("Test User 3"); }
public void FindAll_Should_Return_All_Items_Which_Satisfy_Specification_With_Paging(ICompoundKeyRepository <User, string, int> repository) { const int resultingPage = 2; const int pageSize = 2; const int totalItems = 10; var queryOptions = new PagingOptions <User, string>(resultingPage, pageSize, m => m.Username); for (var i = 1; i <= totalItems; i++) { var contact = new User { Username = "******" + i, Age = i }; repository.Add(contact); } var result = repository.FindAll(new Specification <User>(p => p.Age <= totalItems / 2), queryOptions); result.Count().ShouldEqual(pageSize); queryOptions.TotalItems.ShouldEqual(totalItems / 2); result.First().Username.ShouldEqual("Test User 3"); }
public void Get_With_Anonymouse_Class_Selector_Should_Return_Null_If_Item_Does_Not_Exists(ICompoundKeyRepository <User, string, int> repository) { var result = repository.Get(string.Empty, 0, c => new { c.Age, c.Username }); result.ShouldBeNull(); }
public void Get_Should_Return_Null_If_Item_Does_Not_Exists(ICompoundKeyRepository <User, string, int> repository) { var result = repository.Get(string.Empty, 0); result.ShouldBeNull(); }
public void TryGet_Should_Return_False_If_Item_Does_Not_Exists(ICompoundKeyRepository <User, string, int> repository) { repository.Exists(string.Empty, 0).ShouldBeFalse(); }
public void TryGet_Should_Return_False_And_Null_If_Item_Does_Not_Exists(ICompoundKeyRepository<User, string, int> repository) { User result; repository.TryGet(string.Empty, 0, out result).ShouldBeFalse(); result.ShouldBeNull(); }
public void TryGet_Should_Return_True_If_Item_Exists(ICompoundKeyRepository<User, string, int> repository) { var item = new User { Username = "******", Age = 21 }; repository.Add(item); repository.Exists(item.Username, item.Age).ShouldBeTrue(); }