Пример #1
0
        public void SerializerIncompleteObjTest()
        {
            MyXmlSerializer<PlantSettings> serializer = new MyXmlSerializer<PlantSettings>();
              StringBuilder builder = new StringBuilder();
              builder.Append(@"<?xml version=""1.0"" encoding=""utf-16""?>");
              builder.Append(@"<PlantSettings xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">");
              builder.Append(@"<PlantVisibility>OwnersOnly</PlantVisibility>");
              builder.Append(@"</PlantSettings>");

              PlantSettings actual = serializer.DeserializeObject(builder.ToString());
              Assert.IsNull(actual.InverterEuroMapping);
              Assert.AreEqual(E_PlantVisibility.OwnersOnly, actual.PlantVisibility);
        }
Пример #2
0
        public void XMLSerializerTest()
        {
            MyXmlSerializer<PlantSettings> serializer = new MyXmlSerializer<PlantSettings>();
              PlantSettings settings = new PlantSettings();
              settings.PlantVisibility = E_PlantVisibility.OwnersOnly;
              settings.InverterEuroMapping = new SerializableDictionary<int, double>();
              settings.InverterEuroMapping.Add(1, 2.5);
              settings.InverterEuroMapping.Add(2, 3.5);

              string actual = serializer.SerializeObject(settings);
              Console.Write(actual);

              PlantSettings result = serializer.DeserializeObject(actual);
              Assert.AreEqual(E_PlantVisibility.OwnersOnly, result.PlantVisibility);
        }