Exemple #1
0
        public void TestMissingEnglishDescriptionPokeServiceThrowsException()
        {
            var name       = "test name";
            var id         = 1;
            var returnPoke = new RawPokemon();

            returnPoke.Name = name;
            returnPoke.Id   = id;
            var pokeCharacteristic = new PokemonCharacteristic();

            pokeCharacteristic.descriptions = new System.Collections.Generic.List <Description>();
            pokeCharacteristic.descriptions.Add(new Description {
                description = "oui francais", language = new Language {
                    name = "fr"
                }
            });

            var mockRepo    = new Mock <IPokemonRepository>();
            var pokeService = new PokemonService(mockRepo.Object);

            mockRepo.Setup(a => a.GetPokemon(name)).Returns(returnPoke);
            mockRepo.Setup(a => a.GetCharacteristic(id)).Returns(pokeCharacteristic);

            Assert.Throws <ApiException>(() => pokeService.GetPokemon(name));
        }
Exemple #2
0
        public void TestMissingCharacteristicPokeServiceThrowsException()
        {
            var name       = "test name";
            var id         = 1;
            var returnPoke = new RawPokemon();

            returnPoke.Name = name;
            returnPoke.Id   = id;
            var pokeCharacteristic = new PokemonCharacteristic();

            pokeCharacteristic = null;
            var mockRepo    = new Mock <IPokemonRepository>();
            var pokeService = new PokemonService(mockRepo.Object);

            mockRepo.Setup(a => a.GetPokemon(name)).Returns(returnPoke);
            mockRepo.Setup(a => a.GetCharacteristic(id)).Returns(pokeCharacteristic);
            Assert.Throws <ApiException>(() => pokeService.GetPokemon(name));
        }