+ Added a Clone() test for Sphere

This commit is contained in:
Mike Smith 2016-02-12 17:02:21 -08:00
parent dc950b5fdb
commit 7efd7f161d
2 changed files with 33 additions and 0 deletions

View File

@ -53,5 +53,21 @@ namespace OSCADSharp.UnitTests
Assert.IsTrue(script.StartsWith("sphere("));
Assert.IsTrue(script.EndsWith(");"));
}
[TestMethod]
public void Sphere_CloneCoversEveryAttribute_copyWithAllAttributes()
{
var sphere = new Sphere()
{
Diameter = 10,
MinimumAngle = 5,
MinimumFragmentSize = 5,
Resolution = 30
};
var clone = sphere.Clone();
Assert.IsTrue(sphere.Equals(clone));
}
}
}

View File

@ -80,6 +80,23 @@ namespace OSCADSharp.Solids
Radius = this.Radius
};
}
public override bool Equals(object other)
{
if(other.GetType() == typeof(Sphere))
{
Sphere otherSphere = other as Sphere;
return this.Diameter == otherSphere.Diameter &&
this.Radius == otherSphere.Radius &&
this.MinimumAngle == otherSphere.MinimumAngle &&
this.MinimumFragmentSize == otherSphere.MinimumFragmentSize &&
this.Resolution == otherSphere.Resolution;
}
else
{
return base.Equals(other);
}
}
#endregion
}
}