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:
loudej
2009-11-29 06:08:46 +00:00
parent 4b14786efd
commit 940e2bce07
21 changed files with 107 additions and 13 deletions

View File

@@ -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>>();

View File

@@ -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>();

View File

@@ -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>();

View File

@@ -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));

View File

@@ -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));