Unit test for: U4-2514 Checkboxlist prevalues in packages broken

This commit is contained in:
Sebastiaan Janssen
2013-07-23 16:13:20 +02:00
parent a1037ce43c
commit ca1fe5ff2a
5 changed files with 151 additions and 2 deletions
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<umbPackage>
<files />
<info>
<package>
<name>CheckboxListTest</name>
<version>1</version>
<license url="http://www.opensource.org/licenses/mit-license.php">MIT license</license>
<url>1</url>
<requirements>
<major>3</major>
<minor>0</minor>
<patch>0</patch>
</requirements>
</package>
<author>
<name>1</name>
<website>1</website>
</author>
<readme><![CDATA[]]></readme>
</info>
<Documents>
<DocumentSet importMode="root">
<NewType id="1148" parentID="-1" level="1" creatorID="0" sortOrder="9" createDate="2013-07-23T12:06:07" updateDate="2013-07-23T15:56:37" nodeName="DoIt" urlName="doit" path="-1,1148" isDoc="" nodeType="1134" creatorName="admin" writerName="admin" writerID="0" template="1133" nodeTypeAlias="NewType">
<testList><![CDATA[test3]]></testList>
</NewType>
</DocumentSet>
</Documents>
<DocumentTypes>
<DocumentType>
<Info>
<Name>NewType</Name>
<Alias>NewType</Alias>
<Icon>.sprTreeFolder</Icon>
<Thumbnail>folder.png</Thumbnail>
<Description>
</Description>
<AllowAtRoot>True</AllowAtRoot>
<AllowedTemplates>
<Template>NewType</Template>
</AllowedTemplates>
<DefaultTemplate>NewType</DefaultTemplate>
</Info>
<Structure />
<GenericProperties>
<GenericProperty>
<Name>testList</Name>
<Alias>testList</Alias>
<Type>b4471851-82b6-4c75-afa4-39fa9c6a75e9</Type>
<Definition>8dacee1a-1bbd-46c0-b07f-8ffd49fcca7c</Definition>
<Tab>
</Tab>
<Mandatory>False</Mandatory>
<Validation>
</Validation>
<Description><![CDATA[]]></Description>
</GenericProperty>
</GenericProperties>
<Tabs />
</DocumentType>
</DocumentTypes>
<Templates />
<Stylesheets />
<Macros />
<DictionaryItems />
<Languages />
<DataTypes>
<DataType Name="NewCheckBox" Id="b4471851-82b6-4c75-afa4-39fa9c6a75e9" Definition="8dacee1a-1bbd-46c0-b07f-8ffd49fcca7c" DatabaseType="Nvarchar">
<PreValues>
<PreValue Id="59" Value="test" />
<PreValue Id="60" Value="test3" />
<PreValue Id="61" Value="test2" />
</PreValues>
</DataType>
</DataTypes>
</umbPackage>
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18033
// Runtime Version:4.0.30319.18213
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -60,6 +60,34 @@ namespace Umbraco.Tests.Services.Importing {
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
///&lt;umbPackage&gt;
/// &lt;files /&gt;
/// &lt;info&gt;
/// &lt;package&gt;
/// &lt;name&gt;CheckboxListTest&lt;/name&gt;
/// &lt;version&gt;1&lt;/version&gt;
/// &lt;license url=&quot;http://www.opensource.org/licenses/mit-license.php&quot;&gt;MIT license&lt;/license&gt;
/// &lt;url&gt;1&lt;/url&gt;
/// &lt;requirements&gt;
/// &lt;major&gt;3&lt;/major&gt;
/// &lt;minor&gt;0&lt;/minor&gt;
/// &lt;patch&gt;0&lt;/patch&gt;
/// &lt;/requirements&gt;
/// &lt;/package&gt;
/// &lt;author&gt;
/// &lt;name&gt;1&lt;/name&gt;
/// &lt;website&gt;1&lt;/website&gt;
/// &lt;/author&gt;
/// &lt;r [rest of string was truncated]&quot;;.
/// </summary>
internal static string CheckboxList_Content_Package {
get {
return ResourceManager.GetString("CheckboxList_Content_Package", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
///&lt;umbPackage&gt;
@@ -139,4 +139,7 @@
<data name="TemplateOnly_Updated_Package" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>templateonly-updated-package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="CheckboxList_Content_Package" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>checkboxlist-content-package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
@@ -1,6 +1,9 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using NUnit.Framework;
using Umbraco.Core.Models.Rdbms;
using umbraco.editorControls.MultiNodeTreePicker;
namespace Umbraco.Tests.Services.Importing
{
@@ -213,6 +216,42 @@ namespace Umbraco.Tests.Services.Importing
Assert.That(contents.Count(), Is.EqualTo(numberOfDocs));
}
[Test]
public void PackagingService_Can_Import_CheckboxList_Content_Package_Xml()
{
// Arrange
string strXml = ImportResources.CheckboxList_Content_Package;
var xml = XElement.Parse(strXml);
var dataTypeElement = xml.Descendants("DataTypes").First();
var docTypesElement = xml.Descendants("DocumentTypes").First();
var element = xml.Descendants("DocumentSet").First();
var packagingService = ServiceContext.PackagingService;
// Act
var dataTypeDefinitions = packagingService.ImportDataTypeDefinitions(dataTypeElement);
var contentTypes = packagingService.ImportContentTypes(docTypesElement);
var contents = packagingService.ImportContent(element);
var numberOfDocs = (from doc in element.Descendants()
where (string) doc.Attribute("isDoc") == ""
select doc).Count();
var database = ApplicationContext.DatabaseContext.Database;
var dtos = database.Fetch<DataTypePreValueDto>("WHERE datatypeNodeId = @Id", new { dataTypeDefinitions.First().Id });
int preValueId;
int.TryParse(contents.First().GetValue<string>("testList"), out preValueId);
var preValueKey = dtos.SingleOrDefault(x => x.Id == preValueId);
// Assert
Assert.That(dataTypeDefinitions, Is.Not.Null);
Assert.That(dataTypeDefinitions.Any(), Is.True);
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.That(preValueKey, Is.Not.Null);
Assert.That(preValueKey.Value, Is.EqualTo("test3"));
}
[Test]
public void PackagingService_Can_Import_Templates_Package_Xml_With_Invalid_Master()
{
+3
View File
@@ -506,6 +506,9 @@
<Content Include="Migrations\SqlScripts\SqlCe-SchemaAndData-4110.sql" />
<Content Include="Migrations\SqlScripts\SqlCeTotal-480.sql" />
<Content Include="Migrations\SqlScripts\SqlServerTotal-480.sql" />
<Content Include="Services\Importing\CheckboxList-Content-Package.xml">
<SubType>Designer</SubType>
</Content>
<Content Include="UmbracoExamine\TestFiles\media.xml" />
<Content Include="Services\Importing\InheritedDocTypes-Package.xml" />
<Content Include="Services\Importing\SingleDocType.xml" />