Esempio n. 1
0
        public void Can_Import_Content_Package_Xml()
        {
            // Arrange
            string   strXml          = ImportResources.StandardMvc_Package;
            var      xml             = XElement.Parse(strXml);
            XElement dataTypeElement = xml.Descendants("DataTypes").First();
            XElement docTypesElement = xml.Descendants("DocumentTypes").First();
            XElement element         = xml.Descendants("DocumentSet").First();
            var      packageDocument = CompiledPackageContentBase.Create(element);

            // Act
            IReadOnlyList <IDataType>    dataTypeDefinitions = PackageDataInstallation.ImportDataTypes(dataTypeElement.Elements("DataType").ToList(), 0);
            IReadOnlyList <IContentType> contentTypes        = PackageDataInstallation.ImportDocumentTypes(docTypesElement.Elements("DocumentType"), 0);
            var importedContentTypes          = contentTypes.ToDictionary(x => x.Alias, x => x);
            IReadOnlyList <IContent> contents = PackageDataInstallation.ImportContentBase(packageDocument.Yield(), importedContentTypes, 0, ContentTypeService, ContentService);
            int numberOfDocs = (from doc in element.Descendants()
                                where (string)doc.Attribute("isDoc") == string.Empty
                                select doc).Count();

            // Assert
            Assert.That(contents, Is.Not.Null);
            Assert.That(dataTypeDefinitions.Any(), Is.True);
            Assert.That(contentTypes.Any(), Is.True);
            Assert.That(contents.Any(), Is.True);
            Assert.That(contents.Count(), Is.EqualTo(numberOfDocs));
        }
Esempio n. 2
0
    private void AssertCheckBoxListTests(string strXml)
    {
        // Arrange
        var xml             = XElement.Parse(strXml);
        var dataTypeElement = xml.Descendants("DataTypes").First();
        var docTypesElement = xml.Descendants("DocumentTypes").First();
        var element         = xml.Descendants("DocumentSet").First();
        var packageDocument = CompiledPackageContentBase.Create(element);

        // Act
        var dataTypeDefinitions =
            PackageDataInstallation.ImportDataTypes(dataTypeElement.Elements("DataType").ToList(), 0);
        var contentTypes         = PackageDataInstallation.ImportDocumentTypes(docTypesElement.Elements("DocumentType"), 0);
        var importedContentTypes = contentTypes.ToDictionary(x => x.Alias, x => x);
        var contents             = PackageDataInstallation.ImportContentBase(packageDocument.Yield(), importedContentTypes, 0, ContentTypeService, ContentService);
        var numberOfDocs         = (from doc in element.Descendants()
                                    where (string)doc.Attribute("isDoc") == string.Empty
                                    select doc).Count();

        string configuration;

        using (var scope = ScopeProvider.CreateScope())
        {
            var dtos = ScopeAccessor.AmbientScope.Database.Fetch <DataTypeDto>("WHERE nodeId = @Id", new { dataTypeDefinitions.First().Id });
            configuration = dtos.Single().Configuration;
        }

        // Assert
        Assert.That(dataTypeDefinitions, Is.Not.Null);
        Assert.That(dataTypeDefinitions.Any(), Is.True);
        Assert.AreEqual(Constants.PropertyEditors.Aliases.CheckBoxList, dataTypeDefinitions.First().EditorAlias);
        Assert.That(contents, Is.Not.Null);
        Assert.That(contentTypes.Any(), Is.True);
        Assert.That(contents.Any(), Is.True);
        Assert.That(contents.Count(), Is.EqualTo(numberOfDocs));
        Assert.AreEqual(
            "{\"items\":[{\"id\":59,\"value\":\"test\"},{\"id\":60,\"value\":\"test3\"},{\"id\":61,\"value\":\"test2\"}]}",
            configuration);
    }
Esempio n. 3
0
        public void Can_Import_Media_Package_Xml()
        {
            // Arrange
            string   strXml            = ImportResources.MediaTypesAndMedia_Package_xml;
            var      xml               = XElement.Parse(strXml);
            XElement mediaTypesElement = xml.Descendants("MediaTypes").First();
            XElement element           = xml.Descendants("MediaSet").First();
            var      packageMedia      = CompiledPackageContentBase.Create(element);

            // Act
            IReadOnlyList <IMediaType> mediaTypes = PackageDataInstallation.ImportMediaTypes(mediaTypesElement.Elements("MediaType"), 0);
            var importedMediaTypes        = mediaTypes.ToDictionary(x => x.Alias, x => x);
            IReadOnlyList <IMedia> medias = PackageDataInstallation.ImportContentBase(packageMedia.Yield(), importedMediaTypes, 0, MediaTypeService, MediaService);
            int numberOfDocs = (from doc in element.Descendants()
                                where (string)doc.Attribute("isDoc") == string.Empty
                                select doc).Count();

            // Assert
            Assert.That(medias, Is.Not.Null);
            Assert.That(mediaTypes.Any(), Is.True);
            Assert.That(medias.Any(), Is.True);
            Assert.That(medias.Count(), Is.EqualTo(numberOfDocs));
        }