-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from jfhs/fix-multirelationship-save
fix(RelationshipAttribute): correct Equals and ToString
- Loading branch information
Showing
4 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
test/JsonApiDotNetCoreExampleTests/Unit/Models/AttributesEqualsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |