private static void SetupPokemonTranslationServiceMock( Mock <IPokemonTranslationService> pokemonTranslationServiceMock, IPokemonModel expectedPokemonModel) { pokemonTranslationServiceMock .Setup(service => service.Translate(It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync(() => expectedPokemonModel); }
public async Task TestPokemonTranslation_WhenSuccessful_ExpectTranslatedModel( IPokemonModel expectedPokemonModel) { // Arrange var pokemonTranslationService = DIHelper.GetServices() .GetConfiguredService <IPokemonTranslationService>(); var sutController = new PokemonController(pokemonTranslationService); // Act var actionResult = await sutController.Get(expectedPokemonModel.Name, CancellationToken.None); // Assert var objectResult = Assert.IsType <OkObjectResult>(actionResult.Result); var translatedPokemon = Assert.IsType <PokemonModel>(objectResult.Value); Assert.Equal(expectedPokemonModel, translatedPokemon, new PokemonModelComparer()); }