-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetPositionsQueryHandlerTests.cs
More file actions
47 lines (38 loc) · 1.67 KB
/
Copy pathGetPositionsQueryHandlerTests.cs
File metadata and controls
47 lines (38 loc) · 1.67 KB
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
namespace TalentManagementAPI.Application.Tests.Positions
{
public class GetPositionsQueryHandlerTests
{
private readonly Mock<IPositionRepositoryAsync> _repositoryMock = new();
private readonly Mock<IModelHelper> _modelHelperMock = new();
[Fact]
public async Task Handle_ShouldReturnPagedResult_FromRepositoryShape()
{
// Arrange
var query = new GetPositionsQuery
{
Fields = "Id,PositionTitle",
PageNumber = 1,
PageSize = 5
};
var shaped = new List<Entity>
{
new() { ["Id"] = Guid.NewGuid(), ["PositionTitle"] = "Developer" }
};
var records = new RecordsCount { RecordsFiltered = 1, RecordsTotal = 1 };
_modelHelperMock.Setup(m => m.ValidateModelFields<PositionSummaryDto>(It.IsAny<string>()))
.Returns("Id,PositionTitle");
_modelHelperMock.Setup(m => m.GetModelFields<PositionSummaryDto>())
.Returns("Id,PositionTitle");
_repositoryMock.Setup(r => r.GetPositionReponseAsync(query))
.ReturnsAsync((shaped, records));
var handler = new GetAllPositionsQueryHandler(_repositoryMock.Object, _modelHelperMock.Object);
// Act
var result = await handler.Handle(query, CancellationToken.None);
// Assert
result.IsSuccess.Should().BeTrue();
result.Value.Should().BeEquivalentTo(shaped);
result.IsFailure.Should().BeFalse();
_repositoryMock.Verify(r => r.GetPositionReponseAsync(query), Times.Once);
}
}
}