diff --git a/src/Umbraco.Core/Models/Rdbms/NodeDto.cs b/src/Umbraco.Core/Models/Rdbms/NodeDto.cs
index ccbe9a1639..a89879d8b5 100644
--- a/src/Umbraco.Core/Models/Rdbms/NodeDto.cs
+++ b/src/Umbraco.Core/Models/Rdbms/NodeDto.cs
@@ -9,8 +9,10 @@ namespace Umbraco.Core.Models.Rdbms
[ExplicitColumns]
internal class NodeDto
{
+ public const int NodeIdSeed = 1050;
+
[Column("id")]
- [PrimaryKeyColumn(Name = "PK_structure", IdentitySeed = 1045)]
+ [PrimaryKeyColumn(Name = "PK_structure", IdentitySeed = NodeIdSeed)]
public int NodeId { get; set; }
[Column("trashed")]
diff --git a/src/Umbraco.Core/Publishing/PublishStatus.cs b/src/Umbraco.Core/Publishing/PublishStatus.cs
index aee9a1fafe..519046f5f9 100644
--- a/src/Umbraco.Core/Publishing/PublishStatus.cs
+++ b/src/Umbraco.Core/Publishing/PublishStatus.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Publishing
///
/// The result of publishing a content item
///
- internal class PublishStatus
+ public class PublishStatus
{
public PublishStatus()
{
@@ -26,9 +26,9 @@ namespace Umbraco.Core.Publishing
///
public PublishStatus(IContent content)
: this(content, PublishStatusType.Success)
- {
+ {
}
-
+
public IContent ContentItem { get; private set; }
public PublishStatusType StatusType { get; internal set; }
diff --git a/src/Umbraco.Core/Publishing/PublishStatusType.cs b/src/Umbraco.Core/Publishing/PublishStatusType.cs
index c3cb76e245..0d9ffcfa02 100644
--- a/src/Umbraco.Core/Publishing/PublishStatusType.cs
+++ b/src/Umbraco.Core/Publishing/PublishStatusType.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Publishing
///
/// Anything less than 10 = Success!
///
- internal enum PublishStatusType
+ public enum PublishStatusType
{
///
/// The publishing was successful.
diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs
index 9d80369e93..7c54af38b3 100644
--- a/src/Umbraco.Core/Services/ContentService.cs
+++ b/src/Umbraco.Core/Services/ContentService.cs
@@ -220,6 +220,19 @@ namespace Umbraco.Core.Services
}
}
+ ///
+ /// Gets an object by Id
+ ///
+ /// Ids of the Content to retrieve
+ ///
+ public IEnumerable GetByIds(IEnumerable ids)
+ {
+ using (var repository = _repositoryFactory.CreateContentRepository(_uowProvider.GetUnitOfWork()))
+ {
+ return repository.GetAll(ids.ToArray());
+ }
+ }
+
///
/// Gets an object by its 'UniqueId'
///
@@ -597,10 +610,22 @@ namespace Umbraco.Core.Services
/// The to publish
/// Optional Id of the User issueing the publishing
/// True if publishing succeeded, otherwise False
+ [Obsolete("Use PublishWithStatus instead, that method will provide more detailed information on the outcome")]
public bool Publish(IContent content, int userId = 0)
{
var result = SaveAndPublishDo(content, userId);
- return result.Success;
+ return result.Success;
+ }
+
+ ///
+ /// Publishes a single object
+ ///
+ /// The to publish
+ /// Optional Id of the User issueing the publishing
+ /// True if publishing succeeded, otherwise False
+ public Attempt PublishWithStatus(IContent content, int userId = 0)
+ {
+ return SaveAndPublishDo(content, userId);
}
///
@@ -609,16 +634,29 @@ namespace Umbraco.Core.Services
/// The to publish along with its children
/// Optional Id of the User issueing the publishing
/// True if publishing succeeded, otherwise False
+ [Obsolete("Use PublishWithChildrenWithStatus instead, that method will provide more detailed information on the outcome and also allows the includeUnpublished flag")]
public bool PublishWithChildren(IContent content, int userId = 0)
{
var result = PublishWithChildrenDo(content, userId, true);
-
+
//This used to just return false only when the parent content failed, otherwise would always return true so we'll
// do the same thing for the moment
- if (!result.Any(x => x.Result.ContentItem.Id == content.Id))
- return false;
+ if (!result.Any(x => x.Result.ContentItem.Id == content.Id))
+ return false;
- return result.Single(x => x.Result.ContentItem.Id == content.Id).Success;
+ return result.Single(x => x.Result.ContentItem.Id == content.Id).Success;
+ }
+
+ ///
+ /// Publishes a object and all its children
+ ///
+ /// The to publish along with its children
+ /// Optional Id of the User issueing the publishing
+ /// set to true if you want to also publish children that are currently unpublished
+ /// True if publishing succeeded, otherwise False
+ public IEnumerable> PublishWithChildrenWithStatus(IContent content, int userId = 0, bool includeUnpublished = false)
+ {
+ return PublishWithChildrenDo(content, userId, includeUnpublished);
}
///
@@ -639,10 +677,23 @@ namespace Umbraco.Core.Services
/// Optional Id of the User issueing the publishing
/// Optional boolean indicating whether or not to raise save events.
/// True if publishing succeeded, otherwise False
+ [Obsolete("Use SaveAndPublishWithStatus instead, that method will provide more detailed information on the outcome")]
public bool SaveAndPublish(IContent content, int userId = 0, bool raiseEvents = true)
{
var result = SaveAndPublishDo(content, userId, raiseEvents);
- return result.Success;
+ return result.Success;
+ }
+
+ ///
+ /// Saves and Publishes a single object
+ ///
+ /// The to save and publish
+ /// Optional Id of the User issueing the publishing
+ /// Optional boolean indicating whether or not to raise save events.
+ /// True if publishing succeeded, otherwise False
+ public Attempt SaveAndPublishWithStatus(IContent content, int userId = 0, bool raiseEvents = true)
+ {
+ return SaveAndPublishDo(content, userId, raiseEvents);
}
///
@@ -1160,18 +1211,20 @@ namespace Umbraco.Core.Services
/// The to send to publication
/// Optional Id of the User issueing the send to publication
/// True if sending publication was succesfull otherwise false
- internal bool SendToPublication(IContent content, int userId = 0)
+ public bool SendToPublication(IContent content, int userId = 0)
{
if (SendingToPublish.IsRaisedEventCancelled(new SendToPublishEventArgs(content), this))
return false;
- //TODO: Do some stuff here.. RunActionHandlers
+ //TODO: Do some stuff here.. ... what is it supposed to do ?
+ // pretty sure all that legacy stuff did was raise an event? and we no longer have IActionHandlers so no worries there.
SentToPublish.RaiseEvent(new SendToPublishEventArgs(content, false), this);
Audit.Add(AuditTypes.SendToPublish, "Send to Publish performed by user", content.WriterId, content.Id);
+ //TODO: will this ever be false??
return true;
}
diff --git a/src/Umbraco.Core/Services/IContentService.cs b/src/Umbraco.Core/Services/IContentService.cs
index 6525a9d825..0a19deda6e 100644
--- a/src/Umbraco.Core/Services/IContentService.cs
+++ b/src/Umbraco.Core/Services/IContentService.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Membership;
+using Umbraco.Core.Publishing;
namespace Umbraco.Core.Services
{
@@ -9,6 +11,11 @@ namespace Umbraco.Core.Services
///
public interface IContentService : IService
{
+
+ bool SendToPublication(IContent content, int userId = 0);
+
+ IEnumerable GetByIds(IEnumerable ids);
+
///
/// Creates an object using the alias of the
/// that this Content should based on.
@@ -121,7 +128,7 @@ namespace Umbraco.Core.Services
/// Collection of to save
/// Optional Id of the User saving the Content
/// Optional boolean indicating whether or not to raise events.
- void Save(IEnumerable contents, int userId = 0, bool raiseEvents = true);
+ void Save(IEnumerable contents, int userId = 0, bool raiseEvents = true);
///
/// Deletes all content of specified type. All children of deleted content is moved to Recycle Bin.
@@ -242,16 +249,35 @@ namespace Umbraco.Core.Services
/// The to publish
/// Optional Id of the User issueing the publishing
/// True if publishing succeeded, otherwise False
+ [Obsolete("Use PublishWithStatus instead, that method will provide more detailed information on the outcome")]
bool Publish(IContent content, int userId = 0);
+ ///
+ /// Publishes a single object
+ ///
+ /// The to publish
+ /// Optional Id of the User issueing the publishing
+ /// The published status attempt
+ Attempt PublishWithStatus(IContent content, int userId = 0);
+
///
/// Publishes a object and all its children
///
/// The to publish along with its children
/// Optional Id of the User issueing the publishing
/// True if publishing succeeded, otherwise False
+ [Obsolete("Use PublishWithChildrenWithStatus instead, that method will provide more detailed information on the outcome and also allows the includeUnpublished flag")]
bool PublishWithChildren(IContent content, int userId = 0);
+ ///
+ /// Publishes a object and all its children
+ ///
+ /// The to publish along with its children
+ /// Optional Id of the User issueing the publishing
+ ///
+ /// The list of statuses for all published items
+ IEnumerable> PublishWithChildrenWithStatus(IContent content, int userId = 0, bool includeUnpublished = false);
+
///
/// UnPublishes a single object
///
@@ -267,8 +293,18 @@ namespace Umbraco.Core.Services
/// Optional Id of the User issueing the publishing
/// Optional boolean indicating whether or not to raise save events.
/// True if publishing succeeded, otherwise False
+ [Obsolete("Use SaveAndPublishWithStatus instead, that method will provide more detailed information on the outcome")]
bool SaveAndPublish(IContent content, int userId = 0, bool raiseEvents = true);
+ ///
+ /// Saves and Publishes a single object
+ ///
+ /// The to save and publish
+ /// Optional Id of the User issueing the publishing
+ /// Optional boolean indicating whether or not to raise save events.
+ /// True if publishing succeeded, otherwise False
+ Attempt SaveAndPublishWithStatus(IContent content, int userId = 0, bool raiseEvents = true);
+
///
/// Permanently deletes an object.
///
@@ -311,6 +347,8 @@ namespace Umbraco.Core.Services
/// to retrieve ancestors for
/// An Enumerable list of objects
IEnumerable GetAncestors(IContent content);
+
+ ///
/// Sorts a collection of objects by updating the SortOrder according
/// to the ordering of items in the passed in .
///
@@ -337,6 +375,8 @@ namespace Umbraco.Core.Services
/// to retrieve the parent from
/// Parent object
IContent GetParent(IContent content);
+
+ ///
/// Creates and saves an object using the alias of the
/// that this Content should based on.
///
diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs
index 047fc202ed..1f693509a3 100644
--- a/src/Umbraco.Tests/Services/ContentServiceTests.cs
+++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs
@@ -5,6 +5,7 @@ using System.Threading;
using NUnit.Framework;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
+using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
@@ -24,21 +25,21 @@ namespace Umbraco.Tests.Services
[SetUp]
public override void Initialize()
{
- base.Initialize();
+ base.Initialize();
+ }
+
+ [TearDown]
+ public override void TearDown()
+ {
+ base.TearDown();
}
-
- [TearDown]
- public override void TearDown()
- {
- base.TearDown();
- }
//TODO Add test to verify there is only ONE newest document/content in cmsDocument table after updating.
//TODO Add test to delete specific version (with and without deleting prior versions) and versions by date.
-
- [Test]
- public void Can_Remove_Property_Type()
- {
+
+ [Test]
+ public void Can_Remove_Property_Type()
+ {
// Arrange
var contentService = ServiceContext.ContentService;
@@ -48,9 +49,9 @@ namespace Umbraco.Tests.Services
// Assert
Assert.That(content, Is.Not.Null);
Assert.That(content.HasIdentity, Is.False);
- }
+ }
- [Test]
+ [Test]
public void Can_Create_Content()
{
// Arrange
@@ -63,7 +64,7 @@ namespace Umbraco.Tests.Services
Assert.That(content, Is.Not.Null);
Assert.That(content.HasIdentity, Is.False);
}
-
+
[Test]
public void Can_Create_Content_Without_Explicitly_Set_User()
{
@@ -83,12 +84,12 @@ namespace Umbraco.Tests.Services
public void Can_Save_New_Content_With_Explicit_User()
{
var user = new User(ServiceContext.UserService.GetUserTypeByAlias("admin"))
- {
- Name = "Test",
- Email = "test@test.com",
- Username = "test",
- Password = "test"
- };
+ {
+ Name = "Test",
+ Email = "test@test.com",
+ Username = "test",
+ Password = "test"
+ };
ServiceContext.UserService.SaveUser(user);
var content = new Content("Test", -1, ServiceContext.ContentTypeService.GetContentType("umbTextpage"));
@@ -117,11 +118,11 @@ namespace Umbraco.Tests.Services
var contentService = ServiceContext.ContentService;
// Act
- var content = contentService.GetById(1046);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(content, Is.Not.Null);
- Assert.That(content.Id, Is.EqualTo(1046));
+ Assert.That(content.Id, Is.EqualTo(NodeDto.NodeIdSeed + 1));
}
[Test]
@@ -135,7 +136,7 @@ namespace Umbraco.Tests.Services
// Assert
Assert.That(content, Is.Not.Null);
- Assert.That(content.Id, Is.EqualTo(1046));
+ Assert.That(content.Id, Is.EqualTo(NodeDto.NodeIdSeed + 1));
}
[Test]
@@ -160,7 +161,7 @@ namespace Umbraco.Tests.Services
var contentService = ServiceContext.ContentService;
// Act
- var contents = contentService.GetChildren(1046);
+ var contents = contentService.GetChildren(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(contents, Is.Not.Null);
@@ -177,7 +178,7 @@ namespace Umbraco.Tests.Services
contentService.Save(hierarchy, 0);
// Act
- var contents = contentService.GetDescendants(1046);
+ var contents = contentService.GetDescendants(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(contents, Is.Not.Null);
@@ -190,15 +191,15 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var parent = ServiceContext.ContentService.GetById(1046);
+ var parent = ServiceContext.ContentService.GetById(NodeDto.NodeIdSeed + 1);
ServiceContext.ContentService.Publish(parent);//Publishing root, so Text Page 2 can be updated.
- var subpage2 = contentService.GetById(1048);
+ var subpage2 = contentService.GetById(NodeDto.NodeIdSeed + 3);
subpage2.Name = "Text Page 2 Updated";
subpage2.SetValue("author", "Jane Doe");
contentService.SaveAndPublish(subpage2, 0);//NOTE New versions are only added between publish-state-changed, so publishing to ensure addition version.
// Act
- var versions = contentService.GetVersions(1048);
+ var versions = contentService.GetVersions(NodeDto.NodeIdSeed + 3);
// Assert
Assert.That(versions.Any(), Is.True);
@@ -225,9 +226,9 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var root = contentService.GetById(1046);
+ var root = contentService.GetById(NodeDto.NodeIdSeed + 1);
contentService.SaveAndPublish(root);
- var content = contentService.GetById(1048);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 3);
content.ExpireDate = DateTime.Now.AddSeconds(1);
contentService.SaveAndPublish(content);
@@ -278,7 +279,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1046);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 1);
bool published = contentService.Publish(content, 0);
// Act
@@ -304,24 +305,24 @@ namespace Umbraco.Tests.Services
// Arrange
var contentService = ServiceContext.ContentService;
var published = contentService.RePublishAll(0);
- var content = contentService.GetById(1046);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 1);
// Act
bool unpublished = contentService.UnPublish(content, 0);
- var children = contentService.GetChildren(1046);
+ var children = contentService.GetChildren(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(published, Is.True);//Verify that everything was published
-
- //Verify that content with Id 1046 was unpublished
+
+ //Verify that content with Id (NodeDto.NodeIdSeed + 1) was unpublished
Assert.That(unpublished, Is.True);
Assert.That(content.Published, Is.False);
//Verify that all children was unpublished
Assert.That(children.Any(x => x.Published), Is.False);
- Assert.That(children.First(x => x.Id == 1047).Published, Is.False);//Released 5 mins ago, but should be unpublished
- Assert.That(children.First(x => x.Id == 1047).ReleaseDate.HasValue, Is.False);//Verify that the release date has been removed
- Assert.That(children.First(x => x.Id == 1048).Published, Is.False);//Expired 5 mins ago, so isn't be published
+ Assert.That(children.First(x => x.Id == NodeDto.NodeIdSeed + 2).Published, Is.False);//Released 5 mins ago, but should be unpublished
+ Assert.That(children.First(x => x.Id == NodeDto.NodeIdSeed + 2).ReleaseDate.HasValue, Is.False);//Verify that the release date has been removed
+ Assert.That(children.First(x => x.Id == NodeDto.NodeIdSeed + 3).Published, Is.False);//Expired 5 mins ago, so isn't be published
}
[Test]
@@ -337,7 +338,7 @@ namespace Umbraco.Tests.Services
var allContent = rootContent.Concat(rootContent.SelectMany(x => x.Descendants()));
//for testing we need to clear out the contentXml table so we can see if it worked
var provider = new PetaPocoUnitOfWorkProvider();
- var uow = provider.GetUnitOfWork();
+ var uow = provider.GetUnitOfWork();
using (RepositoryResolver.Current.ResolveByType(uow))
{
uow.Database.TruncateTable("cmsContentXml");
@@ -345,7 +346,7 @@ namespace Umbraco.Tests.Services
//for this test we are also going to save a revision for a content item that is not published, this is to ensure
//that it's published version still makes it into the cmsContentXml table!
contentService.Save(allContent.Last());
-
+
// Act
var published = contentService.RePublishAll(0);
@@ -382,7 +383,7 @@ namespace Umbraco.Tests.Services
// Act
- contentService.RePublishAll(new int[]{allContent.Last().ContentTypeId});
+ contentService.RePublishAll(new int[] { allContent.Last().ContentTypeId });
// Assert
uow = provider.GetUnitOfWork();
@@ -397,7 +398,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1046);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 1);
// Act
bool published = contentService.Publish(content, 0);
@@ -416,12 +417,12 @@ namespace Umbraco.Tests.Services
var contentType = MockedContentTypes.CreateSimpleContentType("umbMandatory", "Mandatory Doc Type", true);
contentTypeService.Save(contentType);
- Content content = MockedContent.CreateSimpleContent(contentType, "Invalid Content", 1046);
+ Content content = MockedContent.CreateSimpleContent(contentType, "Invalid Content", NodeDto.NodeIdSeed + 1);
content.SetValue("author", string.Empty);
contentService.Save(content, 0);
// Act
- var parent = contentService.GetById(1046);
+ var parent = contentService.GetById(NodeDto.NodeIdSeed + 1);
bool parentPublished = contentService.Publish(parent, 0);
bool published = contentService.Publish(content, 0);
@@ -438,16 +439,16 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1046);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 1);
// Act
bool published = contentService.PublishWithChildren(content, 0);
- var children = contentService.GetChildren(1046);
+ var children = contentService.GetChildren(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(published, Is.True);//Nothing was cancelled, so should be true
Assert.That(content.Published, Is.True);//No restrictions, so should be published
- Assert.That(children.First(x => x.Id == 1047).Published, Is.True);//Released 5 mins ago, so should be published
+ Assert.That(children.First(x => x.Id == NodeDto.NodeIdSeed + 2).Published, Is.True);//Released 5 mins ago, so should be published
}
[Test]
@@ -455,11 +456,11 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1048); //This Content expired 5min ago
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 3); //This Content expired 5min ago
content.ExpireDate = DateTime.Now.AddMinutes(-5);
contentService.Save(content);
- var parent = contentService.GetById(1046);
+ var parent = contentService.GetById(NodeDto.NodeIdSeed + 1);
bool parentPublished = contentService.Publish(parent, 0);//Publish root Home node to enable publishing of '1048'
// Act
@@ -476,11 +477,11 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1047);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 2);
content.ReleaseDate = DateTime.Now.AddHours(2);
contentService.Save(content, 0);
- var parent = contentService.GetById(1046);
+ var parent = contentService.GetById(NodeDto.NodeIdSeed + 1);
bool parentPublished = contentService.Publish(parent, 0);//Publish root Home node to enable publishing of '1048'
// Act
@@ -497,7 +498,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.CreateContent("Subpage with Unpublisehed Parent", 1046, "umbTextpage", 0);
+ var content = contentService.CreateContent("Subpage with Unpublisehed Parent", NodeDto.NodeIdSeed + 1, "umbTextpage", 0);
contentService.Save(content, 0);
// Act
@@ -513,7 +514,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1049);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 4);
// Act
bool published = contentService.Publish(content, 0);
@@ -529,7 +530,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.CreateContent("Home US", - 1, "umbTextpage", 0);
+ var content = contentService.CreateContent("Home US", -1, "umbTextpage", 0);
content.SetValue("author", "Barack Obama");
// Act
@@ -546,9 +547,9 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var root = contentService.GetById(1046);
+ var root = contentService.GetById(NodeDto.NodeIdSeed + 1);
var rootPublished = contentService.Publish(root);
- var content = contentService.GetById(1048);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 3);
content.Properties["title"].Value = content.Properties["title"].Value + " Published";
bool published = contentService.SaveAndPublish(content);
@@ -560,7 +561,7 @@ namespace Umbraco.Tests.Services
var savedVersion = content.Version;
// Act
- var publishedDescendants = ((ContentService) contentService).GetPublishedDescendants(root);
+ var publishedDescendants = ((ContentService)contentService).GetPublishedDescendants(root);
// Assert
Assert.That(rootPublished, Is.True);
@@ -579,7 +580,7 @@ namespace Umbraco.Tests.Services
Assert.That(savedContentVersion.Properties["title"].Value, Contains.Substring("Saved"));
//Ensure that the latest version of the content is the saved and not-yet-published one
- var currentContent = contentService.GetById(1048);
+ var currentContent = contentService.GetById(NodeDto.NodeIdSeed + 3);
Assert.That(currentContent.Published, Is.False);
Assert.That(currentContent.Properties["title"].Value, Contains.Substring("Saved"));
Assert.That(currentContent.Version, Is.EqualTo(savedVersion));
@@ -590,7 +591,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.CreateContent("Home US", - 1, "umbTextpage", 0);
+ var content = contentService.CreateContent("Home US", -1, "umbTextpage", 0);
content.SetValue("author", "Barack Obama");
// Act
@@ -608,9 +609,9 @@ namespace Umbraco.Tests.Services
var contentTypeService = ServiceContext.ContentTypeService;
var contentType = contentTypeService.GetContentType("umbTextpage");
- Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Subpage 1", 1047);
- Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Subpage 2", 1047);
- var list = new List {subpage, subpage2};
+ Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Subpage 1", NodeDto.NodeIdSeed + 2);
+ Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Subpage 2", NodeDto.NodeIdSeed + 2);
+ var list = new List { subpage, subpage2 };
// Act
contentService.Save(list, 0);
@@ -630,9 +631,9 @@ namespace Umbraco.Tests.Services
contentService.Save(hierarchy, 0);
Assert.That(hierarchy.Any(), Is.True);
- Assert.That(hierarchy.Any(x => x.HasIdentity == false), Is.False);
- //all parent id's should be ok, they are lazy and if they equal zero an exception will be thrown
- Assert.DoesNotThrow(() => hierarchy.Any(x => x.ParentId != 0));
+ Assert.That(hierarchy.Any(x => x.HasIdentity == false), Is.False);
+ //all parent id's should be ok, they are lazy and if they equal zero an exception will be thrown
+ Assert.DoesNotThrow(() => hierarchy.Any(x => x.ParentId != 0));
}
@@ -659,11 +660,11 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1049);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 4);
// Act
contentService.Delete(content, 0);
- var deleted = contentService.GetById(1049);
+ var deleted = contentService.GetById(NodeDto.NodeIdSeed + 4);
// Assert
Assert.That(deleted, Is.Null);
@@ -674,7 +675,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1048);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 3);
// Act
contentService.MoveToRecycleBin(content, 0);
@@ -690,10 +691,10 @@ namespace Umbraco.Tests.Services
// Arrange
var contentService = ServiceContext.ContentService;
var contentType = ServiceContext.ContentTypeService.GetContentType("umbTextpage");
- Content subsubpage = MockedContent.CreateSimpleContent(contentType, "Text Page 3", 1047);
+ Content subsubpage = MockedContent.CreateSimpleContent(contentType, "Text Page 3", NodeDto.NodeIdSeed + 2);
contentService.Save(subsubpage, 0);
- var content = contentService.GetById(1046);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 1);
// Act
contentService.MoveToRecycleBin(content, 0);
@@ -731,13 +732,13 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1049);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 4);
// Act - moving out of recycle bin
- contentService.Move(content, 1046, 0);
+ contentService.Move(content, NodeDto.NodeIdSeed + 1, 0);
// Assert
- Assert.That(content.ParentId, Is.EqualTo(1046));
+ Assert.That(content.ParentId, Is.EqualTo(NodeDto.NodeIdSeed + 1));
Assert.That(content.Trashed, Is.False);
Assert.That(content.Published, Is.False);
}
@@ -747,11 +748,11 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var temp = contentService.GetById(1048);
+ var temp = contentService.GetById(NodeDto.NodeIdSeed + 3);
// Act
var copy = contentService.Copy(temp, temp.ParentId, false, 0);
- var content = contentService.GetById(1048);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 3);
// Assert
Assert.That(copy, Is.Not.Null);
@@ -764,7 +765,7 @@ namespace Umbraco.Tests.Services
}
//Assert.AreNotEqual(content.Name, copy.Name);
}
-
+
[Test, NUnit.Framework.Ignore]
public void Can_Send_To_Publication()
{ }
@@ -774,9 +775,9 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var parent = ServiceContext.ContentService.GetById(1046);
+ var parent = ServiceContext.ContentService.GetById(NodeDto.NodeIdSeed + 1);
ServiceContext.ContentService.Publish(parent);//Publishing root, so Text Page 2 can be updated.
- var subpage2 = contentService.GetById(1048);
+ var subpage2 = contentService.GetById(NodeDto.NodeIdSeed + 3);
var version = subpage2.Version;
var nameBeforeRollback = subpage2.Name;
subpage2.Name = "Text Page 2 Updated";
@@ -784,7 +785,7 @@ namespace Umbraco.Tests.Services
contentService.SaveAndPublish(subpage2, 0);//Saving and publishing, so a new version is created
// Act
- var rollback = contentService.Rollback(1048, version, 0);
+ var rollback = contentService.Rollback(NodeDto.NodeIdSeed + 3, version, 0);
// Assert
Assert.That(rollback, Is.Not.Null);
@@ -795,14 +796,14 @@ namespace Umbraco.Tests.Services
[Test]
public void Can_Save_Lazy_Content()
- {
- var unitOfWork = PetaPocoUnitOfWorkProvider.CreateUnitOfWork();
+ {
+ var unitOfWork = PetaPocoUnitOfWorkProvider.CreateUnitOfWork();
var contentType = ServiceContext.ContentTypeService.GetContentType("umbTextpage");
- var root = ServiceContext.ContentService.GetById(1046);
+ var root = ServiceContext.ContentService.GetById(NodeDto.NodeIdSeed + 1);
var c = new Lazy(() => MockedContent.CreateSimpleContent(contentType, "Hierarchy Simple Text Page", root.Id));
var c2 = new Lazy(() => MockedContent.CreateSimpleContent(contentType, "Hierarchy Simple Text Subpage", c.Value.Id));
- var list = new List> {c, c2};
+ var list = new List> { c, c2 };
var repository = RepositoryResolver.Current.ResolveByType(unitOfWork);
foreach (var content in list)
@@ -826,14 +827,14 @@ namespace Umbraco.Tests.Services
{
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1046);
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 1);
bool published = contentService.PublishWithChildren(content, 0);
- var homepage = contentService.GetById(1046);
+ var homepage = contentService.GetById(NodeDto.NodeIdSeed + 1);
homepage.Name = "Homepage";
ServiceContext.ContentService.Save(homepage);
// Act
- bool hasPublishedVersion = ServiceContext.ContentService.HasPublishedVersion(1046);
+ bool hasPublishedVersion = ServiceContext.ContentService.HasPublishedVersion(NodeDto.NodeIdSeed + 1);
// Assert
Assert.That(published, Is.True);
@@ -841,20 +842,20 @@ namespace Umbraco.Tests.Services
Assert.That(hasPublishedVersion, Is.True);
}
- [Test]
- public void Can_Verify_Property_Types_On_Content()
- {
+ [Test]
+ public void Can_Verify_Property_Types_On_Content()
+ {
// Arrange
- var contentTypeService = ServiceContext.ContentTypeService;
+ var contentTypeService = ServiceContext.ContentTypeService;
var contentType = MockedContentTypes.CreateAllTypesContentType("allDataTypes", "All DataTypes");
contentTypeService.Save(contentType);
- var contentService = ServiceContext.ContentService;
- var content = MockedContent.CreateAllTypesContent(contentType, "Random Content", -1);
+ var contentService = ServiceContext.ContentService;
+ var content = MockedContent.CreateAllTypesContent(contentType, "Random Content", -1);
contentService.Save(content);
- var id = content.Id;
+ var id = content.Id;
// Act
- var sut = contentService.GetById(id);
+ var sut = contentService.GetById(id);
// Arrange
Assert.That(sut.GetValue("isTrue"), Is.True);
@@ -868,7 +869,7 @@ namespace Umbraco.Tests.Services
//MCH: I'm guessing this is an issue because of the format the date is actually stored as, right? Cause we don't do any formatting when saving or loading
Assert.That(sut.GetValue("dateTime").ToString("G"), Is.EqualTo(content.GetValue("dateTime").ToString("G")));
Assert.That(sut.GetValue("colorPicker"), Is.EqualTo("black"));
- Assert.That(sut.GetValue("folderBrowser"), Is.Empty);
+ Assert.That(sut.GetValue("folderBrowser"), Is.Empty);
Assert.That(sut.GetValue("ddlMultiple"), Is.EqualTo("1234,1235"));
Assert.That(sut.GetValue("rbList"), Is.EqualTo("random"));
Assert.That(sut.GetValue("date").ToString("G"), Is.EqualTo(content.GetValue("date").ToString("G")));
@@ -877,40 +878,36 @@ namespace Umbraco.Tests.Services
Assert.That(sut.GetValue("contentPicker"), Is.EqualTo(1090));
Assert.That(sut.GetValue("mediaPicker"), Is.EqualTo(1091));
Assert.That(sut.GetValue("memberPicker"), Is.EqualTo(1092));
- Assert.That(sut.GetValue("simpleEditor"), Is.EqualTo("This is simply edited"));
- Assert.That(sut.GetValue("ultimatePicker"), Is.EqualTo("1234,1235"));
Assert.That(sut.GetValue("relatedLinks"), Is.EqualTo(""));
Assert.That(sut.GetValue("tags"), Is.EqualTo("this,is,tags"));
- Assert.That(sut.GetValue("macroContainer"), Is.Empty);
- Assert.That(sut.GetValue("imgCropper"), Is.Empty);
- }
+ }
- [Test]
- public void Can_Delete_Previous_Versions_Not_Latest()
- {
+ [Test]
+ public void Can_Delete_Previous_Versions_Not_Latest()
+ {
// Arrange
var contentService = ServiceContext.ContentService;
- var content = contentService.GetById(1049);
- var version = content.Version;
+ var content = contentService.GetById(NodeDto.NodeIdSeed + 4);
+ var version = content.Version;
- // Act
- contentService.DeleteVersion(1049, version, true, 0);
- var sut = contentService.GetById(1049);
+ // Act
+ contentService.DeleteVersion(NodeDto.NodeIdSeed + 4, version, true, 0);
+ var sut = contentService.GetById(NodeDto.NodeIdSeed + 4);
// Assert
Assert.That(sut.Version, Is.EqualTo(version));
- }
+ }
private IEnumerable CreateContentHierarchy()
{
var contentType = ServiceContext.ContentTypeService.GetContentType("umbTextpage");
- var root = ServiceContext.ContentService.GetById(1046);
+ var root = ServiceContext.ContentService.GetById(NodeDto.NodeIdSeed + 1);
- var list = new List();
+ var list = new List();
for (int i = 0; i < 10; i++)
{
- var content = MockedContent.CreateSimpleContent(contentType, "Hierarchy Simple Text Page " + i, root);
+ var content = MockedContent.CreateSimpleContent(contentType, "Hierarchy Simple Text Page " + i, root);
list.Add(content);
list.AddRange(CreateChildrenOf(contentType, content, 4));
@@ -921,12 +918,12 @@ namespace Umbraco.Tests.Services
return list;
}
- private IEnumerable CreateChildrenOf(IContentType contentType, IContent content, int depth)
+ private IEnumerable CreateChildrenOf(IContentType contentType, IContent content, int depth)
{
var list = new List();
for (int i = 0; i < depth; i++)
{
- var c = MockedContent.CreateSimpleContent(contentType, "Hierarchy Simple Text Subpage " + i, content);
+ var c = MockedContent.CreateSimpleContent(contentType, "Hierarchy Simple Text Subpage " + i, content);
list.Add(c);
Console.WriteLine("Created: 'Hierarchy Simple Text Subpage {0}' - Depth: {1}", i, depth);