public void create_media_document_with_node_centric_style_builds_node_centric_nodes() { var document = new XmlMediaDocument(new XmlMediaOptions{ NodeStyle = XmlNodeStyle.NodeCentric }); document.Root.ShouldBeOfType<XmlNodeCentricMediaNode>(); }
public void should_list_the_mime_type_from_the_xml_options() { var options = new XmlMediaOptions { NodeStyle = XmlNodeStyle.AttributeCentric, Root = "Something", LinkWriter = new StubLinkWriter(), Mimetype = "vnd.dovetail.resource" }; var document = new XmlMediaDocument(options); document.Mimetypes.Single().ShouldEqual(options.Mimetype); }
public void root_element_with_a_namespace() { var options = new XmlMediaOptions { NodeStyle = XmlNodeStyle.AttributeCentric, Root = "Something", Namespace = "http://mynamespace.xsd" }; var document = new XmlMediaDocument(options); var root = document.Root.ShouldBeOfType<XmlMediaNode>().Element; root.OuterXml.ShouldEqual("<Something xmlns=\"http://mynamespace.xsd\" />"); }
public void should_list_the_mime_type_from_the_xml_options_if_there_are_multiples() { var options = new XmlMediaOptions { NodeStyle = XmlNodeStyle.AttributeCentric, Root = "Something", LinkWriter = new StubLinkWriter(), Mimetype = "vnd.dovetail.resource,text/xml,application/xml" }; var document = new XmlMediaDocument(options); document.Mimetypes.ShouldHaveTheSameElementsAs(options.Mimetype.ToDelimitedArray(',')); }
public void write_should_use_the_mime_type_from_the_options() { var writer = MockRepository.GenerateMock<IOutputWriter>(); var options = new XmlMediaOptions { NodeStyle = XmlNodeStyle.AttributeCentric, Root = "Something", LinkWriter = new StubLinkWriter() }; var document = new XmlMediaDocument(options); document.Write(writer); writer.AssertWasCalled(x => x.Write(options.Mimetype, document.Root.As<XmlMediaNode>().Element.OuterXml)); }
public void the_root_has__the_link_writer_from_the_options() { var options = new XmlMediaOptions{ NodeStyle = XmlNodeStyle.AttributeCentric, Root = "Something", LinkWriter = new StubLinkWriter() }; var document = new XmlMediaDocument(options); var root = document.Root.ShouldBeOfType<XmlMediaNode>(); root.LinkWriter.ShouldBeTheSameAs(options.LinkWriter); }
public void the_root_element_should_match_the_option_root() { var options = new XmlMediaOptions{ NodeStyle = XmlNodeStyle.AttributeCentric, Root = "Something", Namespace = "http://mynamespace.xsd" }; var document = new XmlMediaDocument(options); var root = document.Root.ShouldBeOfType<XmlMediaNode>().Element; root.Name.ShouldEqual(options.Root); }
public void SetUp() { var projection = new Projection<Address>(DisplayFormatting.RawValues); projection.Value(x => x.Address1); projection.Value(x => x.Address2); projection.Value(x => x.City); projection.Value(x => x.StateOrProvince).Name("State"); theXmlMediaOptions = new XmlMediaOptions(){ Root = "Address" }; theDocument = new XmlMediaDocument(theXmlMediaOptions); var urls = new StubUrlRegistry(); var linkSource = new LinksSource<Address>(); linkSource.ToSubject().Rel("self"); linkSource.To(a => new AddressAction("change")).Rel("change"); linkSource.To(a => new AddressAction("delete")).Rel("delete"); var media = new MediaWriter<Address>(theDocument, linkSource, urls, projection, null); theAddress = new Address(){ Address1 = "22 Cherry Lane", Address2 = "Apt A", City = "Austin", StateOrProvince = "Texas" }; theOutput = new InMemoryOutputWriter(); media.Write(theAddress, theOutput); Debug.WriteLine(theOutput); }