Exemplo n.º 1
0
        public void HasChanges_return_true_if_context_have_entities_in_modified_state()
        {
            using (var context = new SomeContext())
            {
                context.Entry(new Foo { Bar = "the foo" }).State = EntityState.Modified;

                Assert.True(context.ChangeTracker.HasChanges());
            }
        }
Exemplo n.º 2
0
        public void HasChanges_return_true_if_context_have_entities_in_added_state()
        {
            using (var context = new SomeContext())
            {
                context.Foos.AddRange(new[] { new Foo { Bar = "the foo" }, new Foo { Bar = "the foo" } });

                Assert.True(context.ChangeTracker.HasChanges());
            }
        }
Exemplo n.º 3
0
        public void HasChanges_return_false_if_context_dont_have_changes()
        {
            using (var context = new SomeContext())
            {
                context.Foos.Attach(new Foo { Bar = "bar" });

                Assert.False(context.ChangeTracker.HasChanges());
            }
        }
Exemplo n.º 4
0
        public void HasChanges_return_true_if_context_have_entities_in_modified_state()
        {
            using (var context = new SomeContext())
            {
                context.Entry(new Foo {
                    Bar = "the foo"
                }).State = EntityState.Modified;

                Assert.True(context.ChangeTracker.HasChanges());
            }
        }
Exemplo n.º 5
0
        public void HasChanges_return_false_if_context_dont_have_changes()
        {
            using (var context = new SomeContext())
            {
                context.Foos.Attach(new Foo {
                    Bar = "bar"
                });

                Assert.False(context.ChangeTracker.HasChanges());
            }
        }
Exemplo n.º 6
0
        public void HasChanges_return_true_if_context_have_entities_in_added_state()
        {
            using (var context = new SomeContext())
            {
                context.Foos.AddRange(new[] { new Foo {
                                                  Bar = "the foo"
                                              }, new Foo {
                                                  Bar = "the foo"
                                              } });

                Assert.True(context.ChangeTracker.HasChanges());
            }
        }
Exemplo n.º 7
0
        public void HasChanges_does_not_call_DetectChanges_if_it_has_been_disabled()
        {
            using (var context = new SomeContext())
            {
                var foo = context.Foos.Attach(new Foo { Bar = "the foo" });

                context.Configuration.AutoDetectChangesEnabled = false;

                foo.Bar = "the bar";

                Assert.False(context.ChangeTracker.HasChanges());

                context.ChangeTracker.DetectChanges();

                Assert.True(context.ChangeTracker.HasChanges());
            }
        }
Exemplo n.º 8
0
        public void HasChanges_does_not_call_DetectChanges_if_it_has_been_disabled()
        {
            using (var context = new SomeContext())
            {
                var foo = context.Foos.Attach(new Foo {
                    Bar = "the foo"
                });

                context.Configuration.AutoDetectChangesEnabled = false;

                foo.Bar = "the bar";

                Assert.False(context.ChangeTracker.HasChanges());

                context.ChangeTracker.DetectChanges();

                Assert.True(context.ChangeTracker.HasChanges());
            }
        }