コード例 #1
0
        public void Get_All_For_Content()
        {
            int contentId = CreateTestData("en-AU", out ContentType ct);

            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                DomainRepository repo = CreateRepository(provider);

                var contentItems = new List <IContent>();

                ILanguage lang = LanguageRepository.GetByIsoCode("en-AU");
                contentItems.Add(DocumentRepository.Get(contentId));

                // more test data (3 content items total)
                for (int i = 0; i < 2; i++)
                {
                    var c = new Content("test" + i, -1, ct)
                    {
                        CreatorId = 0, WriterId = 0
                    };
                    DocumentRepository.Save(c);
                    contentItems.Add(c);
                }

                for (int i = 0; i < 10; i++)
                {
                    var domain = (IDomain) new UmbracoDomain((i % 2 == 0) ? "test " + i + ".com" : ("*" + i))
                    {
                        RootContentId = ((i % 2 == 0) ? contentItems[0] : contentItems[1]).Id,
                        LanguageId    = lang.Id
                    };
                    repo.Save(domain);
                }

                IEnumerable <IDomain> all1 = repo.GetAssignedDomains(contentItems[0].Id, true);
                Assert.AreEqual(5, all1.Count());

                IEnumerable <IDomain> all2 = repo.GetAssignedDomains(contentItems[1].Id, true);
                Assert.AreEqual(5, all2.Count());

                IEnumerable <IDomain> all3 = repo.GetAssignedDomains(contentItems[2].Id, true);
                Assert.AreEqual(0, all3.Count());
            }
        }