Skip to content

Commit 7112609

Browse files
zhenlei520blazor-component
authored andcommitted
chore: fix !=
1 parent 5a845b9 commit 7112609

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

  • src/DDD/MASA.BuildingBlocks.DDD.Domain/Entities
  • test/MASA.BuildingBlocks.DDD.Domain.Tests

‎src/DDD/MASA.BuildingBlocks.DDD.Domain/Entities/Entity.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace MASA.BuildingBlocks.DDD.Domain.Entities;
1+
namespace MASA.BuildingBlocks.DDD.Domain.Entities;
22

33
public abstract class Entity : IEntity, IEquatable<Entity>, IEquatable<object>
44
{
@@ -50,7 +50,7 @@ public override int GetHashCode()
5050

5151
public static bool operator !=(Entity? x, Entity? y)
5252
{
53-
if (x is null ^ y is null) return false;
53+
if (x is null ^ y is null) return true;
5454

5555
if (x is null) return false;
5656

@@ -66,4 +66,4 @@ public class Entity<TKey> : Entity, IEntity<TKey>
6666
{
6767
yield return ("Id", Id!);
6868
}
69-
}
69+
}

‎test/MASA.BuildingBlocks.DDD.Domain.Tests/TestEntity.cs‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ public class TestEntity
66
[TestMethod]
77
public void TestToString()
88
{
9-
MasaEntity entity = new() {Id = Guid.Empty};
9+
MasaEntity entity = new() { Id = Guid.Empty };
1010
Assert.AreEqual("MasaEntity:Id=00000000-0000-0000-0000-000000000000", entity.ToString());
1111
}
1212

1313
[TestMethod]
1414
public void TestEquals()
1515
{
1616
var id = Guid.NewGuid();
17-
MasaEntity x = new() {Id = id};
18-
MasaEntity y = new() {Id = id};
17+
MasaEntity x = new() { Id = id };
18+
MasaEntity y = new() { Id = id };
1919

2020
Assert.IsTrue(x.Equals(y));
21-
Assert.IsTrue(x.Equals((object) y));
21+
Assert.IsTrue(x.Equals((object)y));
2222
}
2323

2424
[TestMethod]
2525
public void TestGetHashCode()
2626
{
2727
var id = Guid.NewGuid();
28-
MasaEntity x = new() {Id = id};
29-
MasaEntity y = new() {Id = id};
28+
MasaEntity x = new() { Id = id };
29+
MasaEntity y = new() { Id = id };
3030

3131
Assert.AreEqual(x.GetHashCode(), y.GetHashCode());
3232
}
@@ -35,9 +35,9 @@ public void TestGetHashCode()
3535
public void TestOperator()
3636
{
3737
var id = Guid.NewGuid();
38-
MasaEntity x = new() {Id = id};
39-
MasaEntity y = new() {Id = id};
40-
MasaEntity z = new() {Id = Guid.NewGuid()};
38+
MasaEntity x = new() { Id = id };
39+
MasaEntity y = new() { Id = id };
40+
MasaEntity z = new() { Id = Guid.NewGuid() };
4141

4242
Assert.IsTrue(x == y);
4343
Assert.IsTrue(x != z);
@@ -47,9 +47,11 @@ public void TestOperator()
4747
Assert.IsTrue(null == m);
4848
Assert.IsFalse(null != m);
4949
Assert.IsFalse(m != null);
50+
Assert.IsTrue(x != null);
51+
Assert.IsTrue(null != x);
5052
}
5153

5254
public class MasaEntity : Entity<Guid>
5355
{
5456
}
55-
}
57+
}

0 commit comments

Comments
 (0)