// Copyright (c) Umbraco. // See LICENSE for more details. using System; using Umbraco.Cms.Core.Models; namespace Umbraco.Cms.Tests.Common; public class TestClone : IDeepCloneable, IEquatable { public TestClone(Guid id) { Id = id; IsClone = true; } public TestClone() => Id = Guid.NewGuid(); public Guid Id { get; } public bool IsClone { get; } public object DeepClone() => new TestClone(Id); /// /// Indicates whether the current object is equal to another object of the same type. /// /// /// true if the current object is equal to the parameter; otherwise, false. /// /// An object to compare with this object. public bool Equals(TestClone other) { if (other is null) { return false; } if (ReferenceEquals(this, other)) { return true; } return Id.Equals(other.Id); } /// /// Determines whether the specified object is equal to the current object. /// /// /// true if the specified object is equal to the current object; otherwise, false. /// /// The object to compare with the current object. public override bool Equals(object obj) { if (obj is null) { return false; } if (ReferenceEquals(this, obj)) { return true; } if (obj.GetType() != GetType()) { return false; } return Equals((TestClone)obj); } /// /// Serves as the default hash function. /// /// /// A hash code for the current object. /// public override int GetHashCode() => Id.GetHashCode(); public static bool operator ==(TestClone left, TestClone right) => Equals(left, right); public static bool operator !=(TestClone left, TestClone right) => Equals(left, right) == false; }