From b40d593598a06cded19010e0b3dbed60ea650657 Mon Sep 17 00:00:00 2001 From: Paul Welter Date: Wed, 4 Sep 2024 22:14:05 -0500 Subject: [PATCH] Create TaskTest.cs --- .../Entities/TaskTest.cs | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 test/Equatable.Generator.Tests/Entities/TaskTest.cs diff --git a/test/Equatable.Generator.Tests/Entities/TaskTest.cs b/test/Equatable.Generator.Tests/Entities/TaskTest.cs new file mode 100644 index 0000000..81f6b25 --- /dev/null +++ b/test/Equatable.Generator.Tests/Entities/TaskTest.cs @@ -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(); + } + +}