Beispiel #1
0
        public void Can_Move()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                ContentTypeRepository repository = ContentTypeRepository;
                var container1 = new EntityContainer(Constants.ObjectTypes.DocumentType)
                {
                    Name = "blah1"
                };
                DocumentTypeContainerRepository.Save(container1);

                var container2 = new EntityContainer(Constants.ObjectTypes.DocumentType)
                {
                    Name = "blah2", ParentId = container1.Id
                };
                DocumentTypeContainerRepository.Save(container2);

                var contentType = (IContentType)ContentTypeBuilder.CreateBasicContentType("asdfasdf");
                contentType.ParentId = container2.Id;
                repository.Save(contentType);

                // create a
                var contentType2 = (IContentType) new ContentType(ShortStringHelper, contentType, "hello")
                {
                    Name = "Blahasdfsadf"
                };
                contentType.ParentId = contentType.Id;
                repository.Save(contentType2);

                global::Umbraco.Cms.Core.Events.MoveEventInfo <IContentType>[] result = repository.Move(contentType, container1).ToArray();

                Assert.AreEqual(2, result.Count());

                // re-get
                contentType  = repository.Get(contentType.Id);
                contentType2 = repository.Get(contentType2.Id);

                Assert.AreEqual(container1.Id, contentType.ParentId);
                Assert.AreNotEqual(result.Single(x => x.Entity.Id == contentType.Id).OriginalPath, contentType.Path);
                Assert.AreNotEqual(result.Single(x => x.Entity.Id == contentType2.Id).OriginalPath, contentType2.Path);
            }
        }