From 33540c545e79393baaaf1b5878fc62227166b264 Mon Sep 17 00:00:00 2001 From: Shaed Parkar Date: Tue, 3 Dec 2024 20:48:51 +0000 Subject: [PATCH] add tests --- .../HearingDetailsResponseExtensionsTests.cs | 35 ++++++++++++++++--- .../HearingDetailsResponseExtensions.cs | 1 - 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs index c079d6284..3994db2d0 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs @@ -1,18 +1,43 @@ using AdminWebsite.Contracts.Responses; +using AdminWebsite.Extensions; namespace AdminWebsite.UnitTests.Extensions { public class HearingDetailsResponseExtensionsTests { - [SetUp] - public void Setup() + [Test] + public void HasScheduleAmended__True_WhenDatesHaveChanged() { - new HearingDetailsResponse + var hearing = new HearingDetailsResponse { - Id = Guid.NewGuid(), - Participants = new List() + ScheduledDateTime = DateTime.UtcNow }; + var anotherHearing = new HearingDetailsResponse + { + ScheduledDateTime = DateTime.UtcNow.AddHours(1) + }; + + var result = hearing.HasScheduleAmended(anotherHearing); + + result.Should().BeTrue(); } + [Test] + public void HasScheduleAmended__False_WhenDatesAreTheSame() + { + var now = DateTime.UtcNow; + var hearing = new HearingDetailsResponse + { + ScheduledDateTime = now + }; + var anotherHearing = new HearingDetailsResponse + { + ScheduledDateTime = now + }; + + var result = hearing.HasScheduleAmended(anotherHearing); + + result.Should().BeFalse(); + } } } \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs b/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs index e7991bde4..7c200fb83 100644 --- a/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs +++ b/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs @@ -5,7 +5,6 @@ namespace AdminWebsite.Extensions; public static class HearingDetailsResponseExtensions { public static bool HasScheduleAmended(this HearingDetailsResponse hearing, HearingDetailsResponse anotherHearing) - { return hearing.ScheduledDateTime.Ticks != anotherHearing.ScheduledDateTime.Ticks; }