Esempio n. 1
0
        public override void CreateTestData()
        {
            if (_isSetup == false)
            {
                _isSetup = true;

                base.CreateTestData();

                //Create and Save folder-Media -> 1050
                var folderMediaType = ServiceContext.MediaTypeService.Get(1031);
                var folder          = MockedMedia.CreateMediaFolder(folderMediaType, -1);
                ServiceContext.MediaService.Save(folder, 0);
                folderId = folder.Id;

                //Create and Save image-Media -> 1051
                var imageMediaType = ServiceContext.MediaTypeService.Get(1032);
                var image          = MockedMedia.CreateMediaImage(imageMediaType, folder.Id);
                ServiceContext.MediaService.Save(image, 0);

                //Create and Save file-Media -> 1052
                var fileMediaType = ServiceContext.MediaTypeService.Get(1033);
                var file          = MockedMedia.CreateMediaFile(fileMediaType, folder.Id);
                ServiceContext.MediaService.Save(file, 0);

                var subfolder = MockedMedia.CreateMediaFolder(folderMediaType, folder.Id);
                ServiceContext.MediaService.Save(subfolder, 0);
                var subfolder2 = MockedMedia.CreateMediaFolder(folderMediaType, subfolder.Id);
                ServiceContext.MediaService.Save(subfolder2, 0);
            }
        }
Esempio n. 2
0
        public void SaveMediaMultiple()
        {
            // Arrange
            var provider = TestObjects.GetScopeProvider(Logger);

            using (var scope = provider.CreateScope())
            {
                MediaTypeRepository mediaTypeRepository;
                var repository = CreateRepository(provider, out mediaTypeRepository);

                var mediaType = mediaTypeRepository.Get(1032);
                var file      = MockedMedia.CreateMediaFile(mediaType, -1);

                // Act
                repository.Save(file);

                var image = MockedMedia.CreateMediaImage(mediaType, -1);
                repository.Save(image);

                // Assert
                Assert.That(file.HasIdentity, Is.True);
                Assert.That(image.HasIdentity, Is.True);
                Assert.That(file.Name, Is.EqualTo("Test File"));
                Assert.That(image.Name, Is.EqualTo("Test Image"));
                Assert.That(file.ContentTypeId, Is.EqualTo(mediaType.Id));
                Assert.That(image.ContentTypeId, Is.EqualTo(mediaType.Id));
            }
        }
Esempio n. 3
0
        public void Can_Perform_Multiple_Adds_On_MediaRepository_With_RepositoryResolver()
        {
            // Arrange
            var provider            = new PetaPocoUnitOfWorkProvider();
            var unitOfWork          = provider.GetUnitOfWork();
            var mediaTypeRepository = RepositoryResolver.Current.ResolveByType <IMediaTypeRepository>(unitOfWork);
            var repository          = RepositoryResolver.Current.ResolveByType <IMediaRepository>(unitOfWork);

            var mediaType = mediaTypeRepository.Get(1032);
            var file      = MockedMedia.CreateMediaFile(mediaType, -1);

            // Act
            repository.AddOrUpdate(file);
            unitOfWork.Commit();

            var image = MockedMedia.CreateMediaImage(mediaType, -1);

            repository.AddOrUpdate(image);
            unitOfWork.Commit();

            // Assert
            Assert.That(file.HasIdentity, Is.True);
            Assert.That(image.HasIdentity, Is.True);
            Assert.That(file.Name, Is.EqualTo("Test File"));
            Assert.That(image.Name, Is.EqualTo("Test Image"));
            Assert.That(file.ContentTypeId, Is.EqualTo(mediaType.Id));
            Assert.That(image.ContentTypeId, Is.EqualTo(mediaType.Id));
        }
Esempio n. 4
0
        public void Can_Perform_Multiple_Adds_On_MediaRepository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider(Logger);
            var unitOfWork = provider.GetUnitOfWork();
            MediaTypeRepository mediaTypeRepository;

            using (var repository = CreateRepository(unitOfWork, out mediaTypeRepository))
            {
                var mediaType = mediaTypeRepository.Get(1032);
                var file      = MockedMedia.CreateMediaFile(mediaType, -1);

                // Act
                repository.AddOrUpdate(file);
                unitOfWork.Commit();

                var image = MockedMedia.CreateMediaImage(mediaType, -1);
                repository.AddOrUpdate(image);
                unitOfWork.Commit();

                // Assert
                Assert.That(file.HasIdentity, Is.True);
                Assert.That(image.HasIdentity, Is.True);
                Assert.That(file.Name, Is.EqualTo("Test File"));
                Assert.That(image.Name, Is.EqualTo("Test Image"));
                Assert.That(file.ContentTypeId, Is.EqualTo(mediaType.Id));
                Assert.That(image.ContentTypeId, Is.EqualTo(mediaType.Id));
            }
        }
        public void Is_Media_In_Recycle_Bin(string path, bool isInBin)
        {
            var mediaType = MockedContentTypes.CreateImageMediaType();
            var media     = MockedMedia.CreateMediaFile(mediaType, -1);

            media.Path = path;
            media.Id   = 34;

            Assert.AreEqual(isInBin, media.IsInRecycleBin());
        }
Esempio n. 6
0
        public void CreateTestData()
        {
            //Create and Save folder-Media -> (NodeDto.NodeIdSeed)
            var folderMediaType = ServiceContext.MediaTypeService.Get(1031);
            var folder          = MockedMedia.CreateMediaFolder(folderMediaType, -1);

            ServiceContext.MediaService.Save(folder, 0);

            //Create and Save image-Media -> (NodeDto.NodeIdSeed + 1)
            var imageMediaType = ServiceContext.MediaTypeService.Get(1032);
            var image          = MockedMedia.CreateMediaImage(imageMediaType, folder.Id);

            ServiceContext.MediaService.Save(image, 0);

            //Create and Save file-Media -> (NodeDto.NodeIdSeed + 2)
            var fileMediaType = ServiceContext.MediaTypeService.Get(1033);
            var file          = MockedMedia.CreateMediaFile(fileMediaType, folder.Id);

            ServiceContext.MediaService.Save(file, 0);
        }
Esempio n. 7
0
        public void CreateTestData()
        {
            //Create and Save folder-Media -> 1045
            var folderMediaType = ServiceContext.ContentTypeService.GetMediaType(1031);
            var folder          = MockedMedia.CreateMediaFolder(folderMediaType, -1);

            ServiceContext.MediaService.Save(folder, 0);

            //Create and Save image-Media -> 1046
            var imageMediaType = ServiceContext.ContentTypeService.GetMediaType(1032);
            var image          = MockedMedia.CreateMediaImage(imageMediaType, folder.Id);

            ServiceContext.MediaService.Save(image, 0);

            //Create and Save file-Media -> 1047
            var fileMediaType = ServiceContext.ContentTypeService.GetMediaType(1033);
            var file          = MockedMedia.CreateMediaFile(fileMediaType, folder.Id);

            ServiceContext.MediaService.Save(file, 0);
        }
Esempio n. 8
0
        public void Rebuild_All_Xml_Structures_For_Content_Type()
        {
            var provider   = new PetaPocoUnitOfWorkProvider(Logger);
            var unitOfWork = provider.GetUnitOfWork();
            MediaTypeRepository mediaTypeRepository;

            using (var repository = CreateRepository(unitOfWork, out mediaTypeRepository))
            {
                var imageMediaType  = mediaTypeRepository.Get(1032);
                var fileMediaType   = mediaTypeRepository.Get(1033);
                var folderMediaType = mediaTypeRepository.Get(1031);

                for (var i = 0; i < 30; i++)
                {
                    var image = MockedMedia.CreateMediaImage(imageMediaType, -1);
                    repository.AddOrUpdate(image);
                }
                for (var i = 0; i < 30; i++)
                {
                    var file = MockedMedia.CreateMediaFile(fileMediaType, -1);
                    repository.AddOrUpdate(file);
                }
                for (var i = 0; i < 30; i++)
                {
                    var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
                    repository.AddOrUpdate(folder);
                }
                unitOfWork.Commit();

                //delete all xml
                unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
                Assert.AreEqual(0, unitOfWork.Database.ExecuteScalar <int>("SELECT COUNT(*) FROM cmsContentXml"));

                repository.RebuildXmlStructures(media => new XElement("test"), 10, contentTypeIds: new[] { 1032, 1033 });

                Assert.AreEqual(62, unitOfWork.Database.ExecuteScalar <int>("SELECT COUNT(*) FROM cmsContentXml"));
            }
        }