Exemple #1
0
        public async Task Given_EmptyOrNullPokemonName_When_GetTranslatedPokemonInfoAsync_IsCalled_Throws_Exception()
        {
            //Arrange
            var pokemonInfo = pokemonData[DataType.Valid];

            mockPokeService.Setup(o => o.GetBasicPokemonInfoAsync(It.IsAny <string>())).ReturnsAsync(pokemonInfo);
            translatedPokemonFeature = new TranslatedPokemonFeature(mockPokeService.Object, mockTranslationsService.Object);

            //Act & Assert
            await Assert.ThrowsAsync <ArgumentNullException>(() => translatedPokemonFeature.GetTranslatedPokemonInfoAsync(string.Empty));

            await Assert.ThrowsAsync <ArgumentNullException>(() => translatedPokemonFeature.GetTranslatedPokemonInfoAsync(default));
Exemple #2
0
        public async Task Given_Rare_And_Legendary_PokemonName_When_GetTranslatedPokemonInfoAsync_IsCalled_Returns_PokemonInfoDto_With_YodaTranslation()
        {
            //Arrange
            var pokemonInfo     = pokemonData[DataType.Valid];
            var yodaDescription = yodaTranslationsData[TranslationType.Valid];

            mockPokeService.Setup(o => o.GetBasicPokemonInfoAsync(It.IsAny <string>())).ReturnsAsync(pokemonInfo);
            mockTranslationsService.Setup(o => o.GetYodaTranslationAsync(It.IsAny <string>())).ReturnsAsync(yodaDescription);
            translatedPokemonFeature = new TranslatedPokemonFeature(mockPokeService.Object, mockTranslationsService.Object);

            //Act
            var result = await translatedPokemonFeature.GetTranslatedPokemonInfoAsync("mewtwo").ConfigureAwait(false);

            //Assert
            Assert.NotNull(result);
            Assert.Equal("rare", result.Habitat);
            Assert.NotEqual(pokemonInfo.FlavorTextEntries.First().FlavorText, result.Description);
            mockTranslationsService.Verify(o => o.GetShakespheareTranslationAsync(It.IsAny <string>()), Times.Never);
            mockTranslationsService.Verify(o => o.GetYodaTranslationAsync(It.IsAny <string>()), Times.Once);
        }
Exemple #3
0
 public MyPokedexController(IBasicPokemonFeature basicPokemonFeature, ITranslatedPokemonFeature translatedPokemonFeature)
 {
     this.basicPokemonFeature      = basicPokemonFeature;
     this.translatedPokemonFeature = translatedPokemonFeature;
 }