Se hizo toda la parte del Unit Of Work y estoy a punto de terminar la de tests unitarios
This commit is contained in:
Alejandro Sarmiento
2024-02-28 22:40:34 +01:00
parent b55f2be085
commit 81a3e91d6e
67 changed files with 1112 additions and 1375 deletions

View File

@@ -0,0 +1,41 @@
namespace MongoProject.Domain.Common
{
public abstract class ValueObject
{
protected static bool EqualOperator(ValueObject left, ValueObject right)
{
if (left is null ^ right is null)
{
return false;
}
return ReferenceEquals(left, right) || left.Equals(right);
}
protected static bool NotEqualOperator(ValueObject left, ValueObject right)
{
return !(EqualOperator(left, right));
}
protected abstract IEnumerable<object> GetEqualityComponents();
public override bool Equals(object obj)
{
if (obj == null || obj.GetType() != GetType())
{
return false;
}
var other = (ValueObject)obj;
return this.GetEqualityComponents().SequenceEqual(other.GetEqualityComponents());
}
public override int GetHashCode()
{
return GetEqualityComponents()
.Select(x => x != null ? x.GetHashCode() : 0)
.Aggregate((x, y) => x ^ y);
}
// Other utility methods
}
}