예제 #1
0
        public void Repository_CreateEntity()
        {
            List <Menu> subMenus = new List <Menu>
            {
                new Menu {
                    ID = 8, Name = "menu 8"
                },
                new Menu {
                    ID = 9, Name = "menu 9"
                }
            };

            var menu = new Menu {
                ID = 7, Name = "menu 7", SubMenus = subMenus
            };

            var menuRepo = new MenuRepo(appContext);
            var result   = menuRepo.CreateEntity(menu);

            appContext.SaveChanges();

            Assert.Equal(8, appContext.Menus.Count());
            Assert.Equal("menu 7", result.Name);
            Assert.Equal(2, result.SubMenus.Count());
        }