コード例 #1
0
        public void IdShouldDefaultToZero()
        {
            var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());
            var model   = builder.Build();

            Assert.That(model.Id, Is.EqualTo(0));
        }
コード例 #2
0
        public void BuilderShouldReturnWorkingModelWithTypeAndId()
        {
            var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());
            var model   = builder.Build();

            Assert.That(model.ContentType, Is.EqualTo("foo"));
        }
コード例 #3
0
 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>();
 }
コード例 #4
0
ファイル: SetupMode.cs プロジェクト: omidam81/teeyoot.com
            public ISite GetSiteSettings()
            {
                var siteType = new ContentTypeDefinitionBuilder().Named("Site").Build();
                var site     = new ContentItemBuilder(siteType)
                               .Weld <SafeModeSite>()
                               .Build();

                return(site.As <ISite>());
            }
コード例 #5
0
 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>();
 }
コード例 #6
0
        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"));
        }
コード例 #7
0
 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>();
 }
コード例 #8
0
        public void WeldShouldAddPartToModel() {
            var builder = new ContentItemBuilder("foo");
            builder.Weld<Alpha>();
            var model = builder.Build();

            Assert.That(model.Is<Alpha>(), Is.True);
            Assert.That(model.As<Alpha>(), Is.Not.Null);
            Assert.That(model.Is<Beta>(), Is.False);
            Assert.That(model.As<Beta>(), Is.Null);
        }
コード例 #9
0
ファイル: ModelBuilderTests.cs プロジェクト: anycall/Orchard
        public void WeldShouldAddPartToModel() {
            var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());
            builder.Weld<AlphaPart>();
            var model = builder.Build();

            Assert.That(model.Is<AlphaPart>(), Is.True);
            Assert.That(model.As<AlphaPart>(), Is.Not.Null);
            Assert.That(model.Is<BetaPart>(), Is.False);
            Assert.That(model.As<BetaPart>(), Is.Null);
        }
コード例 #10
0
        public void WeldShouldAddPartToModel()
        {
            var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());

            builder.Weld <AlphaPart>();
            var model = builder.Build();

            Assert.That(model.Is <AlphaPart>(), Is.True);
            Assert.That(model.As <AlphaPart>(), Is.Not.Null);
            Assert.That(model.Is <BetaPart>(), Is.False);
            Assert.That(model.As <BetaPart>(), Is.Null);
        }
コード例 #11
0
        public void PartShouldBeAddedBasedOnSimplePredicate()
        {
            var modelDriver = new TestModelHandler();

            var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("testing").Build());

            ((IContentHandler)modelDriver).Activating(new ActivatingContentContext {
                Builder = builder, ContentType = "testing"
            });
            var model = builder.Build();

            Assert.That(model.Is <TestModelPart>(), Is.True);
            Assert.That(model.As <TestModelPart>(), Is.Not.Null);
        }
コード例 #12
0
        public void GetAllPresidents_Good_Found()
        {
            //Arrange
            ContentItemBuilder builder = new ContentItemBuilder();
            var controller             = builder.SetupController();

            //Act
            var result = controller.GetAllPresidents();

            //Assert
            JObject jObject = JObject.Parse(result.Content.ReadAsStringAsync().Result);
            var     success = jObject["Success"].ToString();

            Assert.IsTrue(result.StatusCode == HttpStatusCode.OK, "Expected OK status");
            Assert.IsTrue(success == "True", "Expected Success True");
        }
コード例 #13
0
 public void IdShouldDefaultToZero() {
     var builder = new ContentItemBuilder("foo");
     var model = builder.Build();
     Assert.That(model.Id, Is.EqualTo(0));
 }
コード例 #14
0
 public void IdShouldDefaultToZero()
 {
     var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());
     var model = builder.Build();
     Assert.That(model.Id, Is.EqualTo(0));
 }
コード例 #15
0
 public void BuilderShouldReturnWorkingModelWithTypeAndId()
 {
     var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());
     var model = builder.Build();
     Assert.That(model.ContentType, Is.EqualTo("foo"));
 }
コード例 #16
0
        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"));

        }
コード例 #17
0
ファイル: SetupMode.cs プロジェクト: mofashi2011/orchardcms
            public ISite GetSiteSettings()
            {
                var site = new ContentItemBuilder("site")
                    .Weld<SafeModeSite>()
                    .Build();

                return site.As<ISite>();
            }