public void ShouldApplyOverriddenEquals() { var cookie = new GuineaPig("Cookie", 800, 37.7); var clone = cookie.DeepCopy(); var other = new GuineaPig("Cookie", 800, 37.7); Assert.That(cookie.Equals(clone), Is.True); Assert.That(cookie.Equals(other), Is.False); Assert.That(cookie == clone, Is.True); Assert.That(cookie != other, Is.True); }
public void ShouldPerformDeepCopy() { var pig = new GuineaPig("Cookie", 800, 37.7); var clone = pig.DeepCopy(); Assert.That(pig.Name, Is.EqualTo(clone.Name)); Assert.That(pig.Weight, Is.EqualTo(clone.Weight)); var prop = typeof(GuineaPig).GetProperty("BodyTemp", BindingFlags.NonPublic | BindingFlags.Instance); Assert.That(prop?.GetValue(pig), Is.EqualTo(prop?.GetValue(clone))); }
public void ShouldApplyOverriddenToString() { var cookie = new GuineaPig("Cookie", 800, 37.7); Assert.That(cookie.ToString(), Is.EqualTo($"GuineaPig {cookie.Id} 'Cookie'")); }