Exemplo n.º 1
0
        public void Delete_Method()
        {
            Assert.Throws <ArgumentNullException>(() => new EFModelRepository <EFModelEntity>(this.connectionString).Delete(null));

            var entity = new EFModelEntity();

            using (var repository = new EFModelRepository <EFModelEntity>(this.connectionString))
            {
                Assert.Throws <InvalidOperationException>(() => repository.Delete(entity));
                Assert.False(repository.Persist(entity).Delete(entity).Commit().Any());
            }
        }
Exemplo n.º 2
0
        public void Commit_Method()
        {
            var entity = new EFModelEntity();

            using (var repository = new EFModelRepository <EFModelEntity>(this.connectionString))
            {
                Assert.False(repository.Any());

                Assert.True(ReferenceEquals(repository.Persist(entity).Commit(), repository));
                Assert.True(ReferenceEquals(repository.Single(), entity));

                repository.Delete(entity);
                Assert.True(ReferenceEquals(repository.Single(), entity));

                repository.Commit();
                Assert.False(repository.Any());
            }
        }