diff --git a/OSCADSharp/OSCADSharp.UnitTests/SphereTests.cs b/OSCADSharp/OSCADSharp.UnitTests/SphereTests.cs index 6337958..c7d296a 100644 --- a/OSCADSharp/OSCADSharp.UnitTests/SphereTests.cs +++ b/OSCADSharp/OSCADSharp.UnitTests/SphereTests.cs @@ -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)); + } } } diff --git a/OSCADSharp/OSCADSharp/Solids/Sphere.cs b/OSCADSharp/OSCADSharp/Solids/Sphere.cs index e3c16c2..42dee6a 100644 --- a/OSCADSharp/OSCADSharp/Solids/Sphere.cs +++ b/OSCADSharp/OSCADSharp/Solids/Sphere.cs @@ -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 } }