Skip to content

Commit

Permalink
Issue #61: Update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
akazad13 committed Jan 22, 2025
1 parent b0fadc4 commit 4fe227b
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FluentAssertions;
using Moq;
using Shopizy.Application.Common.Caching;
using Shopizy.Application.Common.Interfaces.Persistence;
using Shopizy.Application.UnitTests.Users.TestUtils;
using Shopizy.Application.Users.Queries.GetUser;
Expand All @@ -13,12 +14,18 @@ public class GetUserQueryHandlerTests
private readonly GetUserQueryHandler _sut;
private readonly Mock<IUserRepository> _mockUserRepository;
private readonly Mock<IOrderRepository> _mockOrderRepository;
private readonly Mock<ICacheHelper> _mockCacheHelper;

public GetUserQueryHandlerTests()
{
_mockUserRepository = new Mock<IUserRepository>();
_mockOrderRepository = new Mock<IOrderRepository>();
_sut = new GetUserQueryHandler(_mockUserRepository.Object, _mockOrderRepository.Object);
_mockCacheHelper = new Mock<ICacheHelper>();
_sut = new GetUserQueryHandler(
_mockUserRepository.Object,
_mockOrderRepository.Object,
_mockCacheHelper.Object
);
}

[Fact]
Expand All @@ -32,6 +39,10 @@ public async Task ShouldReturnUserObjectWhenValidUserIdIsProvided()
.Setup(c => c.GetUserById(UserId.Create(query.UserId)))
.ReturnsAsync(user);

_mockCacheHelper
.Setup(c => c.GetAsync<UserDto>($"user-{user.Id.Value}"))
.ReturnsAsync(() => null);

// Act
var result = (await _sut.Handle(query, CancellationToken.None)).Match(x => x, x => null);

Expand Down

0 comments on commit 4fe227b

Please sign in to comment.