Exemplo n.º 1
0
        public void WhenRemovingElementsFromCollection_ThenDoesNotDeleteEntityForAggregateRoot()
        {
            var baz1 = new Baz();
            var baz2 = new Baz();
            var foo  = new Foo
            {
                Name = "Foo",
                Baz  = { baz1, baz2 }
            };

            using (var db = new TestContext())
            {
                db.Save(foo);
                db.SaveChanges();
            }

            using (var db = new TestContext())
            {
                var saved = db.Foos.Include(x => x.Baz).FirstOrDefault(x => x.Name == foo.Name);
                Assert.NotNull(saved);
                Assert.Equal(2, saved.Baz.Count);
            }

            foo.Baz.RemoveAt(0);

            using (var db = new TestContext())
            {
                db.Save(foo);
                db.SaveChanges();
            }

            using (var db = new TestContext())
            {
                var saved = db.Foos.Include(x => x.Baz).FirstOrDefault(x => x.Name == foo.Name);
                Assert.NotNull(saved);
                Assert.Equal(1, saved.Baz.Count);

                // Original instance remains though.
                Assert.Equal(2, db.Set <Baz>().Count());
            }
        }
        public void DisposableImplementationsAreDisposed()
        {
            IConfigurationRoot configuration = GetConfig();

            IBaz baz = configuration.GetSection("baz").CreateReloadingProxy <IBaz>();

            Baz initialBaz = (Baz)((ConfigReloadingProxy <IBaz>)baz).Object;

            Assert.False(initialBaz.IsDisposed);

            ChangeConfig(configuration);

            Baz changedBaz = (Baz)((ConfigReloadingProxy <IBaz>)baz).Object;

            Assert.False(changedBaz.IsDisposed);
            Assert.True(initialBaz.IsDisposed);

            ((IDisposable)baz).Dispose();

            Assert.True(changedBaz.IsDisposed);
        }
Exemplo n.º 3
0
 public void Test3(Baz baz)
 {
 }
Exemplo n.º 4
0
 public void Test2(Baz baz)
 {
 }
Exemplo n.º 5
0
 public void AutoData(int number, Baz baz)
 {
 }
 public Bar(Baz baz)
 {
     _baz = baz;
 }
 public void OnBaz()
 {
     Baz?.Invoke(this, EventArgs.Empty);
 }