diff --git a/README.md b/README.md
index e43b83d6f1..1c886507e1 100644
--- a/README.md
+++ b/README.md
@@ -46,14 +46,14 @@ Install-Package JsonApiDotnetCore
- project.json
```json
-"JsonApiDotNetCore": "1.2.0"
+"JsonApiDotNetCore": "1.2.1"
```
- *.csproj
```xml
-
+
```
diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
index a222271081..de2426ec77 100755
--- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
+++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
@@ -1,7 +1,7 @@
- 1.2.0
+ 1.2.1
netcoreapp1.0
JsonApiDotNetCore
JsonApiDotNetCore
diff --git a/src/JsonApiDotNetCore/Models/RelationshipAttribute.cs b/src/JsonApiDotNetCore/Models/RelationshipAttribute.cs
index 5e02eaf1ef..6e5356c343 100644
--- a/src/JsonApiDotNetCore/Models/RelationshipAttribute.cs
+++ b/src/JsonApiDotNetCore/Models/RelationshipAttribute.cs
@@ -16,5 +16,20 @@ protected RelationshipAttribute(string publicName)
public bool IsHasOne { get { return this.GetType() == typeof(HasOneAttribute); } }
public abstract void SetValue(object entity, object newValue);
+
+ public override string ToString()
+ {
+ return base.ToString() + ":" + PublicRelationshipName;
+ }
+
+ public override bool Equals(object obj)
+ {
+ RelationshipAttribute attr = obj as RelationshipAttribute;
+ if (attr == null)
+ {
+ return false;
+ }
+ return IsHasMany == attr.IsHasMany && PublicRelationshipName.Equals(attr.PublicRelationshipName);
+ }
}
}
diff --git a/test/JsonApiDotNetCoreExampleTests/Unit/Models/AttributesEqualsTests.cs b/test/JsonApiDotNetCoreExampleTests/Unit/Models/AttributesEqualsTests.cs
new file mode 100644
index 0000000000..ac9efd35e3
--- /dev/null
+++ b/test/JsonApiDotNetCoreExampleTests/Unit/Models/AttributesEqualsTests.cs
@@ -0,0 +1,75 @@
+using JsonApiDotNetCore.Models;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Xunit;
+
+namespace JsonApiDotNetCoreExampleTests.Unit.Models
+{
+ public class AttributesEqualsTests
+ {
+ [Fact]
+ public void HasManyAttribute_Equals_Returns_True_When_Same_Name()
+ {
+ var a = new HasManyAttribute("test");
+ var b = new HasManyAttribute("test");
+
+ Assert.Equal(a, b);
+ }
+
+ [Fact]
+ public void HasManyAttribute_Equals_Returns_False_When_Different_Name()
+ {
+ var a = new HasManyAttribute("test");
+ var b = new HasManyAttribute("test2");
+
+ Assert.NotEqual(a, b);
+ }
+
+ [Fact]
+ public void HasOneAttribute_Equals_Returns_True_When_Same_Name()
+ {
+ var a = new HasOneAttribute("test");
+ var b = new HasOneAttribute("test");
+
+ Assert.Equal(a, b);
+ }
+
+ [Fact]
+ public void HasOneAttribute_Equals_Returns_False_When_Different_Name()
+ {
+ var a = new HasOneAttribute("test");
+ var b = new HasOneAttribute("test2");
+
+ Assert.NotEqual(a, b);
+ }
+
+ [Fact]
+ public void AttrAttribute_Equals_Returns_True_When_Same_Name()
+ {
+ var a = new AttrAttribute("test");
+ var b = new AttrAttribute("test");
+
+ Assert.Equal(a, b);
+ }
+
+ [Fact]
+ public void AttrAttribute_Equals_Returns_False_When_Different_Name()
+ {
+ var a = new AttrAttribute("test");
+ var b = new AttrAttribute("test2");
+
+ Assert.NotEqual(a, b);
+ }
+
+ [Fact]
+ public void HasManyAttribute_Doesnt_Equal_HasOneAttribute_With_Same_Name()
+ {
+ RelationshipAttribute a = new HasManyAttribute("test");
+ RelationshipAttribute b = new HasOneAttribute("test");
+
+ Assert.NotEqual(a, b);
+ Assert.NotEqual(b, a);
+ }
+ }
+}