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()); } }
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; }
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; }
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()); }