diff --git a/src/Umbraco.Tests/IO/IOHelperTest.cs b/src/Umbraco.Tests/IO/IOHelperTest.cs
index d23d5cba5f..9f8822fbff 100644
--- a/src/Umbraco.Tests/IO/IOHelperTest.cs
+++ b/src/Umbraco.Tests/IO/IOHelperTest.cs
@@ -13,6 +13,13 @@ namespace Umbraco.Tests.IO
public class IOHelperTest
{
+ [Test]
+ public void IOHelper_ResolveUrl()
+ {
+ var result = IOHelper.ResolveUrl("~/Scripts");
+ Assert.AreEqual("/Scripts", result);
+ }
+
///
///A test for MapPath verifying that HttpContext method (which includes vdirs) matches non-HttpContext method
///
diff --git a/src/Umbraco.Tests/StringExtensionsTests.cs b/src/Umbraco.Tests/StringExtensionsTests.cs
index 49f8f830d7..c00b3cebac 100644
--- a/src/Umbraco.Tests/StringExtensionsTests.cs
+++ b/src/Umbraco.Tests/StringExtensionsTests.cs
@@ -10,6 +10,16 @@ namespace Umbraco.Tests
[TestFixture]
public class StringExtensionsTests
{
+
+ [TestCase("This is a string to encrypt")]
+ public void Encrypt_And_Decrypt(string input)
+ {
+ var encrypted = input.EncryptWithMachineKey();
+ var decrypted = encrypted.DecryptWithMachineKey();
+ Assert.AreNotEqual(input, encrypted);
+ Assert.AreEqual(input, decrypted);
+ }
+
[TestCase("Hello this is my string", " string", "Hello this is my")]
[TestCase("Hello this is my string strung", " string", "Hello this is my string strung")]
[TestCase("Hello this is my string string", " string", "Hello this is my")]
diff --git a/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs b/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs
index a782e61a7f..877bd02235 100644
--- a/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs
+++ b/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs
@@ -2,6 +2,7 @@ using System;
using System.Data;
using System.Collections;
+using System.Linq;
using umbraco.DataLayer;
using System.Xml;
using umbraco.interfaces;
@@ -9,16 +10,16 @@ using umbraco.cms.businesslogic.propertytype;
namespace umbraco.cms.businesslogic.datatype
{
- ///
- /// Datatypedefinitions is the basic buildingblocks of umbraco's documents/medias/members generic datastructure
- ///
- /// A datatypedefinition encapsulates an object which implements the interface IDataType, and are used when defining
- /// the properties of a document in the documenttype. This extra layer between IDataType and a documenttypes propertytype
- /// are used amongst other for enabling shared prevalues.
- ///
- ///
- public class DataTypeDefinition : CMSNode
- {
+ ///
+ /// Datatypedefinitions is the basic buildingblocks of umbraco's documents/medias/members generic datastructure
+ ///
+ /// A datatypedefinition encapsulates an object which implements the interface IDataType, and are used when defining
+ /// the properties of a document in the documenttype. This extra layer between IDataType and a documenttypes propertytype
+ /// are used amongst other for enabling shared prevalues.
+ ///
+ ///
+ public class DataTypeDefinition : CMSNode
+ {
#region Private fields
private Guid _controlId;
@@ -39,8 +40,8 @@ namespace umbraco.cms.businesslogic.datatype
/// Initialization of the datatypedefinition
///
/// Datattypedefininition id
- public DataTypeDefinition(Guid id) : base(id) { }
-
+ public DataTypeDefinition(Guid id) : base(id) { }
+
#endregion
#region Public Properties
@@ -66,10 +67,10 @@ namespace umbraco.cms.businesslogic.datatype
}
set
{
- if (SqlHelper == null)
- throw new InvalidOperationException("Cannot execute a SQL command when the SqlHelper is null");
- if (value == null)
- throw new InvalidOperationException("The value passed in is null. The DataType property cannot be set to a null value");
+ if (SqlHelper == null)
+ throw new InvalidOperationException("Cannot execute a SQL command when the SqlHelper is null");
+ if (value == null)
+ throw new InvalidOperationException("The value passed in is null. The DataType property cannot be set to a null value");
SqlHelper.ExecuteNonQuery("update cmsDataType set controlId = @id where nodeID = " + this.Id.ToString(),
SqlHelper.CreateParameter("@id", value.Id));
@@ -79,7 +80,7 @@ namespace umbraco.cms.businesslogic.datatype
internal string DbType
{
get { return _dbType; }
- }
+ }
#endregion
#region Public methods
@@ -87,7 +88,7 @@ namespace umbraco.cms.businesslogic.datatype
{
//first clear the prevalues
PreValues.DeleteByDataTypeDefinition(this.Id);
-
+
//next clear out the property types
var propTypes = PropertyType.GetByDataTypeDefinition(this.Id);
foreach (var p in propTypes)
@@ -153,7 +154,7 @@ namespace umbraco.cms.businesslogic.datatype
dt.AppendChild(prevalues);
return dt;
- }
+ }
#endregion
#region Static methods
@@ -178,11 +179,11 @@ namespace umbraco.cms.businesslogic.datatype
DataTypeDefinition dtd = MakeNew(u, _name, new Guid(_def));
- var dataType = f.DataType(new Guid(_id));
- if (dataType == null)
- throw new NullReferenceException("Could not resolve a data type with id " + _id);
+ var dataType = f.DataType(new Guid(_id));
+ if (dataType == null)
+ throw new NullReferenceException("Could not resolve a data type with id " + _id);
- dtd.DataType = dataType;
+ dtd.DataType = dataType;
dtd.Save();
//add prevalues
@@ -254,11 +255,11 @@ namespace umbraco.cms.businesslogic.datatype
int newId = CMSNode.MakeNew(-1, _objectType, u.Id, 1, Text, UniqueId).Id;
cms.businesslogic.datatype.controls.Factory f = new cms.businesslogic.datatype.controls.Factory();
-
+
// initial control id changed to empty to ensure that it'll always work no matter if 3rd party configurators fail
// ref: http://umbraco.codeplex.com/workitem/29788
Guid FirstcontrolId = Guid.Empty;
-
+
SqlHelper.ExecuteNonQuery("Insert into cmsDataType (nodeId, controlId, dbType) values (" + newId.ToString() + ",@controlId,'Ntext')",
SqlHelper.CreateParameter("@controlId", FirstcontrolId));
@@ -276,7 +277,8 @@ namespace umbraco.cms.businesslogic.datatype
public static DataTypeDefinition GetByDataTypeId(Guid DataTypeId)
{
int dfId = 0;
- foreach (DataTypeDefinition df in DataTypeDefinition.GetAll())
+ // When creating a datatype and not saving it, it will be null, so we need this check
+ foreach (DataTypeDefinition df in DataTypeDefinition.GetAll().Where(x => x.DataType != null))
if (df.DataType.Id == DataTypeId)
{
dfId = df.Id;
@@ -323,7 +325,7 @@ namespace umbraco.cms.businesslogic.datatype
System.Web.HttpRuntime.Cache.Insert(string.Format("UmbracoDataTypeDefinition{0}", id.ToString()), dt);
}
return (DataTypeDefinition)System.Web.HttpRuntime.Cache[string.Format("UmbracoDataTypeDefinition{0}", id.ToString())];
- }
+ }
#endregion
#region Protected methods
@@ -341,8 +343,8 @@ namespace umbraco.cms.businesslogic.datatype
else
throw new ArgumentException("No dataType with id = " + this.Id.ToString() + " found");
}
-
- }
+
+ }
#endregion
#region Events
@@ -373,7 +375,7 @@ namespace umbraco.cms.businesslogic.datatype
{
if (Deleting != null)
Deleting(this, e);
- }
+ }
#endregion
}