--HG--
branch : net40
This commit is contained in:
Renaud Paquay
2010-05-21 21:53:00 -07:00
271 changed files with 11089 additions and 7795 deletions

View File

@@ -6,6 +6,7 @@ using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.Core.Common;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
@@ -28,6 +29,7 @@ namespace Orchard.Core.Tests.Common.Providers {
public override void Register(ContainerBuilder builder) {
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<TestHandler>().As<IContentHandler>();
builder.RegisterType<CommonAspectHandler>().As<IContentHandler>();
@@ -45,6 +47,8 @@ namespace Orchard.Core.Tests.Common.Providers {
get {
return new[] {
typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(CommonRecord),

View File

@@ -6,6 +6,7 @@ using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Services;
@@ -26,6 +27,8 @@ namespace Orchard.Core.Tests.Common.Services {
public override void Register(ContainerBuilder builder) {
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<ThingHandler>().As<IContentHandler>();
builder.RegisterType<StuffHandler>().As<IContentHandler>();
builder.RegisterType<RoutableService>().As<IRoutableService>();
@@ -68,7 +71,7 @@ namespace Orchard.Core.Tests.Common.Services {
Assert.That(_routableService.IsSlugValid("a" + c + "b"), Is.False);
}
}
[Test]
public void VeryLongStringTruncatedTo1000Chars() {
@@ -140,18 +143,15 @@ namespace Orchard.Core.Tests.Common.Services {
}
[Test]
public void GeneratedSlugsShouldBeUniqueAmongContentType()
{
public void GeneratedSlugsShouldBeUniqueAmongContentType() {
var contentManager = _container.Resolve<IContentManager>();
var thing1 = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t =>
{
var thing1 = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<RoutableAspect>().Record = new RoutableRecord();
t.Title = "This Is Some Interesting Title";
});
var thing2 = contentManager.Create<Thing>(ThingDriver.ContentType.Name , t =>
{
var thing2 = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<RoutableAspect>().Record = new RoutableRecord();
t.Title = "This Is Some Interesting Title";
});
@@ -160,18 +160,15 @@ namespace Orchard.Core.Tests.Common.Services {
}
[Test]
public void SlugsCanBeDuplicatedAccrossContentTypes()
{
public void SlugsCanBeDuplicatedAccrossContentTypes() {
var contentManager = _container.Resolve<IContentManager>();
var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t =>
{
var thing = contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
t.As<RoutableAspect>().Record = new RoutableRecord();
t.Title = "This Is Some Interesting Title";
});
var stuff = contentManager.Create<Stuff>(StuffDriver.ContentType.Name, s =>
{
var stuff = contentManager.Create<Stuff>(StuffDriver.ContentType.Name, s => {
s.As<RoutableAspect>().Record = new RoutableRecord();
s.Title = "This Is Some Interesting Title";
});
@@ -184,9 +181,11 @@ namespace Orchard.Core.Tests.Common.Services {
get {
return new[] {
typeof(RoutableRecord),
typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(ContentTypeRecord),
typeof(CommonRecord),
typeof(CommonVersionRecord),
};
@@ -195,8 +194,7 @@ namespace Orchard.Core.Tests.Common.Services {
[UsedImplicitly]
public class ThingHandler : ContentHandler {
public ThingHandler()
{
public ThingHandler() {
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(ThingDriver.ContentType.Name));
@@ -217,7 +215,7 @@ namespace Orchard.Core.Tests.Common.Services {
set { this.As<RoutableAspect>().Slug = value; }
}
}
public class ThingDriver : ContentItemDriver<Thing> {
public readonly static ContentType ContentType = new ContentType {
Name = "thing",
@@ -226,10 +224,8 @@ namespace Orchard.Core.Tests.Common.Services {
}
[UsedImplicitly]
public class StuffHandler : ContentHandler
{
public StuffHandler()
{
public class StuffHandler : ContentHandler {
public StuffHandler() {
Filters.Add(new ActivatingFilter<Stuff>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(StuffDriver.ContentType.Name));
@@ -237,27 +233,22 @@ namespace Orchard.Core.Tests.Common.Services {
}
}
public class Stuff : ContentPart
{
public class Stuff : ContentPart {
public int Id { get { return ContentItem.Id; } }
public string Title
{
public string Title {
get { return this.As<RoutableAspect>().Title; }
set { this.As<RoutableAspect>().Title = value; }
}
public string Slug
{
public string Slug {
get { return this.As<RoutableAspect>().Slug; }
set { this.As<RoutableAspect>().Slug = value; }
}
}
public class StuffDriver : ContentItemDriver<Stuff>
{
public readonly static ContentType ContentType = new ContentType
{
public class StuffDriver : ContentItemDriver<Stuff> {
public readonly static ContentType ContentType = new ContentType {
Name = "stuff",
DisplayName = "Stuff"
};

View File

@@ -27,7 +27,8 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
var controller = new FeedController(
Enumerable.Empty<IFeedQueryProvider>(),
Enumerable.Empty<IFeedBuilderProvider>(),
Enumerable.Empty<IFeedItemBuilder>()) {
new StubItemBuilder()
) {
ValueProvider = Values.From(new { })
};
@@ -54,7 +55,8 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
var controller = new FeedController(
new[] { queryProvider.Object },
new[] { formatProvider.Object },
Enumerable.Empty<IFeedItemBuilder>()) {
new StubItemBuilder()
) {
ValueProvider = Values.From(new { })
};
@@ -86,15 +88,20 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
}
}
class StubItemBuilder : IFeedItemBuilder {
public void Populate(FeedContext context) {
}
}
[Test]
public void RssFeedShouldBeStructuredAppropriately() {
var query = new StubQuery(Enumerable.Empty<ContentItem>());
var builder = new ContainerBuilder();
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType<FeedController>();
builder.RegisterType<RssFeedBuilder>().As<IFeedBuilderProvider>();
builder.RegisterInstance(query).As<IFeedQueryProvider>();
builder.RegisterInstance(new StubItemBuilder()).As<IFeedItemBuilder>();
var container = builder.Build();
var controller = container.Resolve<FeedController>();
@@ -117,9 +124,9 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
});
var builder = new ContainerBuilder();
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType<FeedController>();
builder.RegisterType<RssFeedBuilder>().As<IFeedBuilderProvider>();
builder.RegisterInstance(new StubItemBuilder()).As<IFeedItemBuilder>();
builder.RegisterInstance(query).As<IFeedQueryProvider>();
var container = builder.Build();

View File

@@ -4,6 +4,7 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;
@@ -28,7 +29,9 @@ namespace Orchard.Core.Tests.Scheduling {
_handler = new StubTaskHandler();
builder.RegisterInstance(new Mock<IOrchardServices>().Object);
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<ScheduledTaskExecutor>().As<IBackgroundTask>().Named("ScheduledTaskExecutor", typeof (IBackgroundTask));
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<ScheduledTaskExecutor>().As<IBackgroundTask>().Named("ScheduledTaskExecutor", typeof(IBackgroundTask));
builder.RegisterInstance(_handler).As<IScheduledTaskHandler>();
}
@@ -36,6 +39,8 @@ namespace Orchard.Core.Tests.Scheduling {
get {
return new[] {
typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(ScheduledTaskRecord),
@@ -98,7 +103,7 @@ namespace Orchard.Core.Tests.Scheduling {
Assert.That(_handler.TaskContext, Is.Null);
_executor.Sweep();
Assert.That(_handler.TaskContext, Is.Not.Null);
Assert.That(_handler.TaskContext.Task.TaskType, Is.EqualTo("Ignore"));
Assert.That(_handler.TaskContext.Task.ContentItem, Is.Null);
}

View File

@@ -5,6 +5,7 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;
@@ -26,12 +27,14 @@ namespace Orchard.Core.Tests.Scheduling {
_repository = _container.Resolve<IRepository<ScheduledTaskRecord>>();
_scheduledTaskManager = _container.Resolve<IScheduledTaskManager>();
_contentManager = _container.Resolve<IContentManager>();
_mockServices.SetupGet(x=>x.ContentManager).Returns(_contentManager);
_mockServices.SetupGet(x => x.ContentManager).Returns(_contentManager);
}
public override void Register(ContainerBuilder builder) {
public override void Register(ContainerBuilder builder) {
builder.RegisterInstance(_mockServices.Object);
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<ScheduledTaskManager>().As<IScheduledTaskManager>();
}
@@ -39,6 +42,8 @@ namespace Orchard.Core.Tests.Scheduling {
get {
return new[] {
typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(ScheduledTaskRecord),
@@ -86,7 +91,7 @@ namespace Orchard.Core.Tests.Scheduling {
public void TasksForAllVersionsOfContenItemShouldBeReturned() {
var hello1 = _contentManager.New("hello");
_contentManager.Create(hello1);
var hello2 = _contentManager.GetDraftRequired(hello1.Id);
Assert.That(hello1.Version, Is.EqualTo(1));