diff --git a/src/Umbraco.Core/Models/PreValue.cs b/src/Umbraco.Core/Models/PreValue.cs
new file mode 100644
index 0000000000..d0bdcc6d11
--- /dev/null
+++ b/src/Umbraco.Core/Models/PreValue.cs
@@ -0,0 +1,29 @@
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Represents a stored pre-value field value
+ ///
+ public class PreValue
+ {
+ public PreValue(int id, string value)
+ {
+ Value = value;
+ Id = id;
+ }
+
+ public PreValue(string value)
+ {
+ Value = value;
+ }
+
+ ///
+ /// The value stored for the pre-value field
+ ///
+ public string Value { get; private set; }
+
+ ///
+ /// The database id for the pre-value field value
+ ///
+ public int Id { get; private set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/PreValueCollection.cs b/src/Umbraco.Core/Models/PreValueCollection.cs
new file mode 100644
index 0000000000..c6e07d6e34
--- /dev/null
+++ b/src/Umbraco.Core/Models/PreValueCollection.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Represents the pre-value data for a DataType
+ ///
+ ///
+ /// Due to the legacy nature of the data that can be stored for pre-values, we have this class which encapsulates the 2 different
+ /// ways that pre-values are stored: A string array or a Dictionary.
+ ///
+ /// Most legacy property editors won't support the dictionary format but new property editors should always use the dictionary format.
+ /// In order to get overrideable pre-values working we need a dictionary since we'll have to reference a pre-value by a key.
+ ///
+ public class PreValueCollection
+ {
+ private IDictionary _preValuesAsDictionary;
+ private IEnumerable _preValuesAsArray;
+ public IEnumerable PreValuesAsArray
+ {
+ get
+ {
+ if (_preValuesAsArray == null)
+ {
+ throw new InvalidOperationException("The current pre-value collection is dictionary based, use the PreValuesAsDictionary property instead");
+ }
+ return _preValuesAsArray;
+ }
+ set { _preValuesAsArray = value; }
+ }
+
+ public IDictionary PreValuesAsDictionary
+ {
+ get
+ {
+ if (_preValuesAsDictionary == null)
+ {
+ throw new InvalidOperationException("The current pre-value collection is array based, use the PreValuesAsArray property instead");
+ }
+ return _preValuesAsDictionary;
+ }
+ set { _preValuesAsDictionary = value; }
+ }
+
+ ///
+ /// Check if it is a dictionary based collection
+ ///
+ public bool IsDictionaryBased
+ {
+ get { return _preValuesAsDictionary != null; }
+ }
+
+ public PreValueCollection(IEnumerable preVals)
+ {
+ _preValuesAsArray = preVals;
+ }
+
+ public PreValueCollection(IDictionary preVals)
+ {
+ _preValuesAsDictionary = preVals;
+ }
+
+ ///
+ /// Regardless of how the pre-values are stored this will return as a dictionary, it will convert an array based to a dictionary
+ ///
+ ///
+ public IDictionary FormatAsDictionary()
+ {
+ if (IsDictionaryBased)
+ {
+ return PreValuesAsDictionary;
+ }
+
+ //it's an array so need to format it, the alias will just be an iteration
+ var result = new Dictionary();
+ var asArray = PreValuesAsArray.ToArray();
+ for (var i = 0; i < asArray.Length; i++)
+ {
+ result.Add(i.ToInvariantString(), asArray[i]);
+ }
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWork.cs b/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWork.cs
index 4cdf4de85e..eb5dc31059 100644
--- a/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWork.cs
+++ b/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWork.cs
@@ -84,39 +84,58 @@ namespace Umbraco.Core.Persistence.UnitOfWork
});
}
- ///
- /// Commits all batched changes within the scope of a PetaPoco transaction
- ///
- ///
- /// Unlike a typical unit of work, this UOW will let you commit more than once since a new transaction is creaed per
- /// Commit() call instead of having one Transaction per UOW.
- ///
- public void Commit()
- {
- using (var transaction = Database.GetTransaction())
- {
- foreach (var operation in _operations.OrderBy(o => o.ProcessDate))
- {
- switch (operation.Type)
- {
- case TransactionType.Insert:
- operation.Repository.PersistNewItem(operation.Entity);
- break;
- case TransactionType.Delete:
- operation.Repository.PersistDeletedItem(operation.Entity);
- break;
- case TransactionType.Update:
- operation.Repository.PersistUpdatedItem(operation.Entity);
- break;
- }
- }
- transaction.Complete();
- }
+ ///
+ /// Commits all batched changes within the scope of a PetaPoco transaction
+ ///
+ ///
+ /// Unlike a typical unit of work, this UOW will let you commit more than once since a new transaction is creaed per
+ /// Commit() call instead of having one Transaction per UOW.
+ ///
+ public void Commit()
+ {
+ Commit(null);
+ }
- // Clear everything
- _operations.Clear();
- _key = Guid.NewGuid();
- }
+ ///
+ /// Commits all batched changes within the scope of a PetaPoco transaction
+ ///
+ ///
+ /// Allows you to set a callback which is executed before the transaction is committed, allow you to add additional SQL
+ /// operations to the overall commit process after the queue has been processed.
+ ///
+ internal void Commit(Action transactionCompleting)
+ {
+ using (var transaction = Database.GetTransaction())
+ {
+ foreach (var operation in _operations.OrderBy(o => o.ProcessDate))
+ {
+ switch (operation.Type)
+ {
+ case TransactionType.Insert:
+ operation.Repository.PersistNewItem(operation.Entity);
+ break;
+ case TransactionType.Delete:
+ operation.Repository.PersistDeletedItem(operation.Entity);
+ break;
+ case TransactionType.Update:
+ operation.Repository.PersistUpdatedItem(operation.Entity);
+ break;
+ }
+ }
+
+ //Execute the callback if there is one
+ if (transactionCompleting != null)
+ {
+ transactionCompleting(Database);
+ }
+
+ transaction.Complete();
+ }
+
+ // Clear everything
+ _operations.Clear();
+ _key = Guid.NewGuid();
+ }
public object Key
{
diff --git a/src/Umbraco.Core/Services/DataTypeService.cs b/src/Umbraco.Core/Services/DataTypeService.cs
index cb5d5f0cc0..f21b76a899 100644
--- a/src/Umbraco.Core/Services/DataTypeService.cs
+++ b/src/Umbraco.Core/Services/DataTypeService.cs
@@ -9,6 +9,7 @@ using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.UnitOfWork;
+using Umbraco.Core.PropertyEditors;
using umbraco.interfaces;
namespace Umbraco.Core.Services
@@ -18,16 +19,16 @@ namespace Umbraco.Core.Services
///
public class DataTypeService : IDataTypeService
{
- private readonly RepositoryFactory _repositoryFactory;
+ private readonly RepositoryFactory _repositoryFactory;
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
private static readonly ReaderWriterLockSlim Locker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
public DataTypeService()
: this(new RepositoryFactory())
- {}
+ { }
public DataTypeService(RepositoryFactory repositoryFactory)
- : this(new PetaPocoUnitOfWorkProvider(), repositoryFactory)
+ : this(new PetaPocoUnitOfWorkProvider(), repositoryFactory)
{
}
@@ -36,9 +37,9 @@ namespace Umbraco.Core.Services
{
}
- public DataTypeService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory)
+ public DataTypeService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory)
{
- _repositoryFactory = repositoryFactory;
+ _repositoryFactory = repositoryFactory;
_uowProvider = provider;
}
@@ -74,7 +75,7 @@ namespace Umbraco.Core.Services
///
/// Gets a by its control Id
///
- /// Id of the DataType control
+ /// Id of the property editor
/// Collection of objects with a matching contorl id
public IEnumerable GetDataTypeDefinitionByControlId(Guid id)
{
@@ -109,27 +110,25 @@ namespace Umbraco.Core.Services
{
using (var uow = _uowProvider.GetUnitOfWork())
{
- var dtos = uow.Database.Fetch("WHERE datatypeNodeId = @Id", new {Id = id});
+ var dtos = uow.Database.Fetch("WHERE datatypeNodeId = @Id", new { Id = id });
var list = dtos.Select(x => x.Value).ToList();
return list;
}
}
///
- /// Gets all prevalues for an
+ /// Returns the PreValueCollection for the specified data type
///
- ///
- /// This method should be kept internal until a proper PreValue object model is introduced.
- ///
- /// Id of the to retrieve prevalues from
- /// An enumerable list of Tuples containing Id, Alias, SortOrder, Value
- internal IEnumerable> GetDetailedPreValuesByDataTypeId(int id)
+ ///
+ ///
+ public PreValueCollection GetPreValuesCollectionByDataTypeId(int id)
{
using (var uow = _uowProvider.GetUnitOfWork())
{
var dtos = uow.Database.Fetch("WHERE datatypeNodeId = @Id", new { Id = id });
- var list = dtos.Select(x => new Tuple(x.Id, x.Alias, x.SortOrder, x.Value)).ToList();
- return list;
+ var list = dtos.Select(x => new Tuple(new PreValue(x.Id, x.Value), x.Alias, x.SortOrder)).ToList();
+
+ return PreValueConverter.ConvertToPreValuesCollection(list);
}
}
@@ -154,8 +153,8 @@ namespace Umbraco.Core.Services
/// Id of the user issueing the save
public void Save(IDataTypeDefinition dataTypeDefinition, int userId = 0)
{
- if (Saving.IsRaisedEventCancelled(new SaveEventArgs(dataTypeDefinition), this))
- return;
+ if (Saving.IsRaisedEventCancelled(new SaveEventArgs(dataTypeDefinition), this))
+ return;
using (new WriteLock(Locker))
{
@@ -206,8 +205,11 @@ namespace Umbraco.Core.Services
///
/// Id of the DataTypeDefinition to save PreValues for
/// List of string values to save
+ [Obsolete("This should no longer be used, use the alternative SavePreValues or SaveDataTypeAndPreValues methods instead. This will only insert pre-values without keys")]
public void SavePreValues(int id, IEnumerable values)
{
+ //TODO: Should we raise an event here since we are really saving values for the data type?
+
using (new WriteLock(Locker))
{
using (var uow = _uowProvider.GetUnitOfWork())
@@ -236,6 +238,111 @@ namespace Umbraco.Core.Services
}
}
+ ///
+ /// Saves/updates the pre-values
+ ///
+ ///
+ ///
+ ///
+ /// We need to actually look up each pre-value and maintain it's id if possible - this is because of silly property editors
+ /// like 'dropdown list publishing keys'
+ ///
+ public void SavePreValues(int id, IDictionary values)
+ {
+ //TODO: Should we raise an event here since we are really saving values for the data type?
+
+ using (new WriteLock(Locker))
+ {
+ using (var uow = _uowProvider.GetUnitOfWork())
+ {
+ using (var transaction = uow.Database.GetTransaction())
+ {
+ AddOrUpdatePreValues(id, values, uow);
+ transaction.Complete();
+ }
+ }
+ }
+ }
+
+ ///
+ /// This will save a data type and it's pre-values in one transaction
+ ///
+ ///
+ ///
+ ///
+ public void SaveDataTypeAndPreValues(IDataTypeDefinition dataTypeDefinition, IDictionary values, int userId = 0)
+ {
+ if (Saving.IsRaisedEventCancelled(new SaveEventArgs(dataTypeDefinition), this))
+ return;
+
+ using (new WriteLock(Locker))
+ {
+ var uow = (PetaPocoUnitOfWork)_uowProvider.GetUnitOfWork();
+ using (var repository = _repositoryFactory.CreateDataTypeDefinitionRepository(uow))
+ {
+ dataTypeDefinition.CreatorId = userId;
+ repository.AddOrUpdate(dataTypeDefinition);
+
+ //complete the transaction, but run the delegate before the db transaction is finalized
+ uow.Commit(database => AddOrUpdatePreValues(dataTypeDefinition.Id, values, uow));
+
+ Saved.RaiseEvent(new SaveEventArgs(dataTypeDefinition, false), this);
+ }
+ }
+
+ Audit.Add(AuditTypes.Save, string.Format("Save DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
+ }
+
+ private void AddOrUpdatePreValues(int id, IDictionary preValueCollection, IDatabaseUnitOfWork uow)
+ {
+ //first just get all pre-values for this data type so we can compare them to see if we need to insert or update or replace
+ var sql = new Sql().Select("*")
+ .From()
+ .Where(dto => dto.DataTypeNodeId == id)
+ .OrderBy(dto => dto.SortOrder);
+ var currentVals = uow.Database.Fetch(sql).ToArray();
+
+ //already existing, need to be updated
+ var valueIds = preValueCollection.Where(x => x.Value.Id > 0).Select(x => x.Value.Id).ToArray();
+ var existingByIds = currentVals.Where(x => valueIds.Contains(x.Id)).ToArray();
+
+ //These ones need to be removed from the db, they no longer exist in the new values
+ var deleteById = currentVals.Where(x => valueIds.Contains(x.Id) == false);
+
+ foreach (var d in deleteById)
+ {
+ uow.Database.Execute(
+ "DELETE FROM cmsDataTypePreValues WHERE datatypeNodeId = @DataTypeId AND id=@Id",
+ new { DataTypeId = id, Id = d.Id });
+ }
+
+ var sortOrder = 1;
+
+ foreach (var pre in preValueCollection)
+ {
+ var existing = existingByIds.FirstOrDefault(valueDto => valueDto.Id == pre.Value.Id);
+ if (existing != null)
+ {
+ existing.Value = pre.Value.Value;
+ existing.SortOrder = sortOrder;
+ uow.Database.Update(existing);
+ }
+ else
+ {
+ var dto = new DataTypePreValueDto
+ {
+ DataTypeNodeId = id,
+ Value = pre.Value.Value,
+ SortOrder = sortOrder,
+ Alias = pre.Key
+ };
+ uow.Database.Insert(dto);
+ }
+
+ sortOrder++;
+ }
+ }
+
///
/// Deletes an
///
@@ -246,43 +353,43 @@ namespace Umbraco.Core.Services
/// to delete
/// Optional Id of the user issueing the deletion
public void Delete(IDataTypeDefinition dataTypeDefinition, int userId = 0)
- {
- if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs(dataTypeDefinition), this))
- return;
-
- var uow = _uowProvider.GetUnitOfWork();
- using (var repository = _repositoryFactory.CreateContentTypeRepository(uow))
- {
- //Find ContentTypes using this IDataTypeDefinition on a PropertyType
- var query = Query.Builder.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id);
- var contentTypes = repository.GetByQuery(query);
+ {
+ if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs(dataTypeDefinition), this))
+ return;
- //Loop through the list of results and remove the PropertyTypes that references the DataTypeDefinition that is being deleted
- foreach (var contentType in contentTypes)
- {
- if (contentType == null) continue;
+ var uow = _uowProvider.GetUnitOfWork();
+ using (var repository = _repositoryFactory.CreateContentTypeRepository(uow))
+ {
+ //Find ContentTypes using this IDataTypeDefinition on a PropertyType
+ var query = Query.Builder.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id);
+ var contentTypes = repository.GetByQuery(query);
- foreach (var group in contentType.PropertyGroups)
- {
- var types = @group.PropertyTypes.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id).ToList();
- foreach (var propertyType in types)
- {
- @group.PropertyTypes.Remove(propertyType);
- }
- }
+ //Loop through the list of results and remove the PropertyTypes that references the DataTypeDefinition that is being deleted
+ foreach (var contentType in contentTypes)
+ {
+ if (contentType == null) continue;
- repository.AddOrUpdate(contentType);
- }
+ foreach (var group in contentType.PropertyGroups)
+ {
+ var types = @group.PropertyTypes.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id).ToList();
+ foreach (var propertyType in types)
+ {
+ @group.PropertyTypes.Remove(propertyType);
+ }
+ }
- var dataTypeRepository = _repositoryFactory.CreateDataTypeDefinitionRepository(uow);
- dataTypeRepository.Delete(dataTypeDefinition);
+ repository.AddOrUpdate(contentType);
+ }
- uow.Commit();
+ var dataTypeRepository = _repositoryFactory.CreateDataTypeDefinitionRepository(uow);
+ dataTypeRepository.Delete(dataTypeDefinition);
- Deleted.RaiseEvent(new DeleteEventArgs(dataTypeDefinition, false), this);
- }
+ uow.Commit();
- Audit.Add(AuditTypes.Delete, string.Format("Delete DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
+ Deleted.RaiseEvent(new DeleteEventArgs(dataTypeDefinition, false), this);
+ }
+
+ Audit.Add(AuditTypes.Delete, string.Format("Delete DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
}
///
@@ -290,6 +397,7 @@ namespace Umbraco.Core.Services
///
/// Id of the DataType, which corresponds to the Guid Id of the control
/// object
+ [Obsolete("IDataType is obsolete and is no longer used, it will be removed from the codebase in future versions")]
public IDataType GetDataTypeById(Guid id)
{
return DataTypesResolver.Current.GetById(id);
@@ -299,6 +407,7 @@ namespace Umbraco.Core.Services
/// Gets a complete list of all registered 's
///
/// An enumerable list of objects
+ [Obsolete("IDataType is obsolete and is no longer used, it will be removed from the codebase in future versions")]
public IEnumerable GetAllDataTypes()
{
return DataTypesResolver.Current.DataTypes;
@@ -308,22 +417,58 @@ namespace Umbraco.Core.Services
///
/// Occurs before Delete
///
- public static event TypedEventHandler> Deleting;
+ public static event TypedEventHandler> Deleting;
///
/// Occurs after Delete
///
- public static event TypedEventHandler> Deleted;
+ public static event TypedEventHandler> Deleted;
///
/// Occurs before Save
///
- public static event TypedEventHandler> Saving;
+ public static event TypedEventHandler> Saving;
///
/// Occurs after Save
///
- public static event TypedEventHandler> Saved;
+ public static event TypedEventHandler> Saved;
#endregion
+
+ internal static class PreValueConverter
+ {
+ ///
+ /// Converts the tuple to a pre-value collection
+ ///
+ ///
+ ///
+ internal static PreValueCollection ConvertToPreValuesCollection(IEnumerable> list)
+ {
+ //now we need to determine if they are dictionary based, otherwise they have to be array based
+ var dictionary = new Dictionary();
+
+ //need to check all of the keys, if there's only one and it is empty then it's an array
+ var keys = list.Select(x => x.Item2).Distinct().ToArray();
+ if (keys.Length == 1 && keys[0].IsNullOrWhiteSpace())
+ {
+ return new PreValueCollection(list.OrderBy(x => x.Item3).Select(x => x.Item1));
+ }
+
+ foreach (var item in list
+ .OrderBy(x => x.Item3) //we'll order them first so we maintain the order index in the dictionary
+ .GroupBy(x => x.Item2)) //group by alias
+ {
+ if (item.Count() > 1)
+ {
+ //if there's more than 1 item per key, then it cannot be a dictionary, just return the array
+ return new PreValueCollection(list.OrderBy(x => x.Item3).Select(x => x.Item1));
+ }
+
+ dictionary.Add(item.Key, item.First().Item1);
+ }
+
+ return new PreValueCollection(dictionary);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Services/IDataTypeService.cs b/src/Umbraco.Core/Services/IDataTypeService.cs
index 5fac95a25c..a0c53bc38a 100644
--- a/src/Umbraco.Core/Services/IDataTypeService.cs
+++ b/src/Umbraco.Core/Services/IDataTypeService.cs
@@ -83,13 +83,36 @@ namespace Umbraco.Core.Services
/// An enumerable list of string values
IEnumerable GetPreValuesByDataTypeId(int id);
+ ///
+ /// Gets a pre-value collection by data type id
+ ///
+ ///
+ ///
+ PreValueCollection GetPreValuesCollectionByDataTypeId(int id);
+
///
/// Saves a list of PreValues for a given DataTypeDefinition
///
/// Id of the DataTypeDefinition to save PreValues for
/// List of string values to save
+ [Obsolete("This should no longer be used, use the alternative SavePreValues or SaveDataTypeAndPreValues methods instead. This will only insert pre-values without keys")]
void SavePreValues(int id, IEnumerable values);
+ ///
+ /// Saves a list of PreValues for a given DataTypeDefinition
+ ///
+ /// Id of the DataTypeDefinition to save PreValues for
+ /// List of key/value pairs to save
+ void SavePreValues(int id, IDictionary values);
+
+ ///
+ /// Saves the data type and it's prevalues
+ ///
+ ///
+ ///
+ ///
+ void SaveDataTypeAndPreValues(IDataTypeDefinition dataTypeDefinition, IDictionary values, int userId = 0);
+
///
/// Gets a specific PreValue by its Id
///
diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs
index e50daa6a61..7d683cd275 100644
--- a/src/Umbraco.Core/Services/PackagingService.cs
+++ b/src/Umbraco.Core/Services/PackagingService.cs
@@ -707,20 +707,23 @@ namespace Umbraco.Core.Services
{
var prevalues = new XElement("PreValues");
- var prevalueList = ((DataTypeService)_dataTypeService).GetDetailedPreValuesByDataTypeId(dataTypeDefinition.Id);
- foreach (var tuple in prevalueList)
+ var prevalueList = _dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id)
+ .FormatAsDictionary();
+
+ var sort = 0;
+ foreach (var pv in prevalueList)
{
var prevalue = new XElement("PreValue");
- prevalue.Add(new XAttribute("Id", tuple.Item1));
- prevalue.Add(new XAttribute("Value", tuple.Item4));
- prevalue.Add(new XAttribute("Alias", tuple.Item2));
- prevalue.Add(new XAttribute("SortOrder", tuple.Item3));
+ prevalue.Add(new XAttribute("Id", pv.Value.Id));
+ prevalue.Add(new XAttribute("Value", pv.Value.Value));
+ prevalue.Add(new XAttribute("Alias", pv.Key));
+ prevalue.Add(new XAttribute("SortOrder", sort));
prevalues.Add(prevalue);
+ sort++;
}
var xml = new XElement("DataType", prevalues);
xml.Add(new XAttribute("Name", dataTypeDefinition.Name));
- //The 'ID' when exporting is actually the property editor alias (in pre v7 it was the IDataType GUID id)
xml.Add(new XAttribute("Id", dataTypeDefinition.ControlId));
xml.Add(new XAttribute("Definition", dataTypeDefinition.Key));
xml.Add(new XAttribute("DatabaseType", dataTypeDefinition.DatabaseType.ToString()));
diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs
index 8f4c7a57b1..1832e6906b 100644
--- a/src/Umbraco.Core/StringExtensions.cs
+++ b/src/Umbraco.Core/StringExtensions.cs
@@ -439,6 +439,16 @@ namespace Umbraco.Core
return String.Format(CultureInfo.InvariantCulture, format, args);
}
+ ///
+ /// Converts an integer to an invariant formatted string
+ ///
+ ///
+ ///
+ public static string ToInvariantString(this int str)
+ {
+ return str.ToString(CultureInfo.InvariantCulture);
+ }
+
///
/// Compares 2 strings with invariant culture and case ignored
///
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index a50b483d73..f615187f45 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -189,6 +189,8 @@
+
+
diff --git a/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs b/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs
index d8b0909312..5c388e7784 100644
--- a/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs
+++ b/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs
@@ -5,6 +5,7 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
+using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Serialization;
using Umbraco.Tests.CodeFirst.Definitions;
using Umbraco.Tests.CodeFirst.TestModels;
@@ -39,7 +40,7 @@ namespace Umbraco.Tests.CodeFirst
var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes();
ServiceContext.ContentTypeService.Save(mappedContentTypes);
- var model = ServiceContext.ContentTypeService.GetContentType(1046);
+ var model = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed + 1);
Assert.That(model, Is.Not.Null);
}
@@ -145,8 +146,8 @@ namespace Umbraco.Tests.CodeFirst
var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes().ToList();
ServiceContext.ContentTypeService.Save(mappedContentTypes);
- var type1 = ServiceContext.ContentTypeService.GetContentType(1045);
- var type2 = ServiceContext.ContentTypeService.GetContentType(1046);
+ var type1 = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
+ var type2 = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed + 1);
Assert.That(type1, Is.Not.Null);
Assert.That(type2, Is.Not.Null);
@@ -163,7 +164,7 @@ namespace Umbraco.Tests.CodeFirst
var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes().ToList();
ServiceContext.ContentTypeService.Save(mappedContentTypes);
- var type1 = ServiceContext.ContentTypeService.GetContentType(1047);
+ var type1 = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed + 2);
Assert.That(type1, Is.Not.Null);
Assert.That(type1.PropertyGroups.Count(), Is.EqualTo(2));
diff --git a/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs b/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs
index 6664d86eb8..26e93961ac 100644
--- a/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs
+++ b/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using NUnit.Framework;
+using Umbraco.Core.Models.Rdbms;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using umbraco.BusinessLogic;
@@ -27,7 +28,7 @@ namespace Umbraco.Tests.LegacyApi
// Arrange
var folder = MediaType.GetByAlias(Constants.Conventions.MediaTypes.Folder);
var folderStructure = folder.AllowedChildContentTypeIDs.ToList();
- folderStructure.Add(1045);
+ folderStructure.Add(NodeDto.NodeIdSeed);
// Act
folder.AllowedChildContentTypeIDs = folderStructure.ToArray();
@@ -37,7 +38,7 @@ namespace Umbraco.Tests.LegacyApi
var updated = MediaType.GetByAlias(Constants.Conventions.MediaTypes.Folder);
Assert.That(updated.AllowedChildContentTypeIDs.Any(), Is.True);
- Assert.That(updated.AllowedChildContentTypeIDs.Any(x => x == 1045), Is.True);
+ Assert.That(updated.AllowedChildContentTypeIDs.Any(x => x == NodeDto.NodeIdSeed), Is.True);
}
[Test]
@@ -85,7 +86,7 @@ namespace Umbraco.Tests.LegacyApi
public void CreateTestData()
{
- //Create and Save ContentType "video" -> 1045
+ //Create and Save ContentType "video" -> NodeDto.NodeIdSeed
var videoMediaType = MockedContentTypes.CreateVideoMediaType();
ServiceContext.ContentTypeService.Save(videoMediaType);
}
diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs
index 5ce7db21ff..a1adedf149 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs
@@ -224,7 +224,7 @@ namespace Umbraco.Tests.Persistence.Repositories
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
// Act
- var content = repository.Get(1048);
+ var content = repository.Get(NodeDto.NodeIdSeed + 3);
bool dirty = ((Content)content).IsDirty();
// Assert
@@ -242,11 +242,11 @@ namespace Umbraco.Tests.Persistence.Repositories
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
// Act
- var content = repository.Get(1047);
+ var content = repository.Get(NodeDto.NodeIdSeed + 2);
content.Name = "About 2";
repository.AddOrUpdate(content);
unitOfWork.Commit();
- var updatedContent = repository.Get(1047);
+ var updatedContent = repository.Get(NodeDto.NodeIdSeed + 2);
// Assert
Assert.That(updatedContent.Id, Is.EqualTo(content.Id));
@@ -264,8 +264,8 @@ namespace Umbraco.Tests.Persistence.Repositories
ContentTypeRepository contentTypeRepository;
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
- var contentType = contentTypeRepository.Get(1045);
- var content = new Content("Textpage 2 Child Node", 1048, contentType);
+ var contentType = contentTypeRepository.Get(NodeDto.NodeIdSeed);
+ var content = new Content("Textpage 2 Child Node", NodeDto.NodeIdSeed + 3, contentType);
content.CreatorId = 0;
content.WriterId = 0;
@@ -295,17 +295,17 @@ namespace Umbraco.Tests.Persistence.Repositories
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
// Act
- var content = repository.Get(1048);
+ var content = repository.Get(NodeDto.NodeIdSeed + 3);
// Assert
- Assert.That(content.Id, Is.EqualTo(1048));
+ Assert.That(content.Id, Is.EqualTo(NodeDto.NodeIdSeed + 3));
Assert.That(content.CreateDate, Is.GreaterThan(DateTime.MinValue));
Assert.That(content.UpdateDate, Is.GreaterThan(DateTime.MinValue));
Assert.That(content.ParentId, Is.Not.EqualTo(0));
Assert.That(content.Name, Is.EqualTo("Text Page 2"));
Assert.That(content.SortOrder, Is.EqualTo(1));
Assert.That(content.Version, Is.Not.EqualTo(Guid.Empty));
- Assert.That(content.ContentTypeId, Is.EqualTo(1045));
+ Assert.That(content.ContentTypeId, Is.EqualTo(NodeDto.NodeIdSeed));
Assert.That(content.Path, Is.Not.Empty);
Assert.That(content.Properties.Any(), Is.True);
}
@@ -339,7 +339,7 @@ namespace Umbraco.Tests.Persistence.Repositories
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
// Act
- var contents = repository.GetAll(1047, 1048);
+ var contents = repository.GetAll(NodeDto.NodeIdSeed + 2, NodeDto.NodeIdSeed + 3);
// Assert
Assert.That(contents, Is.Not.Null);
@@ -379,7 +379,7 @@ namespace Umbraco.Tests.Persistence.Repositories
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
// Act
- var exists = repository.Exists(1046);
+ var exists = repository.Exists(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(exists, Is.True);
@@ -417,9 +417,9 @@ namespace Umbraco.Tests.Persistence.Repositories
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
// Act
- var textpage = repository.Get(1046);
- var subpage = repository.Get(1047);
- var trashed = repository.Get(1049);
+ var textpage = repository.Get(NodeDto.NodeIdSeed + 1);
+ var subpage = repository.Get(NodeDto.NodeIdSeed + 2);
+ var trashed = repository.Get(NodeDto.NodeIdSeed + 4);
// Assert
Assert.That(textpage.Key.ToString().ToUpper(), Is.EqualTo("B58B3AD4-62C2-4E27-B1BE-837BD7C533E0"));
@@ -443,7 +443,7 @@ namespace Umbraco.Tests.Persistence.Repositories
// Assert
Assert.That(content, Is.Not.Null);
- Assert.That(content.Id, Is.EqualTo(1046));
+ Assert.That(content.Id, Is.EqualTo(NodeDto.NodeIdSeed + 1));
}
}
@@ -457,7 +457,7 @@ namespace Umbraco.Tests.Persistence.Repositories
ContentTypeRepository contentTypeRepository;
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
- var content = repository.Get(1047);
+ var content = repository.Get(NodeDto.NodeIdSeed + 2);
// Act
content.Language = "da-DK";
@@ -465,9 +465,9 @@ namespace Umbraco.Tests.Persistence.Repositories
repository.AddOrUpdate(content);
unitOfWork.Commit();
- var latest = repository.Get(1047);
- var english = repository.GetByLanguage(1047, "en-US");
- var danish = repository.GetByLanguage(1047, "da-DK");
+ var latest = repository.Get(NodeDto.NodeIdSeed + 2);
+ var english = repository.GetByLanguage(NodeDto.NodeIdSeed + 2, "en-US");
+ var danish = repository.GetByLanguage(NodeDto.NodeIdSeed + 2, "da-DK");
// Assert
Assert.That(latest.Name, Is.EqualTo("Tekst Side 1"));
@@ -478,26 +478,26 @@ namespace Umbraco.Tests.Persistence.Repositories
public void CreateTestData()
{
- //Create and Save ContentType "umbTextpage" -> 1045
+ //Create and Save ContentType "umbTextpage" -> NodeDto.NodeIdSeed
ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage");
contentType.Key = new Guid("1D3A8E6E-2EA9-4CC1-B229-1AEE19821522");
ServiceContext.ContentTypeService.Save(contentType);
- //Create and Save Content "Homepage" based on "umbTextpage" -> 1046
+ //Create and Save Content "Homepage" based on "umbTextpage" -> NodeDto.NodeIdSeed + 1
Content textpage = MockedContent.CreateSimpleContent(contentType);
textpage.Key = new Guid("B58B3AD4-62C2-4E27-B1BE-837BD7C533E0");
ServiceContext.ContentService.Save(textpage, 0);
- //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1047
+ //Create and Save Content "Text Page 1" based on "umbTextpage" -> NodeDto.NodeIdSeed + 2
Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Page 1", textpage.Id);
subpage.Key = new Guid("FF11402B-7E53-4654-81A7-462AC2108059");
ServiceContext.ContentService.Save(subpage, 0);
- //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1048
+ //Create and Save Content "Text Page 1" based on "umbTextpage" -> NodeDto.NodeIdSeed + 3
Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Page 2", textpage.Id);
ServiceContext.ContentService.Save(subpage2, 0);
- //Create and Save Content "Text Page Deleted" based on "umbTextpage" -> 1049
+ //Create and Save Content "Text Page Deleted" based on "umbTextpage" -> NodeDto.NodeIdSeed + 4
Content trashed = MockedContent.CreateSimpleContent(contentType, "Text Page Deleted", -20);
trashed.Trashed = true;
ServiceContext.ContentService.Save(trashed, 0);
diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs
index e5c782c00d..9c593d0714 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs
@@ -5,6 +5,7 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
+using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Caching;
using Umbraco.Core.Persistence.Repositories;
@@ -93,7 +94,7 @@ namespace Umbraco.Tests.Persistence.Repositories
using (var repository = CreateRepository(unitOfWork))
{
// Act
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
contentType.Thumbnail = "Doc2.png";
contentType.PropertyGroups["Content"].PropertyTypes.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext)
@@ -155,11 +156,11 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(contentType, Is.Not.Null);
- Assert.That(contentType.Id, Is.EqualTo(1046));
+ Assert.That(contentType.Id, Is.EqualTo(NodeDto.NodeIdSeed + 1));
}
}
@@ -195,7 +196,7 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var exists = repository.Exists(1045);
+ var exists = repository.Exists(NodeDto.NodeIdSeed);
// Assert
Assert.That(exists, Is.True);
@@ -210,14 +211,14 @@ namespace Umbraco.Tests.Persistence.Repositories
var unitOfWork = provider.GetUnitOfWork();
using (var repository = CreateRepository(unitOfWork))
{
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
// Act
contentType.PropertyGroups["Meta"].PropertyTypes.Remove("metaDescription");
repository.AddOrUpdate(contentType);
unitOfWork.Commit();
- var result = repository.Get(1046);
+ var result = repository.Get(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(result.PropertyTypes.Any(x => x.Alias == "metaDescription"), Is.False);
@@ -236,7 +237,7 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var contentType = repository.Get(1045);
+ var contentType = repository.Get(NodeDto.NodeIdSeed);
// Assert
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(3));
@@ -254,7 +255,7 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(4));
@@ -270,7 +271,7 @@ namespace Umbraco.Tests.Persistence.Repositories
var unitOfWork = provider.GetUnitOfWork();
using (var repository = CreateRepository(unitOfWork))
{
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
// Act
var urlAlias = new PropertyType(new Guid(), DataTypeDatabaseType.Nvarchar)
@@ -289,7 +290,7 @@ namespace Umbraco.Tests.Persistence.Repositories
unitOfWork.Commit();
// Assert
- var updated = repository.Get(1046);
+ var updated = repository.Get(NodeDto.NodeIdSeed + 1);
Assert.That(addedPropertyType, Is.True);
Assert.That(updated.PropertyGroups.Count(), Is.EqualTo(2));
Assert.That(updated.PropertyTypes.Count(), Is.EqualTo(5));
@@ -314,7 +315,7 @@ namespace Umbraco.Tests.Persistence.Repositories
unitOfWork.Commit();
// Act
- var contentType = repository.Get(1045);
+ var contentType = repository.Get(NodeDto.NodeIdSeed);
contentType.AllowedContentTypes = new List
{
new ContentTypeSort
@@ -334,7 +335,7 @@ namespace Umbraco.Tests.Persistence.Repositories
unitOfWork.Commit();
//Assert
- var updated = repository.Get(1045);
+ var updated = repository.Get(NodeDto.NodeIdSeed);
Assert.That(updated.AllowedContentTypes.Any(), Is.True);
Assert.That(updated.AllowedContentTypes.Any(x => x.Alias == subpageContentType.Alias), Is.True);
@@ -351,7 +352,7 @@ namespace Umbraco.Tests.Persistence.Repositories
ContentTypeRepository repository;
using (var contentRepository = CreateRepository(unitOfWork, out repository))
{
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id);
contentRepository.AddOrUpdate(subpage);
@@ -378,7 +379,7 @@ namespace Umbraco.Tests.Persistence.Repositories
ContentTypeRepository repository;
using (var contentRepository = CreateRepository(unitOfWork, out repository))
{
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id);
contentRepository.AddOrUpdate(subpage);
@@ -406,7 +407,7 @@ namespace Umbraco.Tests.Persistence.Repositories
ContentTypeRepository repository;
using (var contentRepository = CreateRepository(unitOfWork, out repository))
{
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id);
contentRepository.AddOrUpdate(subpage);
@@ -442,7 +443,7 @@ namespace Umbraco.Tests.Persistence.Repositories
ContentTypeRepository repository;
using (var contentRepository = CreateRepository(unitOfWork, out repository))
{
- var contentType = repository.Get(1046);
+ var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id);
contentRepository.AddOrUpdate(subpage);
@@ -475,11 +476,11 @@ namespace Umbraco.Tests.Persistence.Repositories
public void CreateTestData()
{
- //Create and Save ContentType "umbTextpage" -> 1045
+ //Create and Save ContentType "umbTextpage" -> NodeDto.NodeIdSeed
ContentType simpleContentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage");
ServiceContext.ContentTypeService.Save(simpleContentType);
- //Create and Save ContentType "textPage" -> 1046
+ //Create and Save ContentType "textPage" -> NodeDto.NodeIdSeed + 1
ContentType textpageContentType = MockedContentTypes.CreateTextpageContentType();
ServiceContext.ContentTypeService.Save(textpageContentType);
}
diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs
index 28d89f4baf..884ba5b383 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs
@@ -4,6 +4,7 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
+using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Caching;
using Umbraco.Core.Persistence.Querying;
@@ -145,7 +146,7 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var media = repository.Get(1046);
+ var media = repository.Get(NodeDto.NodeIdSeed + 1);
bool dirty = ((ICanBeDirty) media).IsDirty();
// Assert
@@ -164,12 +165,12 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var content = repository.Get(1047);
+ var content = repository.Get(NodeDto.NodeIdSeed + 2);
content.Name = "Test File Updated";
repository.AddOrUpdate(content);
unitOfWork.Commit();
- var updatedContent = repository.Get(1047);
+ var updatedContent = repository.Get(NodeDto.NodeIdSeed + 2);
// Assert
Assert.That(updatedContent.Id, Is.EqualTo(content.Id));
@@ -188,12 +189,12 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var media = repository.Get(1047);
+ var media = repository.Get(NodeDto.NodeIdSeed + 2);
repository.Delete(media);
unitOfWork.Commit();
- var deleted = repository.Get(1047);
- var exists = repository.Exists(1047);
+ var deleted = repository.Get(NodeDto.NodeIdSeed + 2);
+ var exists = repository.Exists(NodeDto.NodeIdSeed + 2);
// Assert
Assert.That(deleted, Is.Null);
@@ -212,10 +213,10 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var media = repository.Get(1046);
+ var media = repository.Get(NodeDto.NodeIdSeed + 1);
// Assert
- Assert.That(media.Id, Is.EqualTo(1046));
+ Assert.That(media.Id, Is.EqualTo(NodeDto.NodeIdSeed + 1));
Assert.That(media.CreateDate, Is.GreaterThan(DateTime.MinValue));
Assert.That(media.UpdateDate, Is.GreaterThan(DateTime.MinValue));
Assert.That(media.ParentId, Is.Not.EqualTo(0));
@@ -258,7 +259,7 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var medias = repository.GetAll(1046, 1047);
+ var medias = repository.GetAll(NodeDto.NodeIdSeed + 1, NodeDto.NodeIdSeed + 2);
// Assert
Assert.That(medias, Is.Not.Null);
@@ -298,9 +299,9 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var exists = repository.Exists(1046);
- var existsToo = repository.Exists(1046);
- var doesntExists = repository.Exists(1050);
+ var exists = repository.Exists(NodeDto.NodeIdSeed + 1);
+ var existsToo = repository.Exists(NodeDto.NodeIdSeed + 1);
+ var doesntExists = repository.Exists(NodeDto.NodeIdSeed + 5);
// Assert
Assert.That(exists, Is.True);
@@ -337,17 +338,17 @@ namespace Umbraco.Tests.Persistence.Repositories
public void CreateTestData()
{
- //Create and Save folder-Media -> 1045
+ //Create and Save folder-Media -> NodeDto.NodeIdSeed
var folderMediaType = ServiceContext.ContentTypeService.GetMediaType(1031);
var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
ServiceContext.MediaService.Save(folder, 0);
- //Create and Save image-Media -> 1046
+ //Create and Save image-Media -> NodeDto.NodeIdSeed + 1
var imageMediaType = ServiceContext.ContentTypeService.GetMediaType(1032);
var image = MockedMedia.CreateMediaImage(imageMediaType, folder.Id);
ServiceContext.MediaService.Save(image, 0);
- //Create and Save file-Media -> 1047
+ //Create and Save file-Media -> NodeDto.NodeIdSeed + 2
var fileMediaType = ServiceContext.ContentTypeService.GetMediaType(1033);
var file = MockedMedia.CreateMediaFile(fileMediaType, folder.Id);
ServiceContext.MediaService.Save(file, 0);
diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs
index acb96da490..d10884cb39 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs
@@ -3,6 +3,7 @@ using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Caching;
using Umbraco.Core.Persistence.Repositories;
@@ -76,7 +77,7 @@ namespace Umbraco.Tests.Persistence.Repositories
unitOfWork.Commit();
// Act
- var mediaType = repository.Get(1045);
+ var mediaType = repository.Get(NodeDto.NodeIdSeed);
mediaType.Thumbnail = "Doc2.png";
mediaType.PropertyGroups["Media"].PropertyTypes.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext)
@@ -197,12 +198,12 @@ namespace Umbraco.Tests.Persistence.Repositories
unitOfWork.Commit();
// Act
- var mediaTypeV2 = repository.Get(1045);
+ var mediaTypeV2 = repository.Get(NodeDto.NodeIdSeed);
mediaTypeV2.PropertyGroups["Media"].PropertyTypes.Remove("title");
repository.AddOrUpdate(mediaTypeV2);
unitOfWork.Commit();
- var mediaTypeV3 = repository.Get(1045);
+ var mediaTypeV3 = repository.Get(NodeDto.NodeIdSeed);
// Assert
Assert.That(mediaTypeV3.PropertyTypes.Any(x => x.Alias == "title"), Is.False);
@@ -224,7 +225,7 @@ namespace Umbraco.Tests.Persistence.Repositories
unitOfWork.Commit();
// Act
- var contentType = repository.Get(1045);
+ var contentType = repository.Get(NodeDto.NodeIdSeed);
// Assert
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(2));
diff --git a/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs
index c727e04fd4..2eced7ef4d 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs
@@ -3,6 +3,7 @@ using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Caching;
using Umbraco.Core.Persistence.Querying;
@@ -59,7 +60,7 @@ namespace Umbraco.Tests.Persistence.Repositories
// Act
var relationType = repositoryType.Get(1);
- var relation = new Relation(1047, 1048, relationType);
+ var relation = new Relation(NodeDto.NodeIdSeed + 2, NodeDto.NodeIdSeed + 3, relationType);
repository.AddOrUpdate(relation);
unitOfWork.Commit();
@@ -132,8 +133,8 @@ namespace Umbraco.Tests.Persistence.Repositories
// Assert
Assert.That(relation, Is.Not.Null);
Assert.That(relation.HasIdentity, Is.True);
- Assert.That(relation.ChildId, Is.EqualTo(1047));
- Assert.That(relation.ParentId, Is.EqualTo(1046));
+ Assert.That(relation.ChildId, Is.EqualTo(NodeDto.NodeIdSeed + 2));
+ Assert.That(relation.ParentId, Is.EqualTo(NodeDto.NodeIdSeed + 1));
Assert.That(relation.RelationType.Alias, Is.EqualTo("relateContentOnCopy"));
}
}
@@ -211,7 +212,7 @@ namespace Umbraco.Tests.Persistence.Repositories
{
// Act
- var query = Query.Builder.Where(x => x.ParentId == 1046);
+ var query = Query.Builder.Where(x => x.ParentId == NodeDto.NodeIdSeed + 1);
int count = repository.Count(query);
// Assert
@@ -251,7 +252,7 @@ namespace Umbraco.Tests.Persistence.Repositories
using (var repository = CreateRepository(unitOfWork, out repositoryType))
{
- var content = ServiceContext.ContentService.GetById(1047);
+ var content = ServiceContext.ContentService.GetById(NodeDto.NodeIdSeed + 2);
ServiceContext.ContentService.Delete(content, 0);
// Act
@@ -284,19 +285,19 @@ namespace Umbraco.Tests.Persistence.Repositories
relationTypeRepository.AddOrUpdate(relateContentType);
unitOfWork.Commit();
- //Create and Save ContentType "umbTextpage" -> 1045
+ //Create and Save ContentType "umbTextpage" -> NodeDto.NodeIdSeed
ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage");
ServiceContext.ContentTypeService.Save(contentType);
- //Create and Save Content "Homepage" based on "umbTextpage" -> 1046
+ //Create and Save Content "Homepage" based on "umbTextpage" -> NodeDto.NodeIdSeed + 1
Content textpage = MockedContent.CreateSimpleContent(contentType);
ServiceContext.ContentService.Save(textpage, 0);
- //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1047
+ //Create and Save Content "Text Page 1" based on "umbTextpage" -> NodeDto.NodeIdSeed + 2
Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Page 1", textpage.Id);
ServiceContext.ContentService.Save(subpage, 0);
- //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1048
+ //Create and Save Content "Text Page 1" based on "umbTextpage" -> NodeDto.NodeIdSeed + 3
Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Page 2", textpage.Id);
ServiceContext.ContentService.Save(subpage2, 0);
diff --git a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
index 38da2383f2..c6bc06ae1c 100644
--- a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
+++ b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
@@ -25,7 +26,7 @@ namespace Umbraco.Tests.Services
public void Creating_100_Items()
{
// Arrange
- var contentType = ServiceContext.ContentTypeService.GetContentType(1045);
+ var contentType = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
var pages = MockedContent.CreateTextpageContent(contentType, -1, 100);
// Act
@@ -44,7 +45,7 @@ namespace Umbraco.Tests.Services
public void Creating_1000_Items()
{
// Arrange
- var contentType = ServiceContext.ContentTypeService.GetContentType(1045);
+ var contentType = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
var pages = MockedContent.CreateTextpageContent(contentType, -1, 1000);
// Act
@@ -63,7 +64,7 @@ namespace Umbraco.Tests.Services
public void Getting_100_Uncached_Items()
{
// Arrange
- var contentType = ServiceContext.ContentTypeService.GetContentType(1045);
+ var contentType = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
var pages = MockedContent.CreateTextpageContent(contentType, -1, 100);
ServiceContext.ContentService.Save(pages, 0);
@@ -88,7 +89,7 @@ namespace Umbraco.Tests.Services
public void Getting_1000_Uncached_Items()
{
// Arrange
- var contentType = ServiceContext.ContentTypeService.GetContentType(1045);
+ var contentType = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
var pages = MockedContent.CreateTextpageContent(contentType, -1, 1000);
ServiceContext.ContentService.Save(pages, 0);
@@ -113,7 +114,7 @@ namespace Umbraco.Tests.Services
public void Getting_100_Cached_Items()
{
// Arrange
- var contentType = ServiceContext.ContentTypeService.GetContentType(1045);
+ var contentType = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
var pages = MockedContent.CreateTextpageContent(contentType, -1, 100);
ServiceContext.ContentService.Save(pages, 0);
@@ -141,7 +142,7 @@ namespace Umbraco.Tests.Services
public void Getting_1000_Cached_Items()
{
// Arrange
- var contentType = ServiceContext.ContentTypeService.GetContentType(1045);
+ var contentType = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
var pages = MockedContent.CreateTextpageContent(contentType, -1, 1000);
ServiceContext.ContentService.Save(pages, 0);
@@ -173,7 +174,7 @@ namespace Umbraco.Tests.Services
public void CreateTestData()
{
- //Create and Save ContentType "textpage" -> 1045
+ //Create and Save ContentType "textpage" -> NodeDto.NodeIdSeed
ContentType contentType = MockedContentTypes.CreateTextpageContentType();
ServiceContext.ContentTypeService.Save(contentType);
}
diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs
index 1f693509a3..2bf41db197 100644
--- a/src/Umbraco.Tests/Services/ContentServiceTests.cs
+++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs
@@ -461,7 +461,7 @@ namespace Umbraco.Tests.Services
contentService.Save(content);
var parent = contentService.GetById(NodeDto.NodeIdSeed + 1);
- bool parentPublished = contentService.Publish(parent, 0);//Publish root Home node to enable publishing of '1048'
+ bool parentPublished = contentService.Publish(parent, 0);//Publish root Home node to enable publishing of 'NodeDto.NodeIdSeed + 3'
// Act
bool published = contentService.Publish(content, 0);
@@ -482,7 +482,7 @@ namespace Umbraco.Tests.Services
contentService.Save(content, 0);
var parent = contentService.GetById(NodeDto.NodeIdSeed + 1);
- bool parentPublished = contentService.Publish(parent, 0);//Publish root Home node to enable publishing of '1048'
+ bool parentPublished = contentService.Publish(parent, 0);//Publish root Home node to enable publishing of 'NodeDto.NodeIdSeed + 3'
// Act
bool published = contentService.Publish(content, 0);
diff --git a/src/Umbraco.Tests/Services/DataTypeServiceTests.cs b/src/Umbraco.Tests/Services/DataTypeServiceTests.cs
index 31b0489949..a05ea8aa83 100644
--- a/src/Umbraco.Tests/Services/DataTypeServiceTests.cs
+++ b/src/Umbraco.Tests/Services/DataTypeServiceTests.cs
@@ -2,6 +2,7 @@
using System.Linq;
using NUnit.Framework;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Rdbms;
namespace Umbraco.Tests.Services
{
@@ -58,7 +59,7 @@ namespace Umbraco.Tests.Services
Assert.That(deletedDefinition, Is.Null);
//Further assertions against the ContentType that contains PropertyTypes based on the TextField
- var contentType = ServiceContext.ContentTypeService.GetContentType(1045);
+ var contentType = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
Assert.That(contentType.Alias, Is.EqualTo("umbTextpage"));
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(1));
}