public void PokemonTypeSearcher_ReturnsException()
        {
            #region Arrange
            string      name        = PokemonNameMother.Random();
            PokemonName pokemonName = new PokemonName()
            {
                Name = name
            };
            string expectedMessage       = $"Pokemon '{name}' does not exist";
            var    pokemonTypeRepository = new Mock <PokemonTypeRepository>();

            pokemonTypeRepository
            .Setup(r => r.Search(It.Is <PokemonName>(n => String.Equals(n.Name, name, StringComparison.InvariantCultureIgnoreCase))))
            .ReturnsAsync(null as PokemonTypes);

            var pokemonTypeSearcher = new PokemonTypeSearcher(pokemonTypeRepository.Object);

            #endregion

            #region Act
            var exception = Record.ExceptionAsync(async() => await pokemonTypeSearcher.Execute(pokemonName));

            #endregion

            #region Assert
            Assert.Equal(expectedMessage, exception.Result.Message);

            #endregion
        }
Esempio n. 2
0
        public async Task Search_NotFound_ReturnsNull()
        {
            #region Arrange

            PokeApiPokemonTypeRepository pokemonTypeRepository = new PokeApiPokemonTypeRepository();
            PokemonName pokemonName = new PokemonName()
            {
                Name = PokemonNameMother.Random()
            };

            #endregion

            #region Act
            PokemonTypes pokemonTypes = await pokemonTypeRepository.Search(pokemonName);

            #endregion

            #region Assert
            Assert.Null(pokemonTypes);

            #endregion
        }