Exemplo n.º 1
0
        public void CloneLevel2()
        {
            var obj       = ModelBaseTestHelper.CreateIniFileObject();
            var clonedObj = obj.Clone();

            Assert.AreEqual(obj, clonedObj);
        }
Exemplo n.º 2
0
        public void Load_FileName_SerializationMode_Xml()
        {
            var originalObject = ModelBaseTestHelper.CreateIniFileObject();
            var loadedObject   = SerializationTestHelper.SerializeAndDeserialize(originalObject, SerializationFactory.GetXmlSerializer());

            Assert.AreEqual(originalObject, loadedObject);
        }
Exemplo n.º 3
0
        public void XmlSerializationLevel2()
        {
            var originalObject = ModelBaseTestHelper.CreateIniFileObject();
            var clonedObject   = SerializationTestHelper.SerializeAndDeserializeObject(originalObject, SerializationMode.Xml);

            Assert.AreEqual(originalObject, clonedObject);
        }
Exemplo n.º 4
0
        public void Load_FileName_SerializationMode_Xml_EnableRedirects()
        {
            var originalObject = ModelBaseTestHelper.CreateIniFileObject();
            var loadedObject   = SerializationTestHelper.SerializeAndDeserializeObject(originalObject, SerializationMode.Xml, true);

            Assert.AreEqual(originalObject, loadedObject);
        }
Exemplo n.º 5
0
        public void Load_FileName_SerializationMode_Binary()
        {
            var originalObject = ModelBaseTestHelper.CreateIniFileObject();
            var loadedObject   = SerializationTestHelper.SerializeAndDeserializeObject(originalObject, SerializationMode.Binary, false);

            Assert.AreEqual(originalObject, loadedObject);
        }
Exemplo n.º 6
0
        public void ReadXml()
        {
            // Should always return null
            var iniFile = ModelBaseTestHelper.CreateIniFileObject();

            Assert.AreEqual(null, ((IXmlSerializable)iniFile).GetSchema());
        }
Exemplo n.º 7
0
        public void ToXml()
        {
            var iniFile = ModelBaseTestHelper.CreateIniFileObject();

            XDocument document     = iniFile.ToXml();
            var       loadedObject = IniFile.Load(document);

            Assert.AreEqual(iniFile, loadedObject);
        }
Exemplo n.º 8
0
        public void EqualsLevel2()
        {
            // Create 2 objects
            var obj1 = ModelBaseTestHelper.CreateIniFileObject();
            var obj2 = ModelBaseTestHelper.CreateIniFileObject();

            // Equals
            Assert.AreEqual(obj1, obj2);
        }
Exemplo n.º 9
0
        public void Equals_AreNotEqual()
        {
            // Create 2 objects
            var obj1 = ModelBaseTestHelper.CreateComputerSettingsObject();
            var obj2 = ModelBaseTestHelper.CreateIniFileObject();

            // Equals
            Assert.AreNotEqual(obj1, obj2);
        }
Exemplo n.º 10
0
        public void Load_Bytes_EnableRedirects()
        {
            var originalObject = ModelBaseTestHelper.CreateIniFileObject();

            byte[] originalBytes = originalObject.Bytes;

            var loadedObject = IniFile.Load(originalBytes, true);

            Assert.AreEqual(originalObject, loadedObject);
        }
Exemplo n.º 11
0
        /// <summary>
        ///   Initializes the default ini file collection.
        /// </summary>
        /// <returns>New <see cref = "ObservableCollection{T}" />.</returns>
        private static ObservableCollection <IniFile> InitializeDefaultIniFileCollection()
        {
            var result = new ObservableCollection <IniFile>();

            // Add 3 files
            result.Add(ModelBaseTestHelper.CreateIniFileObject("Initial file 1", new[] { ModelBaseTestHelper.CreateIniEntryObject("G1", "K1", "V1") }));
            result.Add(ModelBaseTestHelper.CreateIniFileObject("Initial file 2", new[] { ModelBaseTestHelper.CreateIniEntryObject("G2", "K2", "V2") }));
            result.Add(ModelBaseTestHelper.CreateIniFileObject("Initial file 3", new[] { ModelBaseTestHelper.CreateIniEntryObject("G3", "K3", "V3") }));

            return(result);
        }
Exemplo n.º 12
0
        public void Load_Stream_SerializationMode_Xml()
        {
            using (var memoryStream = new MemoryStream())
            {
                var originalObject = ModelBaseTestHelper.CreateIniFileObject();
                originalObject.Save(memoryStream, SerializationMode.Xml);

                memoryStream.Position = 0L;
                var loadedObject = IniFile.Load(memoryStream, SerializationMode.Xml);

                Assert.AreEqual(originalObject, loadedObject);
            }
        }
Exemplo n.º 13
0
        public void Load_Stream_EnableRedirects()
        {
            using (var memoryStream = new MemoryStream())
            {
                var originalObject = ModelBaseTestHelper.CreateIniFileObject();
                originalObject.Save(memoryStream);

                memoryStream.Position = 0L;
                var loadedObject = IniFile.Load(memoryStream, true);

                Assert.AreEqual(originalObject, loadedObject);
            }
        }
Exemplo n.º 14
0
        public void Load_Stream_SerializationMode_Xml()
        {
            // Note: in a perfect world, we would have real models deriving from SavableModelBase

            using (var memoryStream = new MemoryStream())
            {
                var serializer = SerializationFactory.GetBinarySerializer();

                var originalObject = ModelBaseTestHelper.CreateIniFileObject();
                serializer.Serialize(originalObject, memoryStream);

                memoryStream.Position = 0L;
                var loadedObject = serializer.Deserialize(typeof(IniFile), memoryStream);

                Assert.AreEqual(originalObject, loadedObject);
            }
        }
Exemplo n.º 15
0
        public void XmlSerialization_FixedCheck()
        {
            const string ExpectedXmlContent = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                              @"
<IniFile xmlns:ctl=" + "\"http://catel.codeplex.com\">" + @"
  <FileName>MyIniFile</FileName>
  <IniEntryCollection xmlns:d1p1=" + "\"http://schemas.datacontract.org/2004/07/Catel.Test.Data\"" + " xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"" + @">
    <d1p1:IniEntry>
      <Group>Group 0</Group>
      <Key>Key 0</Key>
      <Value>Value 0</Value>
      <IniEntryType>Public</IniEntryType>
    </d1p1:IniEntry>
    <d1p1:IniEntry>
      <Group>Group 1</Group>
      <Key>Key 1</Key>
      <Value>Value 1</Value>
      <IniEntryType>Private</IniEntryType>
    </d1p1:IniEntry>
    <d1p1:IniEntry>
      <Group>Group 2</Group>
      <Key>Key 2</Key>
      <Value>Value 2</Value>
      <IniEntryType>Public</IniEntryType>
    </d1p1:IniEntry>
  </IniEntryCollection>
</IniFile>";

            IniFile iniFile = ModelBaseTestHelper.CreateIniFileObject();

            using (var memoryStream = new MemoryStream())
            {
                iniFile.Save(memoryStream, SerializationMode.Xml);

                memoryStream.Position = 0L;

                TextReader reader     = new StreamReader(memoryStream);
                string     xmlContent = reader.ReadToEnd();

                Assert.AreEqual(ExpectedXmlContent, xmlContent);
            }
        }