Fixes remaining tests

This commit is contained in:
Shannon
2014-03-18 13:08:24 +11:00
parent e40cf3b8fc
commit 0e40971178
9 changed files with 324 additions and 27 deletions

View File

@@ -34,8 +34,7 @@ namespace Umbraco.Tests.TestHelpers
using (DisposableTimer.TraceDuration<BaseUmbracoApplicationTest>("init", "init"))
{
TestHelper.InitializeContentDirectories();
TestHelper.EnsureUmbracoSettingsConfig();
InitializeLegacyMappingsForCoreEditors();
SetupPluginManager();

View File

@@ -113,28 +113,6 @@ namespace Umbraco.Tests.TestHelpers
}
}
//TODO: With the new config updates, I'm pretty sure this isn't needed?
public static void EnsureUmbracoSettingsConfig()
{
var currDir = new DirectoryInfo(CurrentAssemblyDirectory);
var configPath = Path.Combine(currDir.Parent.Parent.FullName, "config");
if (Directory.Exists(configPath) == false)
Directory.CreateDirectory(configPath);
var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
if (File.Exists(umbracoSettingsFile) == false)
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
//Core.Configuration.LegacyUmbracoSettings.SettingsFilePath = IOHelper.MapPath(SystemDirectories.Config + Path.DirectorySeparatorChar, false);
}
public static void CleanUmbracoSettingsConfig()
{
var currDir = new DirectoryInfo(CurrentAssemblyDirectory);

View File

@@ -1,4 +1,5 @@
using NUnit.Framework;
using System.IO;
using NUnit.Framework;
using Umbraco.Core.Services;
using Umbraco.Tests.TestHelpers;
using System;
@@ -14,9 +15,41 @@ namespace Umbraco.Tests.TreesAndSections
///to contain all ApplicationTreeTest Unit Tests
///</summary>
[DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerFixture)]
[TestFixture()]
[TestFixture, RequiresSTA]
public class ApplicationTreeTest : BaseDatabaseFactoryTest
{
[SetUp]
public override void Initialize()
{
base.Initialize();
var treesConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/trees.config");
var appConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/applications.config");
Directory.CreateDirectory(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"));
using (var writer = File.CreateText(treesConfig))
{
writer.Write(ResourceFiles.trees);
}
using (var writer = File.CreateText(appConfig))
{
writer.Write(ResourceFiles.applications);
}
ApplicationTreeService.TreeConfigFilePath = treesConfig;
SectionService.AppConfigFilePath = appConfig;
}
[TearDown]
public override void TearDown()
{
base.TearDown();
if (Directory.Exists(TestHelper.MapPathForTest("~/TEMP/TreesAndSections")))
{
Directory.Delete(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"), true);
}
ApplicationTreeService.TreeConfigFilePath = null;
SectionService.AppConfigFilePath = null;
}
/// <summary>
/// Creates a new app tree linked to an application, then delete the application and make sure the tree is gone as well

View File

@@ -0,0 +1,91 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Umbraco.Tests.TreesAndSections {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class ResourceFiles {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal ResourceFiles() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Umbraco.Tests.TreesAndSections.ResourceFiles", typeof(ResourceFiles).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;applications&gt;
/// &lt;add alias=&quot;content&quot; name=&quot;content&quot; icon=&quot;file&quot; sortOrder=&quot;0&quot; /&gt;
/// &lt;add alias=&quot;0b486ac9c0f1456996192c6ed1f03e57&quot; name=&quot;0b486ac9c0f1456996192c6ed1f03e57&quot; icon=&quot;icon.jpg&quot; sortOrder=&quot;1&quot; /&gt;
/// &lt;add alias=&quot;1ffbc301744c4e75ae3054d741954c7b&quot; name=&quot;1ffbc301744c4e75ae3054d741954c7b&quot; icon=&quot;icon.jpg&quot; sortOrder=&quot;2&quot; /&gt;
/// &lt;add alias=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; name=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; icon=&quot;icon.jpg&quot; sortOrder=&quot;3&quot; /&gt;
/// &lt;add alias=&quot;e5badae2 [rest of string was truncated]&quot;;.
/// </summary>
internal static string applications {
get {
return ResourceManager.GetString("applications", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;trees&gt;
/// &lt;add initialize=&quot;false&quot; sortOrder=&quot;0&quot; alias=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; application=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; title=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; iconClosed=&quot;icon.jpg&quot; iconOpen=&quot;icon.jpg&quot; type=&quot;nulltype&quot; /&gt;
/// &lt;add initialize=&quot;false&quot; sortOrder=&quot;0&quot; alias=&quot;e5badae2fc5e4cd7acb3700320e33b8b&quot; application=&quot;e5badae2fc5e4cd7acb3700320e33b8b&quot; title=&quot;e5badae2fc5e4cd7acb3700320e33b8b&quot; iconClosed=&quot;icon.jpg&quot; iconOpen=&quot;icon.jpg&quot; type=&quot;nulltype&quot; /&gt;
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string trees {
get {
return ResourceManager.GetString("trees", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="applications" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>applications.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="trees" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>trees.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

View File

@@ -1,4 +1,5 @@
using NUnit.Framework;
using System.IO;
using NUnit.Framework;
using Umbraco.Core.Services;
using Umbraco.Tests.TestHelpers;
using umbraco.BusinessLogic;
@@ -18,6 +19,39 @@ namespace Umbraco.Tests.TreesAndSections
public class SectionTests : BaseDatabaseFactoryTest
{
[SetUp]
public override void Initialize()
{
base.Initialize();
var treesConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/trees.config");
var appConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/applications.config");
Directory.CreateDirectory(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"));
using (var writer = File.CreateText(treesConfig))
{
writer.Write(ResourceFiles.trees);
}
using (var writer = File.CreateText(appConfig))
{
writer.Write(ResourceFiles.applications);
}
ApplicationTreeService.TreeConfigFilePath = treesConfig;
SectionService.AppConfigFilePath = appConfig;
}
[TearDown]
public override void TearDown()
{
base.TearDown();
if (Directory.Exists(TestHelper.MapPathForTest("~/TEMP/TreesAndSections")))
{
Directory.Delete(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"), true);
}
ApplicationTreeService.TreeConfigFilePath = null;
SectionService.AppConfigFilePath = null;
}
/// <summary>
/// Create a new application and delete it
///</summary>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<applications>
<add alias="content" name="content" icon="file" sortOrder="0" />
<add alias="0b486ac9c0f1456996192c6ed1f03e57" name="0b486ac9c0f1456996192c6ed1f03e57" icon="icon.jpg" sortOrder="1" />
<add alias="1ffbc301744c4e75ae3054d741954c7b" name="1ffbc301744c4e75ae3054d741954c7b" icon="icon.jpg" sortOrder="2" />
<add alias="1838c3e1591f4008bbafe59a06a00a31" name="1838c3e1591f4008bbafe59a06a00a31" icon="icon.jpg" sortOrder="3" />
<add alias="e5badae2fc5e4cd7acb3700320e33b8b" name="e5badae2fc5e4cd7acb3700320e33b8b" icon="icon.jpg" sortOrder="4" />
<add alias="7ef5094e98b44c7c81049cac17fd0566" name="7ef5094e98b44c7c81049cac17fd0566" icon="icon.jpg" sortOrder="5" />
<add alias="39e14506a6034c9a9aea471878b54733" name="39e14506a6034c9a9aea471878b54733" icon="icon.jpg" sortOrder="6" />
<add alias="a3c13383b3e444b5bc25a79749eb3176" name="a3c13383b3e444b5bc25a79749eb3176" icon="icon.jpg" sortOrder="7" />
<add alias="77c0d250606c4e6da6c7cd14937a38f0" name="77c0d250606c4e6da6c7cd14937a38f0" icon="icon.jpg" sortOrder="8" />
<add alias="9243924456694c6097b04f98e25591bb" name="9243924456694c6097b04f98e25591bb" icon="icon.jpg" sortOrder="9" />
<add alias="b9c3e6664fa348f2a997577650676019" name="b9c3e6664fa348f2a997577650676019" icon="icon.jpg" sortOrder="10" />
<add alias="f3fd12acb6d44d62a3a3e7cddc8dca43" name="f3fd12acb6d44d62a3a3e7cddc8dca43" icon="icon.jpg" sortOrder="11" />
<add alias="05469a0804f3487ebd3882818b098228" name="05469a0804f3487ebd3882818b098228" icon="icon.jpg" sortOrder="12" />
</applications>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<trees>
<add initialize="false" sortOrder="0" alias="1838c3e1591f4008bbafe59a06a00a31" application="1838c3e1591f4008bbafe59a06a00a31" title="1838c3e1591f4008bbafe59a06a00a31" iconClosed="icon.jpg" iconOpen="icon.jpg" type="nulltype" />
<add initialize="false" sortOrder="0" alias="e5badae2fc5e4cd7acb3700320e33b8b" application="e5badae2fc5e4cd7acb3700320e33b8b" title="e5badae2fc5e4cd7acb3700320e33b8b" iconClosed="icon.jpg" iconOpen="icon.jpg" type="nulltype" />
<add initialize="false" sortOrder="0" alias="78e10185a30e4cd889a6d76b9d61603b" application="7ef5094e98b44c7c81049cac17fd0566" title="78e10185a30e4cd889a6d76b9d61603b" iconClosed="icon.jpg" iconOpen="icon.jpg" type="Umbraco.Web.Trees.ContentTreeController, umbraco" />
<add initialize="false" sortOrder="0" alias="f6f8547da73c43268b2866ce46c827cf" application="39e14506a6034c9a9aea471878b54733" title="f6f8547da73c43268b2866ce46c827cf" iconClosed="icon.jpg" iconOpen="icon.jpg" type="Umbraco.Web.Trees.ContentTreeController, umbraco" />
<add initialize="false" sortOrder="0" alias="db96609af99344fbb24b4c418ff64938" application="b9c3e6664fa348f2a997577650676019" title="db96609af99344fbb24b4c418ff64938" iconClosed="icon.jpg" iconOpen="icon.jpg" type="Umbraco.Web.Trees.ContentTreeController, umbraco" />
</trees>

View File

@@ -405,6 +405,11 @@
<Compile Include="TestHelpers\Entities\MockedUser.cs" />
<Compile Include="TestHelpers\Entities\MockedUserType.cs" />
<Compile Include="TestHelpers\RequiresAutoMapperMappingsAttribute.cs" />
<Compile Include="TreesAndSections\ResourceFiles.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>ResourceFiles.resx</DependentUpon>
</Compile>
<Compile Include="TreesAndSections\SectionTests.cs" />
<Compile Include="TreesAndSections\ApplicationTreeTest.cs" />
<Compile Include="PublishedContent\DynamicPublishedContentCustomExtensionMethods.cs" />
@@ -526,6 +531,8 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<EmbeddedResource Include="TreesAndSections\applications.config" />
<EmbeddedResource Include="TreesAndSections\trees.config" />
<None Include="UmbracoExamine\TestFiles\Converting_file_to_PDF.pdf" />
<None Include="UmbracoExamine\TestFiles\PDFStandards.PDF" />
<None Include="UmbracoExamine\TestFiles\SurviorFlipCup.pdf" />
@@ -602,6 +609,10 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ImportResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="TreesAndSections\ResourceFiles.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ResourceFiles.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="UmbracoExamine\TestFiles.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>TestFiles.Designer.cs</LastGenOutput>