Ejemplo n.º 1
0
        public void EpubRightsTests_Serialize()
        {
            // arrange
            var rights = new EpubRights
            {
                Audio = new EpubRights.AudioElement {
                    TextToSpeech = true
                },
                CopyPaste = new EpubRights.CopyPasteElement
                {
                    Copyright    = "This is copywrited",
                    HasCopyright = true,
                    Days         = 365,
                    Percentage   = 100
                },
                DateTime = DateTime.Now.Subtract(TimeSpan.FromDays(365)),
                Devices  = new EpubRights.DevicesElement {
                    Count = 5
                },
                Isbn  = "9983341236786",
                Print = new EpubRights.PrintElement
                {
                    Permission = true
                }
            };

            // act
            var xml = rights.ToXml();

            //assert
            Assert.IsNotNull(XDocument.Parse(xml));
        }
Ejemplo n.º 2
0
        public void EpubRightsTests_Deserialize()
        {
            // arrange
            var xml = File.ReadAllText(@"..\..\Test Files\permissions.xml");

            // act
            var rights = EpubRights.Parse(xml);

            // assert
            Assert.IsNotNull(rights);
            Assert.AreEqual(rights.Devices.Count, 5);
            Assert.AreEqual(rights.Print.Days, 30);
            Assert.IsTrue(rights.Print.Permission);
            Assert.AreEqual(rights.CopyPaste.Percentage, 20);
            Assert.IsTrue(rights.CopyPaste.Permission);
        }