Content manager assigning values to definition properties

DefaultContentManager now takes a dependency on IContentDefinitionManager
ContentItem.TypeDefinition assigned to ContentTypeDefinition instance when creating
ContentPart.TypePartDefinition assigned to ContentTypeDefinition.Part instance as added
Empty definition instances are created as code-only types and parts are created

--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-06-08 12:05:29 -07:00
parent 1b39eb3bc0
commit 57e830f19e
19 changed files with 137 additions and 41 deletions

View File

@@ -6,6 +6,7 @@ using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Common;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
@@ -25,6 +26,7 @@ namespace Orchard.Core.Tests.Common.Providers {
private Mock<IAuthenticationService> _authn;
private Mock<IAuthorizationService> _authz;
private Mock<IMembershipService> _membership;
private Mock<IContentDefinitionManager> _contentDefinitionManager;
public override void Register(ContainerBuilder builder) {
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
@@ -35,11 +37,12 @@ namespace Orchard.Core.Tests.Common.Providers {
_authn = new Mock<IAuthenticationService>();
_authz = new Mock<IAuthorizationService>();
_membership = new Mock<IMembershipService>();
_contentDefinitionManager = new Mock<IContentDefinitionManager>();
builder.RegisterInstance(_authn.Object);
builder.RegisterInstance(_authz.Object);
builder.RegisterInstance(_membership.Object);
builder.RegisterInstance(_contentDefinitionManager.Object);
}
protected override IEnumerable<Type> DatabaseTypes {

View File

@@ -2,10 +2,12 @@
using System.Collections.Generic;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Services;
@@ -27,6 +29,7 @@ namespace Orchard.Core.Tests.Common.Services {
public override void Register(ContainerBuilder builder) {
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterType<ThingHandler>().As<IContentHandler>();
builder.RegisterType<StuffHandler>().As<IContentHandler>();

View File

@@ -9,6 +9,8 @@ using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.Core.Common.Models;
using Orchard.Core.Feeds;
using Orchard.Core.Feeds.Controllers;
@@ -145,7 +147,7 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
[Test]
public void CorePartValuesAreExtracted() {
var clock = new StubClock();
var hello = new ContentItemBuilder("hello")
var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build())
.Weld<CommonAspect>()
.Weld<RoutableAspect>()
.Weld<BodyAspect>()

View File

@@ -4,6 +4,7 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;
@@ -29,6 +30,7 @@ namespace Orchard.Core.Tests.Scheduling {
builder.RegisterInstance(new Mock<IOrchardServices>().Object);
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterType<ScheduledTaskExecutor>().As<IBackgroundTask>().Named("ScheduledTaskExecutor", typeof(IBackgroundTask));
builder.RegisterInstance(_handler).As<IScheduledTaskHandler>();

View File

@@ -5,6 +5,7 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;
@@ -33,6 +34,7 @@ namespace Orchard.Core.Tests.Scheduling {
builder.RegisterInstance(_mockServices.Object);
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterType<ScheduledTaskManager>().As<IScheduledTaskManager>();
}