public bool PosTest2() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest2: Two return value is not equal with two instance"); try { UTF8Encoding utf8a = new UTF8Encoding(true); UTF8Encoding utf8b = new UTF8Encoding(true, true); if (utf8a.GetHashCode() == utf8b.GetHashCode()) { TestLibrary.TestFramework.LogError("002.1", "Method GetHashCode Err."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return(retVal); }
public bool PosTest2() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest2: Two return value is not equal with two instance"); try { UTF8Encoding utf8a = new UTF8Encoding(true); UTF8Encoding utf8b = new UTF8Encoding(true,true); if (utf8a.GetHashCode() == utf8b.GetHashCode()) { TestLibrary.TestFramework.LogError("002.1", "Method GetHashCode Err."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public void PosTest2() { UTF8Encoding utf8a = new UTF8Encoding(true); UTF8Encoding utf8b = new UTF8Encoding(true, true); Assert.NotEqual(utf8a.GetHashCode(), utf8b.GetHashCode()); }
public void PosTest1() { UTF8Encoding utf8a = new UTF8Encoding(); UTF8Encoding utf8b = utf8a; Assert.Equal(utf8a.GetHashCode(), utf8b.GetHashCode()); }
public void EqualsTest(UTF8Encoding encoding, object value, bool expected) { Assert.Equal(expected, encoding.Equals(value)); if (value is UTF8Encoding) { Assert.Equal(expected, encoding.GetHashCode().Equals(value.GetHashCode())); } }
public static void Main() { // Many ways to instantiate a UTF8 encoding. UTF8Encoding UTF8a = new UTF8Encoding(); Encoding UTF8b = Encoding.UTF8; Encoding UTF8c = new UTF8Encoding(true, true); Encoding UTF8d = new UTF8Encoding(false, false); // But not all are the same. Console.WriteLine(UTF8a.GetHashCode()); Console.WriteLine(UTF8b.GetHashCode()); Console.WriteLine(UTF8c.GetHashCode()); Console.WriteLine(UTF8d.GetHashCode()); }
public void Equals(UTF8Encoding encoding, object value, bool expected) { Assert.Equal(expected, encoding.Equals(value)); if (value is UTF8Encoding) { Assert.Equal(expected, encoding.GetHashCode().Equals(value.GetHashCode())); } }