profileShare

rasmusjy / splitapp-backend-clean-onion

Read-only snapshot

No repository description.

main default branch 429 files Expires Sep 13, 2026, 9:06 AM
TripBllDtoFactoryTests.cs 2,200 bytes
1 using App.BLL.DTO;
2 using App.BLL.Mappers;
3 using App.Domain;
4 using FluentAssertions;
5
6 namespace App.Tests.Mappers;
7
8 public class TripBllDtoFactoryTests
9 {
10 [Fact]
11 public void Create_MapsAllScalarFields()
12 {
13 var entity = new Trip
14 {
15 Id = Guid.NewGuid(),
16 Name = "Paris",
17 Description = "Long weekend",
18 Destination = "France",
19 StartDate = new DateTime(2026, 5, 1, 0, 0, 0, DateTimeKind.Utc),
20 EndDate = new DateTime(2026, 5, 5, 0, 0, 0, DateTimeKind.Utc),
21 Status = ETripStatus.Active,
22 DefaultCurrencyId = Guid.NewGuid(),
23 CreatedById = Guid.NewGuid()
24 };
25
26 var dto = TripBllDtoFactory.Create(entity);
27
28 dto.Id.Should().Be(entity.Id);
29 dto.Name.Should().Be("Paris");
30 dto.Description.Should().Be("Long weekend");
31 dto.Destination.Should().Be("France");
32 dto.StartDate.Should().Be(entity.StartDate);
33 dto.EndDate.Should().Be(entity.EndDate);
34 dto.Status.Should().Be(ETripStatus.Active);
35 dto.DefaultCurrencyId.Should().Be(entity.DefaultCurrencyId);
36 dto.CreatedById.Should().Be(entity.CreatedById);
37 }
38
39 [Fact]
40 public void ToEntity_RoundTrip_PreservesScalarFields()
41 {
42 var original = new TripBllDto
43 {
44 Id = Guid.NewGuid(),
45 Name = "Tokyo",
46 Description = "Cherry blossom",
47 Destination = "Japan",
48 StartDate = new DateTime(2026, 4, 1, 0, 0, 0, DateTimeKind.Utc),
49 EndDate = new DateTime(2026, 4, 14, 0, 0, 0, DateTimeKind.Utc),
50 Status = ETripStatus.Active,
51 DefaultCurrencyId = Guid.NewGuid(),
52 CreatedById = Guid.NewGuid()
53 };
54
55 var roundTripped = TripBllDtoFactory.Create(TripBllDtoFactory.ToEntity(original));
56
57 roundTripped.Should().BeEquivalentTo(original, opts => opts
58 .Excluding(x => x.CreatedAt)
59 .Excluding(x => x.UpdatedAt)
60 .Excluding(x => x.DefaultCurrency)
61 .Excluding(x => x.CreatedBy)
62 .Excluding(x => x.CreatedByFullName)
63 .Excluding(x => x.CreatedByEmail));
64 }
65 }
66