-
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.
Fix wrong implementation of ISTransient for value type IDs. (#9)
Closes #8
- Loading branch information
Showing
5 changed files
with
127 additions
and
62 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
17 changes: 17 additions & 0 deletions
17
tests/Fluxera.Entity.UnitTests/EmployeeAggregate/EmployeeGuid.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,17 @@ | ||
namespace Fluxera.Entity.UnitTests.EmployeeAggregate | ||
{ | ||
using System; | ||
using JetBrains.Annotations; | ||
|
||
[PublicAPI] | ||
public class EmployeeGuid : AggregateRoot<EmployeeGuid, Guid> | ||
{ | ||
[DomainSignature] | ||
public string Name { get; set; } | ||
|
||
[DomainSignature] | ||
public int EmployeeNumber { get; set; } | ||
|
||
public decimal Salary { get; set; } | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
tests/Fluxera.Entity.UnitTests/EntityWithGuidKeyTransientTests.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,38 @@ | ||
namespace Fluxera.Entity.UnitTests | ||
{ | ||
using System; | ||
using FluentAssertions; | ||
using Fluxera.Entity.UnitTests.EmployeeAggregate; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class EntityWithGuidKeyTransientTests | ||
{ | ||
[Test] | ||
public void ShouldReturnTrueForTransientEntityForDefaultValue() | ||
{ | ||
EmployeeGuid employee = new EmployeeGuid | ||
{ | ||
Name = "James Bond", | ||
EmployeeNumber = 8051007, | ||
Salary = 1_000_000, | ||
}; | ||
|
||
employee.IsTransient.Should().BeTrue(); | ||
} | ||
|
||
[Test] | ||
public void ShouldReturnTrueForTransientEntityForEmpty() | ||
{ | ||
EmployeeGuid employee = new EmployeeGuid | ||
{ | ||
ID = Guid.Empty, | ||
Name = "James Bond", | ||
EmployeeNumber = 8051007, | ||
Salary = 1_000_000, | ||
}; | ||
|
||
employee.IsTransient.Should().BeTrue(); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
tests/Fluxera.Entity.UnitTests/EntityWithStringKeyTransientTests.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,65 @@ | ||
namespace Fluxera.Entity.UnitTests | ||
{ | ||
using FluentAssertions; | ||
using Fluxera.Entity.UnitTests.EmployeeAggregate; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class EntityWithStringKeyTransientTests | ||
{ | ||
[Test] | ||
public void ShouldReturnTrueForTransientEntityForDefaultValue() | ||
{ | ||
Employee employee = new Employee | ||
{ | ||
Name = "James Bond", | ||
EmployeeNumber = 8051007, | ||
Salary = 1_000_000, | ||
}; | ||
|
||
employee.IsTransient.Should().BeTrue(); | ||
} | ||
|
||
[Test] | ||
public void ShouldReturnTrueForTransientEntityForEmpty() | ||
{ | ||
Employee employee = new Employee | ||
{ | ||
ID = string.Empty, | ||
Name = "James Bond", | ||
EmployeeNumber = 8051007, | ||
Salary = 1_000_000, | ||
}; | ||
|
||
employee.IsTransient.Should().BeTrue(); | ||
} | ||
|
||
[Test] | ||
public void ShouldReturnTrueForTransientEntityForNull() | ||
{ | ||
Employee employee = new Employee | ||
{ | ||
ID = null, | ||
Name = "James Bond", | ||
EmployeeNumber = 8051007, | ||
Salary = 1_000_000, | ||
}; | ||
|
||
employee.IsTransient.Should().BeTrue(); | ||
} | ||
|
||
[Test] | ||
public void ShouldReturnTrueForTransientEntityForOnlyWhitespace() | ||
{ | ||
Employee employee = new Employee | ||
{ | ||
ID = " ", | ||
Name = "James Bond", | ||
EmployeeNumber = 8051007, | ||
Salary = 1_000_000, | ||
}; | ||
|
||
employee.IsTransient.Should().BeTrue(); | ||
} | ||
} | ||
} |