public void Can_Delete_Container_Containing_Media_Types()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                EntityContainerRepository containerRepository = CreateContainerRepository(provider);
                MediaTypeRepository       repository          = CreateRepository(provider);

                var container = new EntityContainer(Constants.ObjectTypes.MediaType)
                {
                    Name = "blah"
                };
                containerRepository.Save(container);

                IMediaType contentType =
                    MediaTypeBuilder.CreateSimpleMediaType("test", "Test", propertyGroupAlias: "testGroup", propertyGroupName: "testGroup");
                contentType.ParentId = container.Id;
                repository.Save(contentType);

                // Act
                containerRepository.Delete(container);

                EntityContainer found = containerRepository.Get(container.Id);
                Assert.IsNull(found);

                contentType = repository.Get(contentType.Id);
                Assert.IsNotNull(contentType);
                Assert.AreEqual(-1, contentType.ParentId);
            }
        }
        public void Can_Move()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                EntityContainerRepository containerRepository = CreateContainerRepository(provider);
                MediaTypeRepository       repository          = CreateRepository(provider);

                var container1 = new EntityContainer(Constants.ObjectTypes.MediaType)
                {
                    Name = "blah1"
                };
                containerRepository.Save(container1);

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

                IMediaType contentType =
                    MediaTypeBuilder.CreateNewMediaType();
                contentType.ParentId = container2.Id;
                repository.Save(contentType);

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

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

                Assert.AreEqual(2, result.Length);

                // 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);
            }
        }
        public void Can_Create_Container()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                EntityContainerRepository containerRepository = CreateContainerRepository(provider);

                var container = new EntityContainer(Constants.ObjectTypes.MediaType)
                {
                    Name = "blah"
                };
                containerRepository.Save(container);

                Assert.That(container.Id, Is.GreaterThan(0));

                EntityContainer found = containerRepository.Get(container.Id);
                Assert.IsNotNull(found);
            }
        }