Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public void TestInvalidNamePokeServiceThrowsException()
        {
            var badName    = "fake";
            var returnPoke = new RawPokemon();

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

            mockRepo.Setup(a => a.GetPokemon(badName)).Returns(returnPoke);

            Assert.Throws <ApiException>(() => pokeService.GetPokemon(badName));
        }
Exemplo n.º 3
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));
        }