profileShare

rasmusjy / splitapp-backend-clean-onion

Read-only snapshot

No repository description.

main default branch 429 files Expires Sep 13, 2026, 9:06 AM
BudgetCategoryBllDtoFactoryTests.cs 1,688 bytes
1 using App.BLL.Mappers;
2 using App.Domain;
3 using Base.Domain;
4 using FluentAssertions;
5
6 namespace App.Tests.Mappers;
7
8 public class BudgetCategoryBllDtoFactoryTests
9 {
10 [Fact]
11 public void Create_MapsAllScalarFields()
12 {
13 var entity = new BudgetCategory
14 {
15 Id = Guid.NewGuid(),
16 TripId = Guid.NewGuid(),
17 Name = new LangStr("Food"),
18 IconName = "fa-utensils",
19 PlannedAmount = 250.50m,
20 DisplayOrder = 3
21 };
22
23 var dto = BudgetCategoryBllDtoFactory.Create(entity);
24
25 dto.Id.Should().Be(entity.Id);
26 dto.TripId.Should().Be(entity.TripId);
27 ((string)dto.Name).Should().Be("Food");
28 dto.IconName.Should().Be("fa-utensils");
29 dto.PlannedAmount.Should().Be(250.50m);
30 dto.DisplayOrder.Should().Be(3);
31 }
32
33 [Fact]
34 public void ToEntity_RoundTrip_PreservesScalarFields()
35 {
36 var original = new App.BLL.DTO.BudgetCategoryBllDto
37 {
38 Id = Guid.NewGuid(),
39 TripId = Guid.NewGuid(),
40 Name = new LangStr("Transport"),
41 IconName = "fa-car",
42 PlannedAmount = 500m,
43 DisplayOrder = 2
44 };
45
46 var entity = BudgetCategoryBllDtoFactory.ToEntity(original);
47 var roundTripped = BudgetCategoryBllDtoFactory.Create(entity);
48
49 roundTripped.Id.Should().Be(original.Id);
50 roundTripped.TripId.Should().Be(original.TripId);
51 ((string)roundTripped.Name).Should().Be("Transport");
52 roundTripped.IconName.Should().Be("fa-car");
53 roundTripped.PlannedAmount.Should().Be(500m);
54 roundTripped.DisplayOrder.Should().Be(2);
55 }
56 }
57