public void Equality_NullTriangles_False() { Triangle triangle1 = new Triangle(2, 2.5, 4); Triangle triangle2 = null; object objTriangle2 = null; bool result1 = triangle1.Equals(triangle2); bool result2 = triangle1.Equals(objTriangle2); Assert.That(result1 == false); Assert.That(result2 == false); }
public void Equals_TestTriangles_Correct(Triangle triangle1, Triangle triangle2, bool isEquals) { object objTriangle1 = triangle1; object objTriangle2 = triangle2; string errorMessage = triangle1 + "; " + triangle2; bool result1 = triangle1.Equals(triangle2); bool result2 = triangle2.Equals(triangle1); bool result3 = triangle1.Equals(objTriangle2); bool result4 = triangle2.Equals(objTriangle1); Assert.That(result1 == isEquals, errorMessage); Assert.That(result2 == isEquals, errorMessage); Assert.That(result3 == isEquals, errorMessage); Assert.That(result4 == isEquals, errorMessage); }
public void SerializeAndDeserialize_Triangle_Success() { Triangle triangle1 = new Triangle(1, 1.5, 2); //Serialize triangle to triangleBytes byte[] triangleBytes; BinaryFormatter bf1 = new BinaryFormatter(); using (MemoryStream ms = new MemoryStream()) { bf1.Serialize(ms, triangle1); triangleBytes = ms.ToArray(); } //Deserialize triangleBytes to triangle Triangle triangle2; BinaryFormatter bf2 = new BinaryFormatter(); using (MemoryStream ms = new MemoryStream(triangleBytes, 0, triangleBytes.Length)) { triangle2 = (Triangle) bf2.Deserialize(ms); } Assert.That(triangle1.Equals(triangle2)); }