public void Add_modify_means_changes_on_each_op()
        {
            var context = new OEContext();
            var product = new ProductPoco()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100
            };

            context.Set <ProductPoco>().Add(product);
            Assert.AreEqual(true, context.HasChanges());
            product.UnitPrice++;
            Assert.AreEqual(true, context.HasChanges());
        }
        public void Add_delete_means_no_changes()
        {
            var context = new OEContext();
            var product = new ProductPoco()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100
            };

            context.Set <ProductPoco>().Add(product);
            Assert.AreEqual(true, context.HasChanges());
            context.Set <ProductPoco>().Delete(product);
            Assert.AreEqual(false, context.HasChanges());
        }
        public void Attach_modify_means_changes_at_the_end()
        {
            var context = new OEContext();
            var product = new ProductPoco()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100
            };

            context.Set <ProductPoco>().Attach(product);
            Assert.AreEqual(false, context.HasChanges());
            product.UnitPrice++;
            Assert.AreEqual(true, context.HasChanges());
        }
コード例 #4
0
        public void Attach_detach_means_no_changes()
        {
            var context = new OEContext();
            var product = new Product()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100
            };

            context.Set <Product>().Attach(product);
            Assert.AreEqual(false, context.HasChanges());
            context.Set <Product>().Detach(product);
            Assert.AreEqual(false, context.HasChanges());
        }
        public void Ignore_Attach_modify_no_changes()
        {
            var context = new OEContext();
            var product = new Product()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100,
                Category  = "Test category"
            };

            context.Set <Product>().Attach(product);
            Assert.AreEqual(false, context.HasChanges());
            product.Category = "Modified category";
            Assert.AreEqual(false, context.HasChanges());
        }
        public void CancelChanges_cancels_added_changes()
        {
            var context = new OEContext();
            var product = new ProductPoco()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100
            };

            context.Set <ProductPoco>().Add(product);
            Assert.AreEqual(true, context.HasChanges());
            Assert.AreEqual(1, context.GetChanges().Count());
            context.CancelChanges();
            Assert.AreEqual(false, context.HasChanges());
            Assert.AreEqual(0, context.GetChanges().Count());
        }
コード例 #7
0
        public void ApplyChanges_applies_added_changes()
        {
            var context = new OEContext();
            var product = new Product()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100
            };

            context.Set <Product>().Add(product);
            Assert.AreEqual(true, context.HasChanges());
            Assert.AreEqual(1, context.GetChanges().Count());
            context.ApplyChanges();
            Assert.AreEqual(false, context.HasChanges());
            Assert.AreEqual(0, context.GetChanges().Count());
            Assert.AreEqual(1, context.Set <Product>().GetAll().Count());
        }
コード例 #8
0
        public void CancelChanges_cancels_attached_modified_changes()
        {
            var context = new OEContext();
            var product = new Product()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100
            };

            context.Set <Product>().Attach(product);
            product.UnitPrice++;
            Assert.AreEqual(true, context.HasChanges());
            Assert.AreEqual(1, context.GetChanges().Count());
            context.CancelChanges();
            Assert.AreEqual(false, context.HasChanges());
            Assert.AreEqual(0, context.GetChanges().Count());
        }
コード例 #9
0
        public void Add_means_changes()
        {
            var context = new OEContext();
            var product = new Product()
            {
                Id        = 1,
                Name      = "Test product",
                UnitPrice = 100
            };

            context.Set <Product>().Add(product);
            Assert.AreEqual(true, context.HasChanges());
        }