public GetLocationTests() { _location = new Location { Id = 1, Name = "TestName", Description = "TestDescription" }; var locationRepositoryMock = new Mock <IContentLocationRepository>(); locationRepositoryMock .Setup(a => a.GetEntity(It.IsAny <int>())) .ReturnsAsync((int id) => id == 1 ? _location : null); _locationRepository = locationRepositoryMock.Object; _handler = new GetLocationQueryHandler(_locationRepository); }
public async Task Then_The_Service_Is_Called( GetLocationQuery query, Domain.Entities.Location location, [Frozen] Mock <ILocationService> service, GetLocationQueryHandler handler) { //Arrange service.Setup(x => x.GetLocationsByLocationAuthorityName(query.LocationName, query.AuthorityName)).ReturnsAsync(location); //Act var actual = await handler.Handle(query, CancellationToken.None); //Assert actual.Location.Should().BeEquivalentTo(location); }