Esempio n. 1
0
 public void AddCategory(Category category)
 {
     using (var session = DocumentStoreFactory.Instance.DocumentStore.OpenSession())
     {
         session.Store(category);
         session.SaveChanges();
     }
 }
        public void AddCategory_AddANewCategory_CategoryIsPersdisted()
        {
            var categoryRepository = new CategoryRepository();
            var category = new Category
                               {
                                   Name = "Building Services"
                               };

            categoryRepository.AddCategory(category);
            Assert.AreEqual("category/Building Services", category.Id);
        }
        public void AddCategory_AddACategoryWithSubCategories_EntireObjectGraphIsPersisted()
        {
            var categoryRepository = new CategoryRepository();
            var category = new Category
            {
                Name = "Advertising",
                SubCategories = new SubCategoryList
                                    {
                                        new SubCategory { Name = "Radio"},
                                        new SubCategory { Name = "Cinema"},
                                        new SubCategory { Name = "Television"},
                                        new SubCategory { Name = "Print"},
                                        new SubCategory { Name = "Web"},
                                        new SubCategory { Name = "Billboards"},
                                        new SubCategory { Name = "Signs"},
                                        new SubCategory { Name = "Signwriting"},
                                        new SubCategory { Name = "Internet"},
                                        new SubCategory { Name = "Other"},
                                    }
            };

            categoryRepository.AddCategory(category);
            Assert.AreEqual("category/Advertising", category.Id);
        }