Equals() public method

public Equals ( object obj ) : bool
obj object
return bool
コード例 #1
0
		public void TestEquality2()
		{
			ManagedObjectName name1 = new ManagedObjectName("domain.net:name=SomeService,type=aware");
			ManagedObjectName name2 = new ManagedObjectName("domain.net:name=SomeService,type=aware");

			Assert( name1.GetHashCode() == name2.GetHashCode() );
			Assert( name1.Equals( name2 ) );

			ManagedObjectName name3 = new ManagedObjectName("domain.net:name=SomeService,type=unaware");
			Assert( name1.GetHashCode() != name3.GetHashCode() );
			Assert( !name1.Equals( name3 ) );
		}
コード例 #2
0
		public void TestEquality1()
		{
			ManagedObjectName name1 = new ManagedObjectName("domain.net");
			ManagedObjectName name2 = new ManagedObjectName("domain.net");

			Assert( name1.GetHashCode() == name2.GetHashCode() );
			Assert( name1.Equals( name2 ) );

			ManagedObjectName name3 = new ManagedObjectName("domain.org");
			Assert( name1.GetHashCode() != name3.GetHashCode() );
			Assert( !name1.Equals( name3 ) );
		}
コード例 #3
0
		public void TestSerialization()
		{
			MemoryStream stream = new MemoryStream();

			ManagedObjectName name1 = new ManagedObjectName("domain.net:name=SomeService,type=aware");

			BinaryFormatter formatter = new BinaryFormatter();
			formatter.Serialize(stream, name1);

			stream.Position = 0;

			ManagedObjectName name2 = (ManagedObjectName) formatter.Deserialize(stream);

			Assert( name1.GetHashCode() == name2.GetHashCode() );
			Assert( name1.Equals( name2 ) );
		}