public void IdShouldDefaultToZero()
        {
            var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());
            var model   = builder.Build();

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

            Assert.That(model.ContentType, Is.EqualTo("foo"));
        }
Example #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>();
 }
Example #4
0
            public ISite GetSiteSettings()
            {
                var siteType = new ContentTypeDefinitionBuilder().Named("Site").Build();
                var site     = new ContentItemBuilder(siteType)
                               .Weld <SafeModeSite>()
                               .Build();

                return(site.As <ISite>());
            }
Example #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>();
 }
Example #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"));
        }
 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 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);
        }
Example #9
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);
        }
        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);
        }
        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);
        }
        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");
        }
 public void IdShouldDefaultToZero() {
     var builder = new ContentItemBuilder("foo");
     var model = builder.Build();
     Assert.That(model.Id, Is.EqualTo(0));
 }
 public void IdShouldDefaultToZero()
 {
     var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());
     var model = builder.Build();
     Assert.That(model.Id, Is.EqualTo(0));
 }
 public void BuilderShouldReturnWorkingModelWithTypeAndId()
 {
     var builder = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("foo").Build());
     var model = builder.Build();
     Assert.That(model.ContentType, Is.EqualTo("foo"));
 }
Example #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"));

        }
Example #17
0
            public ISite GetSiteSettings()
            {
                var site = new ContentItemBuilder("site")
                    .Weld<SafeModeSite>()
                    .Build();

                return site.As<ISite>();
            }