예제 #1
0
        public void ToXml_ValidCollection_ReturnsXmlString()
        {
            ICollection <string> catalog = Helper.GeStringArray();

            string xml = XSerializer.ToXml(catalog);

            Assert.IsTrue(xml.Length > 0);
        }
예제 #2
0
        public void ToXml_ValidStruct_ReturnsXmlString()
        {
            var catalog = new SampleStruct
            {
                Count     = 50,
                FirstName = "Pablo",
                LastName  = "Duartes",
                Time      = DateTime.Now
            };

            string xml = XSerializer.ToXml(catalog);

            Assert.IsTrue(xml.IndexOf("SampleStruct") > 0);
        }
예제 #3
0
        public void ToXml_ValidObject_ReturnsXmlString()
        {
            var catalog = new Catalog();
            var book    = new Book();
            var book2   = new Book();

            Dummy.Populate(book);
            Dummy.Populate(book2);
            Dummy.Populate(catalog);

            catalog.BookList.Add(book);
            catalog.BookList.Add(book2);

            string xml = XSerializer.ToXml(catalog);

            Assert.IsTrue(xml.Length > 0);
        }
예제 #4
0
        public void ToXml_String_ThrowsInvalidOperation()
        {
            string catalog = File.ReadAllText("Books.xml");

            Assert.Throws <InvalidOperationException>(() => XSerializer.ToXml(catalog));
        }
예제 #5
0
        public void ToXml_EmptyString_ThrowsArgumentException()
        {
            string catalog = "";

            Assert.Throws <ArgumentException>(() => XSerializer.ToXml(catalog));
        }
예제 #6
0
        public void ToXml_Null_ThrowsArgumentException()
        {
            Catalog catalog = null;

            Assert.Throws <ArgumentException>(() => XSerializer.ToXml(catalog));
        }