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 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 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("Test User", 11);

            result.ShouldNotBeNull();

            repository.Delete(item);
            result = repository.Get("Test User", 11);
            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 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 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 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 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 Get_With_Anonymous_Class_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 => new { c.Age, c.Username });

            result.Age.ShouldEqual(21);
            result.Username.ShouldEqual("Test User");
        }
Esempio n. 10
0
        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 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);
        }
Esempio n. 12
0
        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");
        }
Esempio n. 13
0
 public T Get(TKey key, TKey2 key2)
 {
     return(Repository.Get(key, key2));
 }
        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 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 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 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_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));
        }