コード例 #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());
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void Test3(Baz baz)
 {
 }
コード例 #4
0
 public void Test2(Baz baz)
 {
 }
コード例 #5
0
 public void AutoData(int number, Baz baz)
 {
 }
コード例 #6
0
 public Bar(Baz baz)
 {
     _baz = baz;
 }
コード例 #7
0
 public void OnBaz()
 {
     Baz?.Invoke(this, EventArgs.Empty);
 }