public void Store () { 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 with the specified header... using (Stream cout = file.OpenWrite ()) { props.Store (cout, "My Properties"); } } finally { try { file.Delete (); } catch (IOException) { } } }
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")); }
public void Remove () { Properties props = new Properties(); props.Add ("foo", "this"); props.Add ("bar", "is"); Assert.AreEqual (2, props.Count); props.Remove ("foo"); Assert.AreEqual (1, props.Count); Assert.IsFalse (props.ContainsKey ("foo")); }
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")); }
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) { } } }