Merge branch 'temp8' into temp-editing-all-variants
# Conflicts: # src/Umbraco.Web/Editors/ContentController.cs # src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs # src/Umbraco.Web/Models/Mapping/MediaMapperProfile.cs
This commit is contained in:
@@ -16,28 +16,28 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public void EmailAddress()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.NotificationEmailAddress == "robot@umbraco.dk");
|
||||
Assert.AreEqual(SettingsSection.Content.NotificationEmailAddress, "robot@umbraco.dk");
|
||||
}
|
||||
[Test]
|
||||
public virtual void DisableHtmlEmail()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail == true);
|
||||
Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public virtual void Can_Set_Multiple()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.Count() == 3);
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).Culture == "default");
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId == 1047);
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.Count(), 3);
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).Culture, "default");
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId, 1047);
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentId);
|
||||
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentKey);
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(1).Culture == "en-US");
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath == "$site/error [@name = 'error']");
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).Culture, "en-US");
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']");
|
||||
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentId);
|
||||
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentKey);
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).Culture == "en-UK");
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey == new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).Culture, "en-UK");
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentKey);
|
||||
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentId);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public void ScriptFolderPath()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ScriptFolderPath == "/scripts");
|
||||
Assert.AreEqual(SettingsSection.Content.ScriptFolderPath, "/scripts");
|
||||
}
|
||||
[Test]
|
||||
public void ScriptFileTypes()
|
||||
@@ -55,7 +55,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public void DisableScriptEditor()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ScriptEditorDisable == false);
|
||||
Assert.AreEqual(SettingsSection.Content.ScriptEditorDisable, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -71,80 +71,79 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public virtual void ImageAutoFillProperties()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.Count() == 2);
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias == "umbracoFile2");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias == "umbracoWidth2");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias == "umbracoHeight2");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias == "umbracoBytes2");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias == "umbracoExtension2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.Count(), 2);
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UploadAllowDirectories()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.UploadAllowDirectories == true);
|
||||
Assert.IsTrue(SettingsSection.Content.UploadAllowDirectories);
|
||||
}
|
||||
[Test]
|
||||
public void DefaultDocumentTypeProperty()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.DefaultDocumentTypeProperty == "Textstring");
|
||||
Assert.AreEqual(SettingsSection.Content.DefaultDocumentTypeProperty, "Textstring");
|
||||
}
|
||||
[Test]
|
||||
public void GlobalPreviewStorageEnabled()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.GlobalPreviewStorageEnabled == false);
|
||||
Assert.IsFalse(SettingsSection.Content.GlobalPreviewStorageEnabled);
|
||||
}
|
||||
[Test]
|
||||
public void CloneXmlContent()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.CloneXmlContent == true);
|
||||
Assert.IsTrue(SettingsSection.Content.CloneXmlContent);
|
||||
}
|
||||
[Test]
|
||||
public void EnsureUniqueNaming()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.EnsureUniqueNaming == true);
|
||||
Assert.IsTrue(SettingsSection.Content.EnsureUniqueNaming);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ForceSafeAliases()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ForceSafeAliases == true);
|
||||
Assert.IsTrue(SettingsSection.Content.ForceSafeAliases);
|
||||
}
|
||||
[Test]
|
||||
public void XmlCacheEnabled()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.XmlCacheEnabled == true);
|
||||
Assert.IsTrue(SettingsSection.Content.XmlCacheEnabled);
|
||||
}
|
||||
[Test]
|
||||
public void ContinouslyUpdateXmlDiskCache()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ContinouslyUpdateXmlDiskCache == true);
|
||||
Assert.IsTrue(SettingsSection.Content.ContinouslyUpdateXmlDiskCache);
|
||||
}
|
||||
[Test]
|
||||
public virtual void XmlContentCheckForDiskChanges()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.XmlContentCheckForDiskChanges == true);
|
||||
Assert.IsTrue(SettingsSection.Content.XmlContentCheckForDiskChanges);
|
||||
}
|
||||
[Test]
|
||||
public void EnableSplashWhileLoading()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.EnableSplashWhileLoading == false);
|
||||
Assert.IsFalse(SettingsSection.Content.EnableSplashWhileLoading);
|
||||
}
|
||||
[Test]
|
||||
public void PropertyContextHelpOption()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.PropertyContextHelpOption == "text");
|
||||
Assert.AreEqual(SettingsSection.Content.PropertyContextHelpOption, "text");
|
||||
}
|
||||
[Test]
|
||||
public void PreviewBadge()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.PreviewBadge == @"<a id=""umbracoPreviewBadge"" style=""position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;"" href=""{0}/endPreview.aspx?redir={1}""><span style=""display:none;"">In Preview Mode - click to end</span></a>");
|
||||
Assert.AreEqual(SettingsSection.Content.PreviewBadge, @"<a id=""umbracoPreviewBadge"" style=""z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;"" href=""#"" OnClick=""javascript:window.top.location.href = '{0}/endPreview.aspx?redir={1}'""><span style=""display:none;"">In Preview Mode - click to end</span></a>");
|
||||
}
|
||||
[Test]
|
||||
public void ResolveUrlsFromTextString()
|
||||
@@ -154,7 +153,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public void MacroErrors()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.MacroErrorBehaviour == MacroErrorBehaviour.Inline);
|
||||
Assert.AreEqual(SettingsSection.Content.MacroErrorBehaviour, MacroErrorBehaviour.Inline);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -75,7 +75,10 @@
|
||||
|
||||
<ForceSafeAliases>true</ForceSafeAliases>
|
||||
|
||||
<PreviewBadge><![CDATA[<a id="umbracoPreviewBadge" style="position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;" href="{0}/endPreview.aspx?redir={1}"><span style="display:none;">In Preview Mode - click to end</span></a>]]></PreviewBadge>
|
||||
<PreviewBadge>
|
||||
<![CDATA[
|
||||
<a id="umbracoPreviewBadge" style="z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;" href="#" OnClick="javascript:window.top.location.href = '{0}/endPreview.aspx?redir={1}'"><span style="display:none;">In Preview Mode - click to end</span></a>
|
||||
]]></PreviewBadge>
|
||||
|
||||
<!-- How Umbraco should handle errors during macro execution. Can be one of the following values:
|
||||
- inline - show an inline error within the macro but allow the page to continue rendering. Historial Umbraco behaviour.
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace Umbraco.Tests.FrontEnd
|
||||
{
|
||||
Current.Reset();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Truncate_Simple()
|
||||
{
|
||||
@@ -164,7 +163,7 @@ namespace Umbraco.Tests.FrontEnd
|
||||
|
||||
var result = helper.StripHtml(SampleWithBoldAndAnchorElements, tags).ToString();
|
||||
|
||||
Assert.AreEqual("Hello world, this is some text <a href='blah'>with a link</a>", result);
|
||||
Assert.AreEqual(SampleWithAnchorElement, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -179,236 +178,6 @@ namespace Umbraco.Tests.FrontEnd
|
||||
Assert.AreEqual("Hello world, is some text with a link", result);
|
||||
}
|
||||
|
||||
// ------- Int32 conversion tests
|
||||
[Test]
|
||||
public static void Converting_boxed_34_to_an_int_returns_34()
|
||||
{
|
||||
// Arrange
|
||||
const int sample = 34;
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToInt(
|
||||
sample,
|
||||
out int result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(34));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_string_54_to_an_int_returns_54()
|
||||
{
|
||||
// Arrange
|
||||
const string sample = "54";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToInt(
|
||||
sample,
|
||||
out int result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(54));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_hello_to_an_int_returns_false()
|
||||
{
|
||||
// Arrange
|
||||
const string sample = "Hello";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToInt(
|
||||
sample,
|
||||
out int result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_unsupported_object_to_an_int_returns_false()
|
||||
{
|
||||
// Arrange
|
||||
var clearlyWillNotConvertToInt = new StringBuilder(0);
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToInt(
|
||||
clearlyWillNotConvertToInt,
|
||||
out int result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
// ------- GUID conversion tests
|
||||
[Test]
|
||||
public static void Converting_boxed_guid_to_a_guid_returns_original_guid_value()
|
||||
{
|
||||
// Arrange
|
||||
Guid sample = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToGuid(
|
||||
sample,
|
||||
out Guid result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_string_guid_to_a_guid_returns_original_guid_value()
|
||||
{
|
||||
// Arrange
|
||||
Guid sample = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToGuid(
|
||||
sample.ToString(),
|
||||
out Guid result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_hello_to_a_guid_returns_false()
|
||||
{
|
||||
// Arrange
|
||||
const string sample = "Hello";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToGuid(
|
||||
sample,
|
||||
out Guid result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.EqualTo(new Guid("00000000-0000-0000-0000-000000000000")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_unsupported_object_to_a_guid_returns_false()
|
||||
{
|
||||
// Arrange
|
||||
var clearlyWillNotConvertToGuid = new StringBuilder(0);
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToGuid(
|
||||
clearlyWillNotConvertToGuid,
|
||||
out Guid result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.EqualTo(new Guid("00000000-0000-0000-0000-000000000000")));
|
||||
}
|
||||
|
||||
// ------- UDI Conversion Tests
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before
|
||||
/// running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public static void Converting_boxed_udi_to_a_udi_returns_original_udi_value()
|
||||
{
|
||||
// Arrange
|
||||
Udi.ResetUdiTypes();
|
||||
Udi sample = new GuidUdi(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
sample,
|
||||
out Udi result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before
|
||||
/// running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void Converting_string_udi_to_a_udi_returns_original_udi_value()
|
||||
{
|
||||
// Arrange
|
||||
SetUpDependencyContainer();
|
||||
Udi.ResetUdiTypes();
|
||||
Udi sample = new GuidUdi(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
sample.ToString(),
|
||||
out Udi result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success, "Conversion of UDI failed.");
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before
|
||||
/// running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void Converting_hello_to_a_udi_returns_false()
|
||||
{
|
||||
// Arrange
|
||||
SetUpDependencyContainer();
|
||||
Udi.ResetUdiTypes();
|
||||
const string sample = "Hello";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
sample,
|
||||
out Udi result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before
|
||||
/// running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public static void Converting_unsupported_object_to_a_udi_returns_false()
|
||||
{
|
||||
// Arrange
|
||||
Udi.ResetUdiTypes();
|
||||
|
||||
var clearlyWillNotConvertToGuid = new StringBuilder(0);
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
clearlyWillNotConvertToGuid,
|
||||
out Udi result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
|
||||
// ------- Int32 conversion tests
|
||||
[Test]
|
||||
public static void Converting_Boxed_34_To_An_Int_Returns_34()
|
||||
@@ -548,13 +317,14 @@ namespace Umbraco.Tests.FrontEnd
|
||||
}
|
||||
|
||||
// ------- UDI Conversion Tests
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void Converting_Boxed_Udi_To_A_Udi_Returns_Original_Udi_Value()
|
||||
public static void Converting_Boxed_Udi_To_A_Udi_Returns_Original_Udi_Value()
|
||||
{
|
||||
// Arrange
|
||||
SetUpDependencyContainer();
|
||||
Udi.ResetUdiTypes();
|
||||
|
||||
Udi sample = new GuidUdi(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
@@ -568,13 +338,15 @@ namespace Umbraco.Tests.FrontEnd
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void Converting_String_Udi_To_A_Udi_Returns_Original_Udi_Value()
|
||||
{
|
||||
// Arrange
|
||||
SetUpDependencyContainer();
|
||||
Udi.ResetUdiTypes();
|
||||
|
||||
Udi sample = new GuidUdi(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
@@ -584,22 +356,24 @@ namespace Umbraco.Tests.FrontEnd
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.IsTrue(success, "Conversion of UDI failed.");
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void Converting_Hello_To_A_Udi_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
SetUpDependencyContainer();
|
||||
Udi.ResetUdiTypes();
|
||||
|
||||
const string SAMPLE = "Hello";
|
||||
const string sample = "Hello";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
SAMPLE,
|
||||
sample,
|
||||
out Udi result
|
||||
);
|
||||
|
||||
@@ -608,11 +382,13 @@ namespace Umbraco.Tests.FrontEnd
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void Converting_Unsupported_Object_To_A_Udi_Returns_False()
|
||||
public static void Converting_Unsupported_Object_To_A_Udi_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
SetUpDependencyContainer();
|
||||
Udi.ResetUdiTypes();
|
||||
|
||||
var clearlyWillNotConvertToGuid = new StringBuilder(0);
|
||||
|
||||
@@ -112,7 +112,9 @@ namespace Umbraco.Tests.PublishedContent
|
||||
<testRecursive><![CDATA[]]></testRecursive>
|
||||
</Home>
|
||||
<CustomDocument id=""1177"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""2"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""custom sub 1"" urlName=""custom-sub-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1177"" isDoc="""" />
|
||||
<CustomDocument id=""1178"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""3"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-16T14:23:35"" nodeName=""custom sub 2"" urlName=""custom-sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1178"" isDoc="""" />
|
||||
<CustomDocument id=""1178"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""3"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-16T14:23:35"" nodeName=""custom sub 2"" urlName=""custom-sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1178"" isDoc="""">
|
||||
<CustomDocument id=""1179"" parentID=""1178"" level=""4"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""1"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""custom sub sub 1"" urlName=""custom-sub-sub-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1178,1179"" isDoc="""" />
|
||||
</CustomDocument>
|
||||
<Home id=""1176"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""4"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""sub-3"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1176"" isDoc="""" key=""CDB83BBC-A83B-4BA6-93B8-AADEF67D3C09"">
|
||||
<content><![CDATA[]]></content>
|
||||
<umbracoNaviHide>1</umbracoNaviHide>
|
||||
@@ -322,7 +324,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
var doc = GetNode(1046);
|
||||
|
||||
var expected = new[] {1046, 1173, 1174, 1177, 1178, 1176, 1175, 4444, 1172};
|
||||
var expected = new[] { 1046, 1173, 1174, 1177, 1178, 1179, 1176, 1175, 4444, 1172 };
|
||||
var exindex = 0;
|
||||
|
||||
// must respect the XPath descendants-or-self axis!
|
||||
@@ -559,6 +561,93 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Assert.IsTrue(result.Select(x => ((dynamic)x).Id).ContainsAll(new dynamic[] { 1173, 1046 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsAncestor()
|
||||
{
|
||||
// Structure:
|
||||
// - Root : 1046 (no parent)
|
||||
// -- Home: 1173 (parent 1046)
|
||||
// -- Custom Doc: 1178 (parent 1173)
|
||||
// --- Custom Doc2: 1179 (parent: 1178)
|
||||
// - Custom Doc3: 1172 (no parent)
|
||||
|
||||
var home = GetNode(1173);
|
||||
var root = GetNode(1046);
|
||||
var customDoc = GetNode(1178);
|
||||
var customDoc2 = GetNode(1179);
|
||||
var customDoc3 = GetNode(1172);
|
||||
|
||||
Assert.IsFalse(root.IsAncestor(customDoc3));
|
||||
Assert.IsTrue(root.IsAncestor(customDoc2));
|
||||
Assert.IsTrue(root.IsAncestor(customDoc));
|
||||
Assert.IsTrue(root.IsAncestor(home));
|
||||
Assert.IsFalse(root.IsAncestor(root));
|
||||
|
||||
Assert.IsFalse(home.IsAncestor(customDoc3));
|
||||
Assert.IsTrue(home.IsAncestor(customDoc2));
|
||||
Assert.IsTrue(home.IsAncestor(customDoc));
|
||||
Assert.IsFalse(home.IsAncestor(home));
|
||||
Assert.IsFalse(home.IsAncestor(root));
|
||||
|
||||
Assert.IsFalse(customDoc.IsAncestor(customDoc3));
|
||||
Assert.IsTrue(customDoc.IsAncestor(customDoc2));
|
||||
Assert.IsFalse(customDoc.IsAncestor(customDoc));
|
||||
Assert.IsFalse(customDoc.IsAncestor(home));
|
||||
Assert.IsFalse(customDoc.IsAncestor(root));
|
||||
|
||||
Assert.IsFalse(customDoc2.IsAncestor(customDoc3));
|
||||
Assert.IsFalse(customDoc2.IsAncestor(customDoc2));
|
||||
Assert.IsFalse(customDoc2.IsAncestor(customDoc));
|
||||
Assert.IsFalse(customDoc2.IsAncestor(home));
|
||||
Assert.IsFalse(customDoc2.IsAncestor(root));
|
||||
|
||||
Assert.IsFalse(customDoc3.IsAncestor(customDoc3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsAncestorOrSelf()
|
||||
{
|
||||
// Structure:
|
||||
// - Root : 1046 (no parent)
|
||||
// -- Home: 1173 (parent 1046)
|
||||
// -- Custom Doc: 1178 (parent 1173)
|
||||
// --- Custom Doc2: 1179 (parent: 1178)
|
||||
// - Custom Doc3: 1172 (no parent)
|
||||
|
||||
var home = GetNode(1173);
|
||||
var root = GetNode(1046);
|
||||
var customDoc = GetNode(1178);
|
||||
var customDoc2 = GetNode(1179);
|
||||
var customDoc3 = GetNode(1172);
|
||||
|
||||
Assert.IsFalse(root.IsAncestorOrSelf(customDoc3));
|
||||
Assert.IsTrue(root.IsAncestorOrSelf(customDoc2));
|
||||
Assert.IsTrue(root.IsAncestorOrSelf(customDoc));
|
||||
Assert.IsTrue(root.IsAncestorOrSelf(home));
|
||||
Assert.IsTrue(root.IsAncestorOrSelf(root));
|
||||
|
||||
Assert.IsFalse(home.IsAncestorOrSelf(customDoc3));
|
||||
Assert.IsTrue(home.IsAncestorOrSelf(customDoc2));
|
||||
Assert.IsTrue(home.IsAncestorOrSelf(customDoc));
|
||||
Assert.IsTrue(home.IsAncestorOrSelf(home));
|
||||
Assert.IsFalse(home.IsAncestorOrSelf(root));
|
||||
|
||||
Assert.IsFalse(customDoc.IsAncestorOrSelf(customDoc3));
|
||||
Assert.IsTrue(customDoc.IsAncestorOrSelf(customDoc2));
|
||||
Assert.IsTrue(customDoc.IsAncestorOrSelf(customDoc));
|
||||
Assert.IsFalse(customDoc.IsAncestorOrSelf(home));
|
||||
Assert.IsFalse(customDoc.IsAncestorOrSelf(root));
|
||||
|
||||
Assert.IsFalse(customDoc2.IsAncestorOrSelf(customDoc3));
|
||||
Assert.IsTrue(customDoc2.IsAncestorOrSelf(customDoc2));
|
||||
Assert.IsFalse(customDoc2.IsAncestorOrSelf(customDoc));
|
||||
Assert.IsFalse(customDoc2.IsAncestorOrSelf(home));
|
||||
Assert.IsFalse(customDoc2.IsAncestorOrSelf(root));
|
||||
|
||||
Assert.IsTrue(customDoc3.IsAncestorOrSelf(customDoc3));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Descendants_Or_Self()
|
||||
{
|
||||
@@ -568,7 +657,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
|
||||
Assert.AreEqual(8, result.Length);
|
||||
Assert.AreEqual(9, result.Count());
|
||||
Assert.IsTrue(result.Select(x => ((dynamic)x).Id).ContainsAll(new dynamic[] { 1046, 1173, 1174, 1176, 1175 }));
|
||||
}
|
||||
|
||||
@@ -581,10 +670,96 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
|
||||
Assert.AreEqual(7, result.Length);
|
||||
Assert.AreEqual(8, result.Count());
|
||||
Assert.IsTrue(result.Select(x => ((dynamic)x).Id).ContainsAll(new dynamic[] { 1173, 1174, 1176, 1175, 4444 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsDescendant()
|
||||
{
|
||||
// Structure:
|
||||
// - Root : 1046 (no parent)
|
||||
// -- Home: 1173 (parent 1046)
|
||||
// -- Custom Doc: 1178 (parent 1173)
|
||||
// --- Custom Doc2: 1179 (parent: 1178)
|
||||
// - Custom Doc3: 1172 (no parent)
|
||||
|
||||
var home = GetNode(1173);
|
||||
var root = GetNode(1046);
|
||||
var customDoc = GetNode(1178);
|
||||
var customDoc2 = GetNode(1179);
|
||||
var customDoc3 = GetNode(1172);
|
||||
|
||||
Assert.IsFalse(root.IsDescendant(root));
|
||||
Assert.IsFalse(root.IsDescendant(home));
|
||||
Assert.IsFalse(root.IsDescendant(customDoc));
|
||||
Assert.IsFalse(root.IsDescendant(customDoc2));
|
||||
Assert.IsFalse(root.IsDescendant(customDoc3));
|
||||
|
||||
Assert.IsTrue(home.IsDescendant(root));
|
||||
Assert.IsFalse(home.IsDescendant(home));
|
||||
Assert.IsFalse(home.IsDescendant(customDoc));
|
||||
Assert.IsFalse(home.IsDescendant(customDoc2));
|
||||
Assert.IsFalse(home.IsDescendant(customDoc3));
|
||||
|
||||
Assert.IsTrue(customDoc.IsDescendant(root));
|
||||
Assert.IsTrue(customDoc.IsDescendant(home));
|
||||
Assert.IsFalse(customDoc.IsDescendant(customDoc));
|
||||
Assert.IsFalse(customDoc.IsDescendant(customDoc2));
|
||||
Assert.IsFalse(customDoc.IsDescendant(customDoc3));
|
||||
|
||||
Assert.IsTrue(customDoc2.IsDescendant(root));
|
||||
Assert.IsTrue(customDoc2.IsDescendant(home));
|
||||
Assert.IsTrue(customDoc2.IsDescendant(customDoc));
|
||||
Assert.IsFalse(customDoc2.IsDescendant(customDoc2));
|
||||
Assert.IsFalse(customDoc2.IsDescendant(customDoc3));
|
||||
|
||||
Assert.IsFalse(customDoc3.IsDescendant(customDoc3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsDescendantOrSelf()
|
||||
{
|
||||
// Structure:
|
||||
// - Root : 1046 (no parent)
|
||||
// -- Home: 1173 (parent 1046)
|
||||
// -- Custom Doc: 1178 (parent 1173)
|
||||
// --- Custom Doc2: 1179 (parent: 1178)
|
||||
// - Custom Doc3: 1172 (no parent)
|
||||
|
||||
var home = GetNode(1173);
|
||||
var root = GetNode(1046);
|
||||
var customDoc = GetNode(1178);
|
||||
var customDoc2 = GetNode(1179);
|
||||
var customDoc3 = GetNode(1172);
|
||||
|
||||
Assert.IsTrue(root.IsDescendantOrSelf(root));
|
||||
Assert.IsFalse(root.IsDescendantOrSelf(home));
|
||||
Assert.IsFalse(root.IsDescendantOrSelf(customDoc));
|
||||
Assert.IsFalse(root.IsDescendantOrSelf(customDoc2));
|
||||
Assert.IsFalse(root.IsDescendantOrSelf(customDoc3));
|
||||
|
||||
Assert.IsTrue(home.IsDescendantOrSelf(root));
|
||||
Assert.IsTrue(home.IsDescendantOrSelf(home));
|
||||
Assert.IsFalse(home.IsDescendantOrSelf(customDoc));
|
||||
Assert.IsFalse(home.IsDescendantOrSelf(customDoc2));
|
||||
Assert.IsFalse(home.IsDescendantOrSelf(customDoc3));
|
||||
|
||||
Assert.IsTrue(customDoc.IsDescendantOrSelf(root));
|
||||
Assert.IsTrue(customDoc.IsDescendantOrSelf(home));
|
||||
Assert.IsTrue(customDoc.IsDescendantOrSelf(customDoc));
|
||||
Assert.IsFalse(customDoc.IsDescendantOrSelf(customDoc2));
|
||||
Assert.IsFalse(customDoc.IsDescendantOrSelf(customDoc3));
|
||||
|
||||
Assert.IsTrue(customDoc2.IsDescendantOrSelf(root));
|
||||
Assert.IsTrue(customDoc2.IsDescendantOrSelf(home));
|
||||
Assert.IsTrue(customDoc2.IsDescendantOrSelf(customDoc));
|
||||
Assert.IsTrue(customDoc2.IsDescendantOrSelf(customDoc2));
|
||||
Assert.IsFalse(customDoc2.IsDescendantOrSelf(customDoc3));
|
||||
|
||||
Assert.IsTrue(customDoc3.IsDescendantOrSelf(customDoc3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Up()
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web.Composing.CompositionRoots;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Current = Umbraco.Core.Composing.Current;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Tests.Testing
|
||||
{
|
||||
@@ -136,6 +137,7 @@ namespace Umbraco.Tests.Testing
|
||||
ComposeApplication(Options.WithApplication);
|
||||
|
||||
// etc
|
||||
ComposeWeb();
|
||||
ComposeWtf();
|
||||
|
||||
// not sure really
|
||||
@@ -172,11 +174,22 @@ namespace Umbraco.Tests.Testing
|
||||
Container.RegisterSingleton(f => new ProfilingLogger(f.GetInstance<ILogger>(), f.GetInstance<IProfiler>()));
|
||||
}
|
||||
|
||||
protected virtual void ComposeWtf()
|
||||
protected virtual void ComposeWeb()
|
||||
{
|
||||
//TODO: Should we 'just' register the WebRuntimeComponent?
|
||||
|
||||
// imported from TestWithSettingsBase
|
||||
// which was inherited by TestWithApplicationBase so pretty much used everywhere
|
||||
Umbraco.Web.Composing.Current.UmbracoContextAccessor = new TestUmbracoContextAccessor();
|
||||
Container.Register(_ => Umbraco.Web.Composing.Current.UmbracoContextAccessor);
|
||||
Container.RegisterSingleton<PublishedRouter>();
|
||||
Container.RegisterCollectionBuilder<ContentFinderCollectionBuilder>();
|
||||
Container.Register<IContentLastChanceFinder, TestLastChanceFinder>();
|
||||
Container.Register<IVariationContextAccessor, TestVariationContextAccessor>();
|
||||
}
|
||||
|
||||
protected virtual void ComposeWtf()
|
||||
{
|
||||
|
||||
// what else?
|
||||
var runtimeStateMock = new Mock<IRuntimeState>();
|
||||
@@ -270,6 +283,7 @@ namespace Umbraco.Tests.Testing
|
||||
Container.RegisterSingleton(factory => globalSettings);
|
||||
Container.RegisterSingleton(factory => umbracoSettings.Content);
|
||||
Container.RegisterSingleton(factory => umbracoSettings.Templates);
|
||||
Container.RegisterSingleton(factory => umbracoSettings.WebRouting);
|
||||
Container.Register(factory => new MediaFileSystem(Mock.Of<IFileSystem>()));
|
||||
Container.RegisterSingleton<IExamineManager>(factory => ExamineManager.Instance);
|
||||
|
||||
@@ -322,6 +336,8 @@ namespace Umbraco.Tests.Testing
|
||||
Container.RegisterCollectionBuilder<DataEditorCollectionBuilder>();
|
||||
Container.RegisterSingleton<PropertyEditorCollection>();
|
||||
Container.RegisterSingleton<ParameterEditorCollection>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user