Created
December 6, 2014 11:06
-
-
Save 0liver/dbeeb597b626f9a15f36 to your computer and use it in GitHub Desktop.
ContentHelpers for Unit Testing in Orchard CMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Orchard.ContentManagement; | |
using Orchard.ContentManagement.FieldStorage.InfosetStorage; | |
using Orchard.ContentManagement.Records; | |
namespace Nwazet.Commerce.Tests.Helpers { | |
public class ContentHelpers { | |
public static ContentItem PreparePart<TPart, TRecord>(TPart part, string contentType, int id = -1) | |
where TPart : ContentPart<TRecord> | |
where TRecord : ContentPartRecord, new() { | |
part.Record = new TRecord(); | |
return PreparePart(part, contentType, id); | |
} | |
public static ContentItem PreparePart<TPart>(TPart part, string contentType, int id = -1) | |
where TPart : ContentPart { | |
var contentItem = part.ContentItem = new ContentItem { | |
VersionRecord = new ContentItemVersionRecord { | |
ContentItemRecord = new ContentItemRecord() | |
}, | |
ContentType = contentType | |
}; | |
contentItem.Record.Id = id; | |
contentItem.Weld(part); | |
contentItem.Weld(new InfosetPart()); | |
return contentItem; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment