コード例 #1
0
        public async Task GetAchievementByIdAsync()
        {
            //Arrange
            var achievement       = AchievementDumbData.GetRandomEntity();
            var expectedValue     = _mapper.Map <ReadAchievementModel>(achievement);
            var cancellationToken = new CancellationToken();

            _achievementRepository.Setup(x => x.GetByIdAsync(It.IsAny <Guid>(), cancellationToken)).Returns(Task.FromResult(achievement));

            // Act
            var response = await _achievementService.GetAchievementByIdAsync(achievement.Id, cancellationToken);

            // Assert
            _achievementRepository.Verify(x => x.GetByIdAsync(It.IsAny <Guid>(), cancellationToken), Times.Once);
            response.Should().BeEquivalentTo(expectedValue);
        }