Ejemplo n.º 1
0
        public void Attaching_one_to_one_aggregate_with_no_key_set_adds_it_instead()
        {
            using var context = new AggregateContext();
            var statistics = new BlogCategoryStatistics();
            var category   = new BlogCategory {
                Statistics = statistics
            };

            context.Attach(category);

            Assert.Equal(EntityState.Added, context.Entry(category).State);
            Assert.Equal(EntityState.Added, context.Entry(category.Statistics).State);
        }
Ejemplo n.º 2
0
        public void Can_add_one_to_one_aggregate()
        {
            using var context = new AggregateContext();
            var statistics = new BlogCategoryStatistics();
            var category   = new BlogCategory {
                Statistics = statistics
            };

            context.Add(category);

            Assert.Equal(EntityState.Added, context.Entry(category).State);
            Assert.Equal(EntityState.Added, context.Entry(category.Statistics).State);
        }
Ejemplo n.º 3
0
        public void Can_attach_one_to_one_aggreate()
        {
            using (var context = new AggregateContext())
            {
                var statistics = new BlogCategoryStatistics { Id = 11, BlogCategoryId = 22 };
                var category = new BlogCategory { Id = 22, Statistics = statistics };

                context.Attach(category);

                Assert.Equal(EntityState.Unchanged, context.Entry(category).State);
                Assert.Equal(EntityState.Unchanged, context.Entry(category.Statistics).State);
            }
        }
Ejemplo n.º 4
0
        public void Can_add_one_to_one_aggreate()
        {
            using (var context = new AggregateContext())
            {
                var statistics = new BlogCategoryStatistics();
                var category = new BlogCategory { Statistics = statistics };

                context.Add(category);

                Assert.Equal(EntityState.Added, context.Entry(category).State);
                Assert.Equal(EntityState.Added, context.Entry(category.Statistics).State);
            }
        }
Ejemplo n.º 5
0
        public void Can_attach_one_to_one_aggregate()
        {
            using var context = new AggregateContext();
            var statistics = new BlogCategoryStatistics {
                Id = 11, BlogCategoryId = 22
            };
            var category = new BlogCategory {
                Id = 22, Statistics = statistics
            };

            context.Attach(category);

            Assert.Equal(EntityState.Unchanged, context.Entry(category).State);
            Assert.Equal(EntityState.Unchanged, context.Entry(category.Statistics).State);
        }
Ejemplo n.º 6
0
        public void One_to_one_dependents_with_no_key_set_are_added()
        {
            using var context = new AggregateContext();
            var statistics = new BlogCategoryStatistics {
                BlogCategoryId = 22
            };
            var category = new BlogCategory {
                Id = 22, Statistics = statistics
            };

            context.Attach(category);

            Assert.Equal(EntityState.Unchanged, context.Entry(category).State);
            Assert.Equal(EntityState.Added, context.Entry(category.Statistics).State);
        }
Ejemplo n.º 7
0
        public void One_to_one_dependents_with_no_key_set_are_added()
        {
            using (var context = new AggregateContext())
            {
                var statistics = new BlogCategoryStatistics { BlogCategoryId = 22 };
                var category = new BlogCategory { Id = 22, Statistics = statistics };

                context.Attach(category);

                Assert.Equal(EntityState.Unchanged, context.Entry(category).State);
                Assert.Equal(EntityState.Added, context.Entry(category.Statistics).State);
            }
        }
Ejemplo n.º 8
0
        public void Attaching_one_to_one_aggregate_with_no_key_set_adds_it_instead()
        {
            using (var context = new AggregateContext())
            {
                var statistics = new BlogCategoryStatistics();
                var category = new BlogCategory { Statistics = statistics };

                context.Attach(category);

                Assert.Equal(EntityState.Added, context.Entry(category).State);
                Assert.Equal(EntityState.Added, context.Entry(category.Statistics).State);
            }
        }