diff --git a/.gitignore b/.gitignore index c414e564..75a99b78 100644 --- a/.gitignore +++ b/.gitignore @@ -338,3 +338,6 @@ ASALocalRun/ # Test Results /tests-results + +# Snapshot testing +**/*.received.txt \ No newline at end of file diff --git a/src/Services/Enrolling/Enrolling.UnitTests/Domain/EnrollmentAggregateTests.cs b/src/Services/Enrolling/Enrolling.UnitTests/Domain/EnrollmentAggregateTests.cs index 011f281f..e3595662 100644 --- a/src/Services/Enrolling/Enrolling.UnitTests/Domain/EnrollmentAggregateTests.cs +++ b/src/Services/Enrolling/Enrolling.UnitTests/Domain/EnrollmentAggregateTests.cs @@ -1,25 +1,24 @@ using System; +using System.Threading.Tasks; using Enrolling.UnitTests.Builders; using OpenCodeFoundation.ESchool.Services.Enrolling.Domain.AggregatesModel.EnrollmentAggregate; +using VerifyXunit; using Xunit; namespace Enrolling.UnitTests.Domain { + [UsesVerify] public class EnrollmentAggregateTests { [Fact] - public void NewApplicationShouldSuccessWithValidInput() + public Task NewApplicationShouldSuccessWithValidInput() { var dto = new EnrollmentDtoBuilder() .WithDefaults() .Build(); var enrollment = Enrollment.CreateNew(dto.Name!, dto.Email!, dto.Mobile!); - - Assert.NotNull(enrollment); - Assert.Equal(dto.Name, enrollment.Name); - Assert.Equal(dto.Email, enrollment.EmailAddress); - Assert.Equal(dto.Mobile, enrollment.MobileNumber); + return Verifier.Verify(enrollment).UseDirectory("Snapshots"); } [Fact] diff --git a/src/Services/Enrolling/Enrolling.UnitTests/Domain/Snapshots/EnrollmentAggregateTests.NewApplicationShouldSuccessWithValidInput.verified.txt b/src/Services/Enrolling/Enrolling.UnitTests/Domain/Snapshots/EnrollmentAggregateTests.NewApplicationShouldSuccessWithValidInput.verified.txt new file mode 100644 index 00000000..0887c883 --- /dev/null +++ b/src/Services/Enrolling/Enrolling.UnitTests/Domain/Snapshots/EnrollmentAggregateTests.NewApplicationShouldSuccessWithValidInput.verified.txt @@ -0,0 +1,6 @@ +{ + Id: Guid_1, + Name: John Doe, + EmailAddress: john@example.com, + MobileNumber: 01771999999 +} \ No newline at end of file diff --git a/src/Services/Enrolling/Enrolling.UnitTests/Enrolling.UnitTests.csproj b/src/Services/Enrolling/Enrolling.UnitTests/Enrolling.UnitTests.csproj index 714d1291..4b0edad4 100644 --- a/src/Services/Enrolling/Enrolling.UnitTests/Enrolling.UnitTests.csproj +++ b/src/Services/Enrolling/Enrolling.UnitTests/Enrolling.UnitTests.csproj @@ -6,6 +6,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive