Merge pull request #12598 from abpframework/auto-merge/rel-5-3/1062

Merge branch dev with rel-5.3
pull/12471/merge
Halil İbrahim Kalkan 4 years ago committed by GitHub
commit 0ae21afa09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,21 +16,29 @@ public abstract class ValueObject
return false;
}
ValueObject other = (ValueObject)obj;
var other = (ValueObject)obj;
IEnumerator<object> thisValues = GetAtomicValues().GetEnumerator();
IEnumerator<object> otherValues = other.GetAtomicValues().GetEnumerator();
var thisValues = GetAtomicValues().GetEnumerator();
var otherValues = other.GetAtomicValues().GetEnumerator();
while (thisValues.MoveNext() && otherValues.MoveNext())
var thisMoveNext = thisValues.MoveNext();
var otherMoveNext = otherValues.MoveNext();
while (thisMoveNext && otherMoveNext)
{
if (ReferenceEquals(thisValues.Current, null) ^
ReferenceEquals(otherValues.Current, null))
if (ReferenceEquals(thisValues.Current, null) ^ ReferenceEquals(otherValues.Current, null))
{
return false;
}
if (thisValues.Current != null &&
!thisValues.Current.Equals(otherValues.Current))
if (thisValues.Current != null && !thisValues.Current.Equals(otherValues.Current))
{
return false;
}
thisMoveNext = thisValues.MoveNext();
otherMoveNext = otherValues.MoveNext();
if (thisMoveNext != otherMoveNext)
{
return false;
}

@ -11,6 +11,8 @@ public class Address : ValueObject
public int Number { get; }
public string[] Tags { get; }
private Address()
{
}
@ -18,11 +20,13 @@ public class Address : ValueObject
public Address(
Guid cityId,
string street,
int number)
int number,
params string[] tags)
{
CityId = cityId;
Street = street;
Number = number;
Tags = tags;
}
//Requires to implement this method to return properties.
@ -31,5 +35,9 @@ public class Address : ValueObject
yield return Street;
yield return CityId;
yield return Number;
foreach (var tag in Tags)
{
yield return tag;
}
}
}

@ -10,8 +10,9 @@ public class ValueObject_Tests
public void ValueObjects_With_Same_Properties_Should_Be_Equals()
{
var cityId = Guid.NewGuid();
var address1 = new Address(cityId, "Baris Manco", 42);
var address2 = new Address(cityId, "Baris Manco", 42);
var address1 = new Address(cityId, "Baris Manco", 42, "home", "office");
var address2 = new Address(cityId, "Baris Manco", 42, "home", "office");
address1.ValueEquals(address2).ShouldBeTrue();
}
@ -25,5 +26,10 @@ public class ValueObject_Tests
var address2 = new Address(cityId, "Baris Manco", 43);
address1.ValueEquals(address2).ShouldBeFalse();
address1 = new Address(cityId, "Baris Manco", 42, "home", "office");
address2 = new Address(cityId, "Baris Manco", 42, "home");
address1.ValueEquals(address2).ShouldBeFalse();
}
}

Loading…
Cancel
Save