-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
125 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using Equatable.Entities; | ||
|
||
namespace Equatable.Generator.Tests.Entities; | ||
|
||
public class TaskTest | ||
{ | ||
[Fact] | ||
public void EqualNested() | ||
{ | ||
var left = new Equatable.Entities.Task | ||
{ | ||
Id = 1, | ||
Title = "In Progress", | ||
Description = "In Progress", | ||
StartDate = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
Created = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
CreatedBy = "system", | ||
Updated = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
UpdatedBy = "system", | ||
Status = new Status | ||
{ | ||
Id = 1, | ||
Name = "In Progress", | ||
Description = "In Progress", | ||
IsActive = true, | ||
DisplayOrder = 1, | ||
Created = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
CreatedBy = "system", | ||
Updated = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
UpdatedBy = "system" | ||
} | ||
}; | ||
|
||
var right = new Equatable.Entities.Task | ||
{ | ||
Id = 1, | ||
Title = "In Progress", | ||
Description = "In Progress", | ||
StartDate = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
Created = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
CreatedBy = "system", | ||
Updated = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
UpdatedBy = "system", | ||
Status = new Status | ||
{ | ||
Id = 1, | ||
Name = "In Progress", | ||
Description = "In Progress", | ||
IsActive = true, | ||
DisplayOrder = 1, | ||
Created = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
CreatedBy = "system", | ||
Updated = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
UpdatedBy = "system" | ||
} | ||
}; | ||
|
||
var isEqual = left.Equals(right); | ||
isEqual.Should().BeTrue(); | ||
|
||
// check operator == | ||
isEqual = left == right; | ||
isEqual.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void NotEqualNested() | ||
{ | ||
var left = new Equatable.Entities.Task | ||
{ | ||
Id = 1, | ||
Title = "In Progress", | ||
Description = "In Progress", | ||
StartDate = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
Created = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
CreatedBy = "system", | ||
Updated = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
UpdatedBy = "system", | ||
Status = new Status | ||
{ | ||
Id = 1, | ||
Name = "In Progress", | ||
Description = "In Progress", | ||
IsActive = true, | ||
DisplayOrder = 1, | ||
Created = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
CreatedBy = "system", | ||
Updated = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
UpdatedBy = "system" | ||
} | ||
}; | ||
|
||
var right = new Equatable.Entities.Task | ||
{ | ||
Id = 1, | ||
Title = "In Progress", | ||
Description = "In Progress", | ||
StartDate = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
Created = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
CreatedBy = "system", | ||
Updated = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
UpdatedBy = "system", | ||
Status = new Status | ||
{ | ||
Id = 2, | ||
Name = "In Progress", | ||
Description = "In Progress", | ||
IsActive = true, | ||
DisplayOrder = 1, | ||
Created = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
CreatedBy = "system", | ||
Updated = new DateTimeOffset(2024, 9, 1, 11, 30, 15, TimeSpan.Zero), | ||
UpdatedBy = "system" | ||
} | ||
}; | ||
|
||
var isEqual = left.Equals(right); | ||
isEqual.Should().BeFalse(); | ||
|
||
// check operator != | ||
isEqual = left != right; | ||
isEqual.Should().BeTrue(); | ||
} | ||
|
||
} |