| Name | Message | Date |
|---|---|---|
| 📄 OrderServiceTests.cs | 1 day ago | |
| 📄 RefundServiceTests.cs | 4 days ago | |
| 📄 Walley.Checkout.Api.Tests.csproj | 4 days ago |
📄
OrderServiceTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using FluentAssertions; using Xunit; using Walley.Checkout.Api.Models; using Walley.Checkout.Api.Services; namespace Walley.Checkout.Api.Tests; public class OrderServiceTests { private readonly OrderService _sut; public OrderServiceTests() { _sut = new OrderService(); } [Fact] public async Task GetAllOrdersAsync_ShouldReturnAllOrders() { // Act var orders = await _sut.GetAllOrdersAsync(); // Assert orders.Should().HaveCount(3); } [Fact] public async Task GetOrderByIdAsync_ShouldReturnTheSoughtOrder() { // Act var order = await _sut.GetOrderByIdAsync("ORD-001"); // Assert order.Should().NotBeNull(); order!.Id.Should().Be("ORD-001"); } [Fact] public async Task GetOrderByIdAsync_ShouldReturnNull_WhenTheSoughtOrderIsNotFound() { // Act var order = await _sut.GetOrderByIdAsync("ORD-004"); // Assert order.Should().BeNull(); } [Fact] public async Task CreateOrderAsync_ShouldSetCalculatedValuesOnTheOrder() { // Arrange var order = new Order { CustomerName = "A.N. Other", CustomerEmail = "a.n.other@example.com", Currency = "SEK", Lines = new List<OrderLine> { new() { ProductName = "Product A", Quantity = 2, UnitPrice = 3m }, new() { ProductName = "Product B", Quantity = 1, UnitPrice = 6m }, } }; // Act order = await _sut.CreateOrderAsync(order); // Assert order.Id.Should().NotBeEmpty(); order.CreatedAt.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(1)); order.Status.Should().Be(OrderStatus.Pending); order.TotalAmount.Should().Be(12m); } [Fact] public async Task CreateOrderAsync_ShouldPersistTheOrder() { // Arrange var order = new Order { CustomerName = "A.N. Other", CustomerEmail = "a.n.other@example.com", Currency = "SEK", Lines = new List<OrderLine> { new() { ProductName = "Product A", Quantity = 2, UnitPrice = 3m }, new() { ProductName = "Product B", Quantity = 1, UnitPrice = 6m }, } }; // Act order = await _sut.CreateOrderAsync(order); // Assert var persistedOrder = await _sut.GetOrderByIdAsync(order.Id); persistedOrder.Should().NotBeNull(); } }