コード例 #1
0
ファイル: GetLocationTests.cs プロジェクト: AniRPG/AniRPG
        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);
        }
コード例 #2
0
        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);
        }