Exemplo n.º 1
0
 public void GetPropertyWithDefault ()
 {
     Properties props = new Properties();
     props.Add ("foo", "this");
     props.Add ("bar", "is");
     Assert.AreEqual ("this", props.GetProperty ("foo"));
     Assert.AreEqual ("is", props.GetProperty ("bar"));
     Assert.AreEqual ("it", props.GetProperty ("baz", "it"));
 }
Exemplo n.º 2
0
        public void GetPropertyWithDefault()
        {
            Properties props = new Properties();

            props.Add("foo", "this");
            props.Add("bar", "is");
            Assert.AreEqual("this", props.GetProperty("foo"));
            Assert.AreEqual("is", props.GetProperty("bar"));
            Assert.AreEqual("it", props.GetProperty("baz", "it"));
        }
Exemplo n.º 3
0
        public void Instantiation ()
        {
            Properties root = new Properties();
            root.Add ("foo", "this");
            root.Add ("bar", "is");
            Properties props = new Properties(root);
			props.SetProperty("myPropertyKey", "myPropertyValue");
            Assert.AreEqual (3, props.Count);
            Assert.AreEqual ("this", props.GetProperty ("foo"));
            Assert.AreEqual ("is", props.GetProperty ("bar"));
            Assert.AreEqual ("myPropertyValue", props.GetProperty ("myPropertyKey"));
        }
Exemplo n.º 4
0
        public void Instantiation()
        {
            Properties root = new Properties();

            root.Add("foo", "this");
            root.Add("bar", "is");
            Properties props = new Properties(root);

            props.SetProperty("myPropertyKey", "myPropertyValue");
            Assert.AreEqual(3, props.Count);
            Assert.AreEqual("this", props.GetProperty("foo"));
            Assert.AreEqual("is", props.GetProperty("bar"));
            Assert.AreEqual("myPropertyValue", props.GetProperty("myPropertyKey"));
        }
Exemplo n.º 5
0
        public void ListAndLoad()
        {
            Properties props = new Properties();

            props.Add("foo", "this");
            props.Add("bar", "is");
            props.Add("baz", "it");
            FileInfo file = new FileInfo("properties.test");

            try
            {
                // write 'em out...
                using (Stream cout = file.OpenWrite())
                {
                    props.List(cout);
                }
                // read 'em back in...
                using (Stream cin = file.OpenRead())
                {
                    props = new Properties();
                    props.Load(cin);
                    Assert.AreEqual(3, props.Count);
                    Assert.AreEqual("this", props.GetProperty("foo"));
                    Assert.AreEqual("is", props.GetProperty("bar"));
                    Assert.AreEqual("it", props.GetProperty("baz", "it"));
                }
            }
            finally
            {
                try
                {
                    file.Delete();
                }
                catch (IOException)
                {
                }
            }
        }
Exemplo n.º 6
0
 public void ListAndLoad()
 {
     Properties props = new Properties();
     props.Add ("foo", "this");
     props.Add ("bar", "is");
     props.Add ("baz", "it");
     FileInfo file = new FileInfo ("properties.test");
     try 
     {
         // write 'em out...
         using (Stream cout = file.OpenWrite ()) 
         {
             props.List (cout);
         }
         // read 'em back in...
         using (Stream cin = file.OpenRead ()) 
         {
             props = new Properties ();
             props.Load (cin);
             Assert.AreEqual (3, props.Count);
             Assert.AreEqual ("this", props.GetProperty ("foo"));
             Assert.AreEqual ("is", props.GetProperty ("bar"));
             Assert.AreEqual ("it", props.GetProperty ("baz", "it"));
         }
     }
     finally 
     {
         try 
         {
             file.Delete ();
         } 
         catch (IOException)
         {
         }
     }
 }