Exemplo n.º 1
0
        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>();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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\" />");
        }
Exemplo n.º 5
0
        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(','));
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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, "text/xml");

            writer.AssertWasCalled(x => x.Write(options.Mimetype, document.Root.As <XmlMediaNode>().Element.OuterXml));
        }
Exemplo n.º 8
0
        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");

            theOutput = new InMemoryOutputWriter();

            var media = new MediaWriter <Address>(theDocument, linkSource, urls, projection, null, theOutput);


            theAddress = new Address()
            {
                Address1        = "22 Cherry Lane",
                Address2        = "Apt A",
                City            = "Austin",
                StateOrProvince = "Texas"
            };



            media.Write("text/plain", theAddress);

            Debug.WriteLine(theOutput);
        }