Пример #1
0
 public void RenderSucceeds()
 {
     using (var context = CreateContext())
     {
         var view = new CmsView("example");
         var xml = view.Render(context, new CmsDocument("doc", new CmsPart(CmsTypes.Text, "Hello"))).Single();
         Assert.NotNull(xml);
         Assert.Equal("<div>Hello</div>", xml.ToString());
     }
 }
Пример #2
0
        public virtual HttpResponseMessage Post(CmsView view)
        {
            if (view == null)
                throw new ArgumentNullException("view");
            if (view.Id != Guid.Empty)
                throw new ArgumentOutOfRangeException("view", "Attempt to post a non-transient view");

            CmsContext.Views.Save(view);
            var response = Request.CreateResponse(HttpStatusCode.Created, view);
            string uri = Url.Link("GetCmsViewApi", new { id = view.Id });
            response.Headers.Location = new Uri(uri);
            return response;
        }
Пример #3
0
        public virtual HttpResponseMessage Put(Guid id, CmsView view)
        {
            if (id == Guid.Empty)
                throw new ArgumentOutOfRangeException("id", "invalid View Id");
            if (view == null)
                throw new ArgumentNullException("view");
            if (view.Id != id)
                throw new ArgumentOutOfRangeException("view", "view Id doesn't match id parameter");

            CmsContext.Views.Save(view);
            var response = Request.CreateResponse(HttpStatusCode.OK, view);
            string uri = Url.Link("GetCmsViewApi", new { id = view.Id });
            response.Headers.Location = new Uri(uri);
            return response;
        }
Пример #4
0
        public WebApiFixture()
        {
            var unity = new UnityContainer();
            unity.ConfigureCms()
                .UseMemoryStorage()
                .UseLuceneSearch(new RAMDirectory())
                .UseTextRenderer()
                .UseHtmlRenderer()
                .UseMarkdownRenderer()
                .UseSourceCodeRenderer();
            Cms.Configure(() => new UnityCmsContainer(unity.CreateChildContainer()));
            using (var context = Cms.CreateContext())
            {
                ExampleDocument = new CmsDocument("Example");
                context.Documents.Save(ExampleDocument);
                ExampleView = new CmsView("Example");
                context.Views.Save(ExampleView);
            }

            //CmsTesting.Initialize(() => new UnityCmsContainer(unity.CreateChildContainer()));
            _WebApp = WebApp.Start<Startup>(WebUrl.ToString());
        }