mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Fixing tests
--HG-- branch : dev
This commit is contained in:
@@ -28,6 +28,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>();
|
||||
|
||||
|
@@ -26,6 +26,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 +70,7 @@ namespace Orchard.Core.Tests.Common.Services {
|
||||
Assert.That(_routableService.IsSlugValid("a" + c + "b"), Is.False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void VeryLongStringTruncatedTo1000Chars() {
|
||||
@@ -140,18 +142,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 +159,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";
|
||||
});
|
||||
@@ -195,8 +191,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 +212,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 +221,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 +230,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"
|
||||
};
|
||||
|
@@ -28,7 +28,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>();
|
||||
}
|
||||
|
||||
@@ -98,7 +100,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);
|
||||
}
|
||||
|
@@ -26,12 +26,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>();
|
||||
}
|
||||
|
||||
@@ -86,7 +88,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));
|
||||
|
Reference in New Issue
Block a user