コード例 #1
0
        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();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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();
        }
コード例 #5
0
 public IBatch <T> BeginBatch()
 {
     return(Repository.BeginBatch());
 }