mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding ContentType class and GetContentTypes methods to IContentManager and IContentProvider
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4042626
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
using Autofac.Builder;
|
||||
using Autofac.Modules;
|
||||
@@ -149,6 +150,15 @@ namespace Orchard.Tests.Models {
|
||||
Assert.That(modelRecord.ContentType.Name, Is.EqualTo("beta"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetContentTypesShouldReturnAllTypes() {
|
||||
var types = _manager.GetContentTypes();
|
||||
Assert.That(types.Count(), Is.EqualTo(3));
|
||||
Assert.That(types, Has.Some.With.Property("Name").EqualTo("alpha"));
|
||||
Assert.That(types, Has.Some.With.Property("Name").EqualTo("beta"));
|
||||
Assert.That(types, Has.Some.With.Property("Name").EqualTo("gamma"));
|
||||
}
|
||||
|
||||
private ContentItemRecord CreateModelRecord(string contentType) {
|
||||
var contentItemRepository = _container.Resolve<IRepository<ContentItemRecord>>();
|
||||
var contentTypeRepository = _container.Resolve<IRepository<ContentTypeRecord>>();
|
||||
|
@@ -1,7 +1,11 @@
|
||||
using Orchard.Models.Driver;
|
||||
using Orchard.Models;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Tests.Models.Stubs {
|
||||
public class AlphaProvider : ContentProvider {
|
||||
public override System.Collections.Generic.IEnumerable<Orchard.Models.ContentType> GetContentTypes() {
|
||||
return new[] {new ContentType {Name = "alpha"}};
|
||||
}
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
if (context.ContentType == "alpha") {
|
||||
context.Builder.Weld<Alpha>();
|
||||
|
@@ -2,10 +2,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Orchard.Models;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Tests.Models.Stubs {
|
||||
public class BetaProvider : ContentProvider {
|
||||
public override System.Collections.Generic.IEnumerable<Orchard.Models.ContentType> GetContentTypes() {
|
||||
return new[] { new ContentType { Name = "beta" } };
|
||||
}
|
||||
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
if (context.ContentType == "beta") {
|
||||
context.Builder.Weld<Beta>();
|
||||
|
@@ -13,6 +13,10 @@ namespace Orchard.Tests.Models.Stubs {
|
||||
|
||||
|
||||
public class DeltaProvider : ContentProvider {
|
||||
public override System.Collections.Generic.IEnumerable<Orchard.Models.ContentType> GetContentTypes() {
|
||||
return new[] { new ContentType { Name = "delta" } };
|
||||
}
|
||||
|
||||
public DeltaProvider(IRepository<DeltaRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<Delta>(x => x == "delta"));
|
||||
Filters.Add(new StorageFilter<DeltaRecord>(repository));
|
||||
|
@@ -12,6 +12,10 @@ namespace Orchard.Tests.Models.Stubs {
|
||||
|
||||
|
||||
public class GammaProvider : ContentProvider {
|
||||
public override System.Collections.Generic.IEnumerable<Orchard.Models.ContentType> GetContentTypes() {
|
||||
return new[] { new ContentType { Name = "gamma" } };
|
||||
}
|
||||
|
||||
public GammaProvider(IRepository<GammaRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<Gamma>(x => x == "gamma"));
|
||||
Filters.Add(new StorageFilter<GammaRecord>(repository));
|
||||
|
Reference in New Issue
Block a user