mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 01:54:43 +00:00
Add brewery discovery & detail pages with location-based search (#253)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using Domain.Entities;
|
||||
using Features.Breweries.Dtos;
|
||||
using Features.Breweries.Queries.GetAllBreweryLocations;
|
||||
using Features.Breweries.Repository;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
||||
namespace Features.Breweries.Tests.Queries;
|
||||
|
||||
public class GetAllBreweryLocationsHandlerTests
|
||||
{
|
||||
private readonly GetAllBreweryLocationsHandler _handler;
|
||||
private readonly Mock<IBreweryRepository> _repoMock = new();
|
||||
|
||||
public GetAllBreweryLocationsHandlerTests()
|
||||
{
|
||||
_handler = new GetAllBreweryLocationsHandler(_repoMock.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Handle_ReturnsEmpty_WhenNoBreweriesHaveALocation()
|
||||
{
|
||||
_repoMock.Setup(r => r.GetAllLocations()).ReturnsAsync(Array.Empty<BreweryPost>());
|
||||
|
||||
IEnumerable<SimplifiedBreweryDto> result = await _handler.Handle(
|
||||
new GetAllBreweryLocationsQuery(),
|
||||
CancellationToken.None
|
||||
);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_repoMock.Verify(r => r.GetAllLocations(), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Handle_ReturnsAllLocatedBreweries_FromRepository()
|
||||
{
|
||||
BreweryPost[] breweries =
|
||||
[
|
||||
new BreweryPost { BreweryPostId = Guid.NewGuid(), BreweryName = "A" },
|
||||
new BreweryPost { BreweryPostId = Guid.NewGuid(), BreweryName = "B" },
|
||||
];
|
||||
_repoMock.Setup(r => r.GetAllLocations()).ReturnsAsync(breweries);
|
||||
|
||||
IEnumerable<SimplifiedBreweryDto> result = await _handler.Handle(
|
||||
new GetAllBreweryLocationsQuery(),
|
||||
CancellationToken.None
|
||||
);
|
||||
|
||||
result
|
||||
.Select(b => b.BreweryPostId)
|
||||
.Should()
|
||||
.BeEquivalentTo(breweries.Select(b => b.BreweryPostId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user