public static IUser Create(string role) { var simulation = new ContentItemBuilder("user") .Weld<SimulatedUser>() .Weld<SimulatedUserRoles>() .Build(); simulation.As<SimulatedUserRoles>().Roles = new[] {role}; return simulation.As<IUser>(); }
public static IUser Create(string role) { var simulationType = new ContentTypeDefinitionBuilder().Named("User").Build(); var simulation = new ContentItemBuilder(simulationType) .Weld<SimulatedUser>() .Weld<SimulatedUserRoles>() .Build(); simulation.As<SimulatedUserRoles>().Roles = new[] {role}; return simulation.As<IUser>(); }
public ISite GetSiteSettings() { var siteType = new ContentTypeDefinitionBuilder().Named("Site").Build(); var site = new ContentItemBuilder(siteType) .Weld <SafeModeSite>() .Build(); return(site.As <ISite>()); }
public void CorePartValuesAreExtracted() { var clock = new StubClock(); var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build()) .Weld <CommonPart>() .Weld <TitlePart>() .Weld <BodyPart>() .Weld <InfosetPart>() .Build(); hello.As <CommonPart>().Record = new CommonPartRecord(); hello.As <TitlePart>().Record = new TitlePartRecord(); hello.As <BodyPart>().Record = new BodyPartRecord(); hello.As <CommonPart>().PublishedUtc = clock.UtcNow; hello.As <TitlePart>().Title = "alpha"; // hello.As<RoutePart>().Slug = "beta"; hello.As <BodyPart>().Text = "gamma"; var query = new StubQuery(new[] { hello, }); var mockContentManager = new Mock <IContentManager>(); mockContentManager.Setup(x => x.GetItemMetadata(It.IsAny <IContent>())) .Returns(new ContentItemMetadata() { DisplayText = "foo" }); var builder = new ContainerBuilder(); //builder.RegisterModule(new ImplicitCollectionSupportModule()); builder.RegisterType <FeedController>(); builder.RegisterInstance(new RouteCollection()); builder.RegisterInstance(mockContentManager.Object).As <IContentManager>(); builder.RegisterType <RssFeedBuilder>().As <IFeedBuilderProvider>(); builder.RegisterType <CorePartsFeedItemBuilder>().As <IFeedItemBuilder>(); builder.RegisterInstance(query).As <IFeedQueryProvider>(); var container = builder.Build(); var controller = container.Resolve <FeedController>(); controller.ValueProvider = Values.From(new { }); var result = controller.Index("rss"); Assert.That(result, Is.Not.Null); Assert.That(result, Is.InstanceOf <RssResult>()); var doc = ((RssResult)result).Document; var item = doc.Elements("rss").Elements("channel").Elements("item").Single(); Assert.That(item.Element("title").Value, Is.EqualTo("foo")); Assert.That(item.Element("description").Value, Is.EqualTo("gamma")); }
public void CorePartValuesAreExtracted() { var clock = new StubClock(); var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build()) .Weld<CommonPart>() .Weld<TitlePart>() .Weld<BodyPart>() .Weld<InfosetPart>() .Build(); hello.As<CommonPart>().Record = new CommonPartRecord(); hello.As<TitlePart>().Record = new TitlePartRecord(); hello.As<BodyPart>().Record = new BodyPartRecord(); hello.As<CommonPart>().PublishedUtc = clock.UtcNow; hello.As<TitlePart>().Title = "alpha"; // hello.As<RoutePart>().Slug = "beta"; hello.As<BodyPart>().Text = "gamma"; var query = new StubQuery(new[] { hello, }); var mockContentManager = new Mock<IContentManager>(); mockContentManager.Setup(x => x.GetItemMetadata(It.IsAny<IContent>())) .Returns(new ContentItemMetadata() { DisplayText = "foo" }); var builder = new ContainerBuilder(); //builder.RegisterModule(new ImplicitCollectionSupportModule()); builder.RegisterType<FeedController>(); builder.RegisterInstance(new RouteCollection()); builder.RegisterInstance(mockContentManager.Object).As<IContentManager>(); builder.RegisterType<RssFeedBuilder>().As<IFeedBuilderProvider>(); builder.RegisterType<CorePartsFeedItemBuilder>().As<IFeedItemBuilder>(); builder.RegisterInstance(query).As<IFeedQueryProvider>(); var container = builder.Build(); var controller = container.Resolve<FeedController>(); controller.ValueProvider = Values.From(new { }); var result = controller.Index("rss"); Assert.That(result, Is.Not.Null); Assert.That(result, Is.InstanceOf<RssResult>()); var doc = ((RssResult)result).Document; var item = doc.Elements("rss").Elements("channel").Elements("item").Single(); Assert.That(item.Element("title").Value, Is.EqualTo("foo")); Assert.That(item.Element("description").Value, Is.EqualTo("gamma")); }
public ISite GetSiteSettings() { var site = new ContentItemBuilder("site") .Weld<SafeModeSite>() .Build(); return site.As<ISite>(); }