public void SearchDocumentsSucceeds()
 {
     using (var context = CreateContext())
     {
         var doc = new CmsDocument("Test", new CmsPart(CmsTypes.Text, "Hello, World"));
         context.Documents.Save(doc);
         var found = context.Search.SearchDocuments("World").SingleOrDefault();
         Assert.NotNull(found);
         Assert.Equal(doc.Id, found.Id);
         Assert.Equal(doc.Title, found.Title);
     }
 }
Exemplo n.º 2
0
 public void SearchByValue()
 {
     using (var context = CreateContext())
     {
         var doc = new CmsDocument("SearchByTitle", new CmsPart(CmsTypes.Text, "SearchByValue"));
         context.Documents.Save(doc);
         var found = context.Search.SearchDocuments(CmsDocumentField.Value, "SearchByValue").SingleOrDefault();
         Assert.NotNull(found);
         Assert.Equal(doc.Id, found.Id);
         Assert.Equal(doc.Title, found.Title);
     }
 }
Exemplo n.º 3
0
        public virtual HttpResponseMessage Post(CmsDocument document)
        {
            if (document == null)
                throw new ArgumentNullException("document");
            if (document.Id != Guid.Empty)
                throw new ArgumentOutOfRangeException("document", "Attempt to post a non-transient document");

            CmsContext.Documents.Save(document);
            var response = Request.CreateResponse(HttpStatusCode.Created, document);
            string uri = Url.Link("GetCmsDocumentApi", new { id = document.Id });
            response.Headers.Location = new Uri(uri);
            return response;
        }
Exemplo n.º 4
0
 public void SearchByTag()
 {
     using (var context = CreateContext())
     {
         var doc = new CmsDocument("SearchByTitle");
         doc.Tags.Add("SearchByTag");
         context.Documents.Save(doc);
         var found = context.Search.SearchDocuments(CmsDocumentField.Tag, "SearchByTag").SingleOrDefault();
         Assert.NotNull(found);
         Assert.Equal(doc.Id, found.Id);
         Assert.Equal(doc.Title, found.Title);
     }
 }
Exemplo n.º 5
0
        public virtual HttpResponseMessage Put(Guid id, CmsDocument document)
        {
            if (id == Guid.Empty)
                throw new ArgumentOutOfRangeException("id", "invalid Document Id");
            if (document == null)
                throw new ArgumentNullException("document");
            if (document.Id != id)
                throw new ArgumentOutOfRangeException("document", "document Id doesn't match id parameter");

            CmsContext.Documents.Save(document);
            var response = Request.CreateResponse(HttpStatusCode.OK, document);
            string uri = Url.Link("GetCmsDocumentApi", new { id = document.Id });
            response.Headers.Location = new Uri(uri);
            return response;
        }
Exemplo n.º 6
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());
        }