public void Create_Catalog_With_Categories_And_Subcategories_And_Products() { var catalog = new CatalogBuilder() .AddCategory("Toys") .AddSubcategory("Puzzles") .AddProduct("Rubik's Cube") .AddSubcategory("Games") .AddProduct("Battleship") .AddProduct("Monopoly") .Build(); WhenCatalogIsCreated(catalog); var resultCatalog = ThenThereShouldBeOneResult(); resultCatalog .ShouldBeNamed("Department Store") .ShouldHaveCategories("Toys", "Puzzles", "Games"); resultCatalog.Categories[0] .ShouldBeATopLevelCategoryNamed("Toys") .ShouldHaveNoProducts() .ShouldHaveSubcategories("Puzzles", "Games"); resultCatalog.Categories[0].Subcategories[0] .ShouldBeNamed("Puzzles") .ShouldHaveProducts("Rubik's Cube") .ShouldHaveNoSubcategories(); resultCatalog.Categories[0].Subcategories[1] .ShouldBeNamed("Games") .ShouldHaveProducts("Battleship", "Monopoly") .ShouldHaveNoSubcategories(); }
public void Create_Catalog_With_Categories_And_Products() { var catalog = new CatalogBuilder() .AddCategory("Toys") .AddProduct("Rubik's Cube") .AddProduct("Etch A Sketch") .AddCategory("Home & Garden") .AddProduct("Adirondack Chair") .Build(); WhenCatalogIsCreated(catalog); var resultCatalog = ThenThereShouldBeOneResult(); resultCatalog .ShouldBeNamed("Department Store") .ShouldHaveCategories("Toys", "Home & Garden"); resultCatalog.Categories[0] .ShouldBeATopLevelCategoryNamed("Toys") .ShouldHaveProducts("Rubik's Cube", "Etch A Sketch") .ShouldHaveNoSubcategories(); resultCatalog.Categories[1] .ShouldBeATopLevelCategoryNamed("Home & Garden") .ShouldHaveProducts("Adirondack Chair") .ShouldHaveNoSubcategories(); }
public void Serialize_Catalog_With_Categories_And_Products() { var catalog = new CatalogBuilder() .AddCategory("Toys") .AddProduct("Rubik's Cube") .AddProduct("Etch A Sketch") .AddCategory("Home & Garden") .AddProduct("Adirondack Chair") .Build(); GivenTheCatalogHasBeenCreated(catalog); WhenTheCatalogIsSerialized(catalog.Id); ThenTheResultIs( @"<?xml version=""1.0"" encoding=""utf-16""?> <Catalog xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <Id>1</Id> <Name>Department Store</Name> <Categories> <Category> <Id>1</Id> <Name>Toys</Name> <CatalogId>1</CatalogId> <ParentCategoryId xsi:nil=""true"" /> <Subcategories /> <Products> <Product> <Id>1</Id> <Name>Rubik's Cube</Name> <CategoryId>1</CategoryId> </Product> <Product> <Id>2</Id> <Name>Etch A Sketch</Name> <CategoryId>1</CategoryId> </Product> </Products> </Category> <Category> <Id>2</Id> <Name>Home & Garden</Name> <CatalogId>1</CatalogId> <ParentCategoryId xsi:nil=""true"" /> <Subcategories /> <Products> <Product> <Id>3</Id> <Name>Adirondack Chair</Name> <CategoryId>2</CategoryId> </Product> </Products> </Category> </Categories> </Catalog>"); }