public void CreateCountryWithFestivalAndCity()
        {
            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
            Type           countryType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.CountryType);
            DynamicContent countryItem = dynamicModuleManager.CreateDataItem(countryType, HierarchicalDynamicContentTests.CountryId, dynamicModuleManager.Provider.ApplicationName);

            countryItem.SetValue("Name", "Test country");
            countryItem.SetValue("Description", "Test Description");
            countryItem.SetString("UrlName", "TestUrlName");
            countryItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            countryItem.SetValue("PublicationDate", DateTime.Now);
            countryItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft");

            Type           cityType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.CityType);
            DynamicContent cityItem = dynamicModuleManager.CreateDataItem(cityType, HierarchicalDynamicContentTests.CityId, dynamicModuleManager.Provider.ApplicationName);

            cityItem.SetValue("Name", "Test Name");
            cityItem.SetValue("History", "Test History");
            cityItem.SetString("UrlName", "TestUrlName");
            cityItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            cityItem.SetValue("PublicationDate", DateTime.Now);
            cityItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft");

            countryItem.AddChildItem(cityItem);

            Type           festivalType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.FestivalType);
            DynamicContent festivalItem = dynamicModuleManager.CreateDataItem(festivalType, HierarchicalDynamicContentTests.FestivalId, dynamicModuleManager.Provider.ApplicationName);

            festivalItem.SetValue("Name", "Test Name");
            festivalItem.SetValue("Description", "Test Description");
            festivalItem.SetValue("From", DateTime.Now);
            festivalItem.SetValue("To", DateTime.Now);
            festivalItem.SetString("UrlName", "TestUrlName");
            festivalItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            festivalItem.SetValue("PublicationDate", DateTime.Now);
            festivalItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft");

            countryItem.AddChildItem(festivalItem);

            dynamicModuleManager.SaveChanges();

            var actualCountry = dynamicModuleManager.GetDataItem(countryType, countryItem.Id);

            Assert.IsNotNull(actualCountry);

            var cityCount     = DynamicContentExtensions.GetChildItemsCount(actualCountry, HierarchicalDynamicContentTests.CityType);
            var festivalCount = DynamicContentExtensions.GetChildItemsCount(actualCountry, HierarchicalDynamicContentTests.FestivalType);

            Assert.AreEqual(cityCount, 1);
            Assert.AreEqual(festivalCount, 1);
        }
        public void CreateCityWithTenHotelsAndTenRestaurant()
        {
            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
            Type           cityType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.CityType);
            DynamicContent cityItem = dynamicModuleManager.CreateDataItem(cityType, HierarchicalDynamicContentTests.CityId, dynamicModuleManager.Provider.ApplicationName);

            cityItem.SetValue("Name", "Test Name");
            cityItem.SetValue("History", "Test History");
            cityItem.SetString("UrlName", "TestUrlName");
            cityItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            cityItem.SetValue("PublicationDate", DateTime.Now);
            cityItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft");

            Type hotelType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.HotelType);

            for (int i = 0; i < 10; i++)
            {
                DynamicContent hotelItem = dynamicModuleManager.CreateDataItem(hotelType);
                hotelItem.SetValue("Name", "Test Name " + i);
                hotelItem.SetValue("Overview", "Test Overview " + i);
                cityItem.AddChildItem(hotelItem);
            }

            Type restaurantType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.RestaurantType);

            for (int i = 0; i < 10; i++)
            {
                DynamicContent restaurantItem = dynamicModuleManager.CreateDataItem(restaurantType);
                restaurantItem.SetValue("Name", "Test Name " + i);
                restaurantItem.SetValue("Description", "Test Description " + i);
                cityItem.AddChildItem(restaurantItem);
            }

            dynamicModuleManager.SaveChanges();

            var actualCity = dynamicModuleManager.GetDataItem(cityType, cityItem.Id);

            Assert.IsNotNull(actualCity);

            var hotelCount      = DynamicContentExtensions.GetChildItemsCount(actualCity, HierarchicalDynamicContentTests.HotelType);
            var restaurantCount = DynamicContentExtensions.GetChildItemsCount(actualCity, HierarchicalDynamicContentTests.RestaurantType);

            Assert.AreEqual(hotelCount, 10);
            Assert.AreEqual(restaurantCount, 10);
        }