-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return the reason why the relationship cannot be created from CanCrea…
…teRelationship (#903) * refactor: simplify usage of test container in MigrationReaderTests * feat: return code * test: add/update integration tests * chore: remove unused ApplicationErrors * feat: don't mention "relationshipRequest" in error codes * test: minor changes * test: inherit from AbstractTestsBase
- Loading branch information
Showing
16 changed files
with
197 additions
and
52 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
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
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
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
64 changes: 64 additions & 0 deletions
64
...ships/src/Relationships.Domain/Aggregates/Relationships/Relationship.CanEstablishTests.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,64 @@ | ||
using Backbone.Modules.Relationships.Domain.TestHelpers; | ||
using Backbone.UnitTestTools.BaseClasses; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Backbone.Modules.Relationships.Domain.Aggregates.Relationships; | ||
|
||
public class RelationshipCanEstablishTests : AbstractTestsBase | ||
{ | ||
[Fact] | ||
public void Returns_null_when_no_relationships_exists() | ||
{ | ||
// Act | ||
var error = Relationship.CanEstablish([]); | ||
|
||
// Assert | ||
error.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void Returns_null_when_a_relationship_ready_for_deletion_exists() | ||
{ | ||
// Act | ||
var error = Relationship.CanEstablish([TestData.CreateRelationshipInStatus(RelationshipStatus.ReadyForDeletion)]); | ||
|
||
// Assert | ||
error.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void Returns_null_when_a_rejected_relationship_exists() | ||
{ | ||
// Act | ||
var error = Relationship.CanEstablish([TestData.CreateRelationshipInStatus(RelationshipStatus.Rejected)]); | ||
|
||
// Assert | ||
error.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void Returns_null_when_a_revoked_relationship_exists() | ||
{ | ||
// Act | ||
var error = Relationship.CanEstablish([TestData.CreateRelationshipInStatus(RelationshipStatus.Revoked)]); | ||
|
||
// Assert | ||
error.Should().BeNull(); | ||
} | ||
|
||
[Theory] | ||
[InlineData(RelationshipStatus.Pending)] | ||
[InlineData(RelationshipStatus.Active)] | ||
[InlineData(RelationshipStatus.Terminated)] | ||
[InlineData(RelationshipStatus.DeletionProposed)] | ||
public void Returns_an_error_when_a_relationship_exists(RelationshipStatus status) | ||
{ | ||
// Act | ||
var error = Relationship.CanEstablish([TestData.CreateRelationshipInStatus(status)]); | ||
|
||
// Assert | ||
error.Should().NotBeNull(); | ||
error!.Code.Should().Be("error.platform.validation.relationship.relationshipToTargetAlreadyExists"); | ||
} | ||
} |
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
Oops, something went wrong.