ToString() public méthode

public ToString ( ) : string
Résultat string
Exemple #1
0
 public static void ApplicationDirectoryCallMethods()
 {
     ApplicationDirectory ad = new ApplicationDirectory("test");
     object obj = ad.Copy();
     bool check = ad.Equals(new object());
     int hash = ad.GetHashCode();
     string str = ad.ToString();
 }
		public void Copy ()
		{
			ApplicationDirectory ad = new ApplicationDirectory ("novell");
#if NET_2_0
			Assert.AreEqual ("novell", ad.Directory, "Directory");
#else
			Assert.AreEqual ("file://NOVELL", ad.Directory, "Directory");
#endif
			ApplicationDirectory copy = (ApplicationDirectory)ad.Copy ();
			Assert.IsTrue (ad.Equals (copy), "ad.Equals(copy)");
			Assert.IsTrue (copy.Equals (ad), "copy.Equals(ad)");
			Assert.IsFalse (Object.ReferenceEquals (ad, copy), "Copy");
			Assert.AreEqual (ad.GetHashCode (), copy.GetHashCode (), "GetHashCode");
			Assert.AreEqual (ad.ToString (), copy.ToString (), "ToString");
		}
		public void Equals_Invalid ()
		{
			// funny one
			string appdir = Invalid (true);
			// constructor is ok with an invalid path...
			ApplicationDirectory ad = new ApplicationDirectory (appdir);
			// we can copy it...
			ApplicationDirectory copy = (ApplicationDirectory)ad.Copy ();
			// we can't get it's hash code
			Assert.AreEqual (appdir.GetHashCode (), ad.GetHashCode (), "GetHashCode");
			// we can convert it to string...
			Assert.IsTrue (ad.ToString ().IndexOf (appdir) > 0, "ToString");
			// ... but it throws in Equals - with self!
			Assert.IsTrue (ad.Equals (ad), "Equals(self)");
		}
		public void ToString_ ()
		{
			ApplicationDirectory ad = new ApplicationDirectory ("file://MONO");
			string ts = ad.ToString ();
			Assert.IsTrue (ts.StartsWith ("<System.Security.Policy.ApplicationDirectory"), "Tag");
			Assert.IsTrue (ts.IndexOf ("version=\"1\"") > 0, "Directory");
			Assert.IsTrue (ts.IndexOf ("<Directory>file://MONO</Directory>") > 0, "Directory");
		}