public void Ctor_CategoriesDocument_Referenced() { var document = new ReferencedCategoriesDocument(); var formatter = new AtomPub10CategoriesDocumentFormatter(document); Assert.Same(document, formatter.Document); Assert.Equal("http://www.w3.org/2007/app", formatter.Version); }
public void Create_LinkToCategoriesDocument_ReturnsExpected(Uri linkToCategoriesDocument) { ReferencedCategoriesDocument document = CategoriesDocument.Create(linkToCategoriesDocument); Assert.Empty(document.AttributeExtensions); Assert.Null(document.BaseUri); Assert.Empty(document.ElementExtensions); Assert.Null(document.Language); Assert.Equal(linkToCategoriesDocument, document.Link); }
public void Ctor_Uri(Uri link) { var document = new ReferencedCategoriesDocument(link); Assert.Empty(document.AttributeExtensions); Assert.Null(document.BaseUri); Assert.Empty(document.ElementExtensions); Assert.Null(document.Language); Assert.Equal(link, document.Link); }
public void CreateReferencedCategoriesDocument_Invoke_ReturnsExpected() { var formatter = new Formatter(); ReferencedCategoriesDocument document = formatter.CreateReferencedCategoriesDocumentEntryPoint(); Assert.Empty(document.AttributeExtensions); Assert.Null(document.BaseUri); Assert.Empty(document.ElementExtensions); Assert.Null(document.Language); Assert.Null(document.Link); }
public void CreateReferencedCategories_Invoke_ReturnsExpected() { var collection = new ResourceCollectionInfo(); ReferencedCategoriesDocument document = Formatter.CreateReferencedCategoriesEntryPoint(collection); Assert.Empty(document.AttributeExtensions); Assert.Null(document.BaseUri); Assert.Empty(document.ElementExtensions); Assert.Null(document.Language); Assert.Null(document.Link); }
public void CreateReferencedCategoriesDocument_Invoke_ReturnsExpected() { var workspace = new ResourceCollectionInfoSubclass(); ReferencedCategoriesDocument document = workspace.CreateReferencedCategoriesDocumentEntryPoint(); Assert.Empty(document.AttributeExtensions); Assert.Null(document.BaseUri); Assert.Empty(document.ElementExtensions); Assert.Null(document.Language); Assert.Null(document.Link); }
public void Categories_SetNonNullItem_GetReturnsExpected() { Collection <CategoriesDocument> collection = new ResourceCollectionInfo().Categories; collection.Add(new InlineCategoriesDocument()); var newValue = new ReferencedCategoriesDocument(); collection[0] = newValue; Assert.Same(newValue, collection[0]); }
private ResourceCollectionInfo GetPostsResourceCollectionInfo(UrlHelper url) { ResourceCollectionInfo posts = new ResourceCollectionInfo("Blog", new Uri(url.Link("DefaultApi", new { controller = "posts" }))); posts.Accepts.Add("application/atom+xml;type=entry"); // For WLW to work we need to include format in the categories URI. // Hoping to provide a better solution than this. var categoriesUri = new Uri(url.Link("DefaultApi", new { controller = "tags", format = "atomcat" })); ReferencedCategoriesDocument categories = new ReferencedCategoriesDocument(categoriesUri); posts.Categories.Add(categories); return(posts); }
public HttpResponseMessage Get() { var doc = new ServiceDocument(); var ws = new Workspace { Title = new TextSyndicationContent("My Site"), BaseUri = new Uri(Request.RequestUri.GetLeftPart(UriPartial.Authority)) }; var posts = new ResourceCollectionInfo("Blog", new Uri(Url.Link("DefaultApi", new { controller = "posts" }))); posts.Accepts.Add("application/atom+xml;type=entry"); // For WLW to work we need to include format in the categories URI. // Hoping to provide a better solution than this. var categoriesUri = new Uri(Url.Link("DefaultApi", new { controller = "tags", format = "atomcat" })); var categories = new ReferencedCategoriesDocument(categoriesUri); posts.Categories.Add(categories); ws.Collections.Add(posts); doc.Workspaces.Add(ws); var response = new HttpResponseMessage(HttpStatusCode.OK); var formatter = new AtomPub10ServiceDocumentFormatter(doc); var stream = new MemoryStream(); using (var writer = XmlWriter.Create(stream)) { formatter.WriteTo(writer); } stream.Position = 0; var content = new StreamContent(stream); response.Content = content; response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/atomsvc+xml"); return(response); }
public void CreateReferencedCategoriesDocument_NonGeneric_Success() { var formatter = new Formatter(); ReferencedCategoriesDocument document = Assert.IsType <ReferencedCategoriesDocument>(formatter.CreateReferencedCategoriesDocumentEntryPoint()); Assert.Empty(document.AttributeExtensions); Assert.Null(document.BaseUri); Assert.Empty(document.ElementExtensions); Assert.Null(document.Language); Assert.Null(document.Link); var typedFormatter = new Formatter(typeof(InlineCategoriesDocumentSubclass), typeof(ReferencedCategoriesDocumentSubclass)); document = Assert.IsType <ReferencedCategoriesDocumentSubclass>(typedFormatter.CreateReferencedCategoriesDocumentEntryPoint()); Assert.Empty(document.AttributeExtensions); Assert.Null(document.BaseUri); Assert.Empty(document.ElementExtensions); Assert.Null(document.Language); Assert.Null(document.Link); }
public static IEnumerable <object[]> WriteTo_TestData() { // Empty InlineCategoriesDocument. yield return(new object[] { new InlineCategoriesDocument(), @"<app:categories xmlns:a10=""http://www.w3.org/2005/Atom"" xmlns:app=""http://www.w3.org/2007/app"" />" }); // Full InlineCategoriesDocument var fullSyndicationCategory = new SyndicationCategory("category_name", "category_scheme", "category_label"); fullSyndicationCategory.AttributeExtensions.Add(new XmlQualifiedName("category_name1"), null); fullSyndicationCategory.AttributeExtensions.Add(new XmlQualifiedName("category_name2", "category_namespace"), ""); fullSyndicationCategory.AttributeExtensions.Add(new XmlQualifiedName("category_name3", "category_namespace"), "category_value"); fullSyndicationCategory.AttributeExtensions.Add(new XmlQualifiedName("category_name4", "xmlns"), ""); fullSyndicationCategory.ElementExtensions.Add(new ExtensionObject { Value = 10 }); var fullInlineCategoriesDocument = new InlineCategoriesDocument(new SyndicationCategory[] { new SyndicationCategory(), fullSyndicationCategory }) { BaseUri = new Uri("http://inlinecategories_url.com"), Language = "inlinecategories_Language", IsFixed = true, Scheme = "inlinecategories_scheme" }; fullInlineCategoriesDocument.AttributeExtensions.Add(new XmlQualifiedName("inlinecategories_name1"), null); fullInlineCategoriesDocument.AttributeExtensions.Add(new XmlQualifiedName("inlinecategories_name2", "inlinecategories_namespace"), ""); fullInlineCategoriesDocument.AttributeExtensions.Add(new XmlQualifiedName("inlinecategories_name3", "inlinecategories_namespace"), "inlinecategories_value"); fullInlineCategoriesDocument.AttributeExtensions.Add(new XmlQualifiedName("inlinecategories_name4", "xmlns"), ""); fullInlineCategoriesDocument.ElementExtensions.Add(new ExtensionObject { Value = 10 }); yield return(new object[] { fullInlineCategoriesDocument, @"<app:categories xmlns:a10=""http://www.w3.org/2005/Atom"" xml:base=""http://inlinecategories_url.com/"" xml:lang=""inlinecategories_Language"" scheme=""inlinecategories_scheme"" fixed=""yes"" inlinecategories_name1="""" d1p1:inlinecategories_name2="""" d1p1:inlinecategories_name3=""inlinecategories_value"" d1p2:inlinecategories_name4="""" xmlns:d1p2=""xmlns"" xmlns:d1p1=""inlinecategories_namespace"" xmlns:app=""http://www.w3.org/2007/app""> <a10:category term="""" /> <a10:category category_name1="""" d2p1:category_name2="""" d2p1:category_name3=""category_value"" d1p2:category_name4="""" term=""category_name"" label=""category_label"" scheme=""category_scheme"" xmlns:d2p1=""category_namespace""> <AtomPub10CategoriesDocumentFormatterTests.ExtensionObject xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests""> <Value>10</Value> </AtomPub10CategoriesDocumentFormatterTests.ExtensionObject> </a10:category> <AtomPub10CategoriesDocumentFormatterTests.ExtensionObject xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests""> <Value>10</Value> </AtomPub10CategoriesDocumentFormatterTests.ExtensionObject> </app:categories>" }); // Empty ReferencedCategoriesDocument. yield return(new object[] { new ReferencedCategoriesDocument(), @"<app:categories xmlns:a10=""http://www.w3.org/2005/Atom"" xmlns:app=""http://www.w3.org/2007/app"" />" }); // Full ReferencedCategoriesDocument. var fullReferenceCategoriesDocument = new ReferencedCategoriesDocument(new Uri("http://referencecategories_link.com")) { BaseUri = new Uri("http://referencecategories_url.com"), Language = "referencecategories_language" }; fullReferenceCategoriesDocument.AttributeExtensions.Add(new XmlQualifiedName("referencecategories_name1"), null); fullReferenceCategoriesDocument.AttributeExtensions.Add(new XmlQualifiedName("referencecategories_name2", "referencecategories_namespace"), ""); fullReferenceCategoriesDocument.AttributeExtensions.Add(new XmlQualifiedName("referencecategories_name3", "referencecategories_namespace"), "referencecategories_value"); fullReferenceCategoriesDocument.AttributeExtensions.Add(new XmlQualifiedName("referencecategories_name4", "xmlns"), ""); fullReferenceCategoriesDocument.ElementExtensions.Add(new ExtensionObject { Value = 10 }); yield return(new object[] { fullReferenceCategoriesDocument, @"<app:categories xmlns:a10=""http://www.w3.org/2005/Atom"" xml:base=""http://referencecategories_url.com/"" xml:lang=""referencecategories_language"" href=""http://referencecategories_link.com/"" referencecategories_name1="""" d1p1:referencecategories_name2="""" d1p1:referencecategories_name3=""referencecategories_value"" d1p2:referencecategories_name4="""" xmlns:d1p2=""xmlns"" xmlns:d1p1=""referencecategories_namespace"" xmlns:app=""http://www.w3.org/2007/app""> <AtomPub10CategoriesDocumentFormatterTests.ExtensionObject xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests""> <Value>10</Value> </AtomPub10CategoriesDocumentFormatterTests.ExtensionObject> </app:categories>" }); }