示例#1
0
        public void testGetElement()
        {
            WaveUnitConfig item = new WaveUnitConfig();

            item.putElement("a", "A");
            item.putElement("b", null);
            item.putElement("c", "");

            Assert.AreEqual("A", item.getElement("a"));
            Assert.AreEqual("", item.getElement("b"));
            Assert.AreEqual("", item.getElement("c"));

            Assert.AreEqual("", item.getElement("NON_EXIST_KEY"));
            Assert.AreEqual("", item.getElement(null));
        }
示例#2
0
        public void testPutElement()
        {
            WaveUnitConfig item = new WaveUnitConfig();

            item.putElement("a", "B");
            Assert.AreEqual("\na:B", item.getConfigString());

            item.putElement("a", "C");
            Assert.AreEqual("\na:C", item.getConfigString());

            item.putElement("a", null);
            Assert.AreEqual("\na:", item.getConfigString());

            item.putElement("b", "A");
            Assert.AreEqual("\na:\nb:A", item.getConfigString());
        }
示例#3
0
        public void testXmlSerialization()
        {
            XmlSerializer  xs   = new XmlSerializer(typeof(WaveUnitConfig));
            WaveUnitConfig item = new WaveUnitConfig();

            item.putElement("a", "A");
            string actualPath = PortUtil.createTempFile();

            using (FileStream fs = new FileStream(actualPath, FileMode.Create, FileAccess.Write)){
                xs.serialize(fs, item);
            }

            Console.WriteLine(File.ReadAllText(actualPath));
            byte[] actual   = File.ReadAllBytes(actualPath);
            byte[] expected = File.ReadAllBytes("./expected/WaveUnitConfig.xml");
            Assert.AreEqual(expected, actual);

            File.Delete(actualPath);
        }
示例#4
0
        public void testPutElementWithEmptyKey()
        {
            WaveUnitConfig item = new WaveUnitConfig();

            item.putElement("", "a");
        }
示例#5
0
        public void testPutElementWithNullKey()
        {
            WaveUnitConfig item = new WaveUnitConfig();

            item.putElement(null, "a");
        }