public void GetById_ShouldReturnNull_WhenUnknownIdPassed() { HeroesService heroesService = new HeroesService(); Hero hero = heroesService.GetById(5000); Assert.IsNull(hero); }
public void GetHeroes_ShouldReturnAllHeroes() { HeroesService heroesService = new HeroesService(); IEnumerable <Hero> heroes = heroesService.GetHeroes(); Assert.AreEqual(5, heroes.Count()); }
public void GenerateId_ShouldReturnNextId() { HeroesService heroesService = new HeroesService(); int id = heroesService.GenerateId(); Assert.AreEqual(id, heroesService.GetHeroes().Last().Id + 1); }
public void GetById_ShouldReturnSpecifiedHero_WhenExisitingIdPassed() { HeroesService heroesService = new HeroesService(); Hero hero = heroesService.GetById(1); Assert.AreEqual("Pasha", hero.Name); }
public void Remove_ShouldRemoveSpecifiedHero_WhenExistingIdPassed() { HeroesService heroesService = new HeroesService(); heroesService.Remove(5); Assert.AreEqual(4, heroesService.GetHeroes().Count()); }
public void SearchHeroes_ShouldReturnHeroesWithCorrectName_WhenKnownNameIsPassed() { HeroesService heroesService = new HeroesService(); string name = "ky"; IEnumerable <Hero> filtered = heroesService.SearchHeroes(name); Assert.AreEqual(1, filtered.Count()); }
public void SearchHeroes_ShouldReturnEmpty_WhenUnknownNameIsPassed() { HeroesService heroesService = new HeroesService(); string name = "boi"; IEnumerable <Hero> filtered = heroesService.SearchHeroes(name); Assert.AreEqual(0, filtered.Count()); }
public void get_hero() { HeroesService heroes = new HeroesService(); var hero = new Hero(); string name = "Ma"; IEnumerable <Hero> filtered = heroes.SearchHeroes(name); Assert.AreEqual(1, filtered.Count()); //get Heroes[Test] }
public void remove_hero() { HeroesService heroes = new HeroesService(); List <Hero> heroList = heroes.GetHeroes().ToList(); int n = heroList.Count(); foreach (Hero h in heroList) { heroes.Remove(h.Id); } Assert.AreEqual(0, heroes.GetHeroes().Count()); }
public async Task Create_Super_Heroues() { var heroRepository = new Mock <IHeroRepository>(); var service = new HeroesService(heroRepository.Object); IList <Hero> list = new List <Hero>(); for (int i = 0; i < 20; i++) { list.Add(await service.CreateHeroAsync("Hero" + i)); } Assert.IsTrue(list.GroupBy(h => h.Ability).Count() > 1); Assert.IsTrue(list.GroupBy(h => h.SuitColor).Count() > 1); }
public void Update_ShouldReplaceSpecifiedHero_WhenHeroPassed() { HeroesService heroesService = new HeroesService(); Hero hero = new Hero() { Id = 5, Name = "kyle", Pic = "https://images2.minutemediacdn.com/image/upload/c_crop,h_1180,w_2100,x_0,y_94/f_auto,q_auto,w_1100/v1555001162/shape/mentalfloss/504106-wikipedia.jpg", Power = 0.7 }; heroesService.Update(hero); Assert.AreEqual(0.7, heroesService.GetHeroes().Last().Power); }
public void add_new_hero() { HeroesService heroes = new HeroesService(); Hero chris = new Hero(); chris.Name = "Chris"; chris.Pic = "https://making-the-web.com/sites/default/files/clipart/142014/stick-figure-142014-5551841.jpg"; chris.Power = 2; heroes.Add(chris); Hero ashazi = new Hero(); ashazi.Name = "Ashazi"; ashazi.Pic = "http://clipart-library.com/images/pio5eXK6T.png"; ashazi.Power = 3; heroes.Add(ashazi); Hero pasha = new Hero(); pasha.Name = "Pasha"; pasha.Pic = "https://image.shutterstock.com/image-vector/stick-figure-business-ideas-260nw-220840597.jpg"; pasha.Power = 4; heroes.Add(pasha); Hero marcus = new Hero(); marcus.Name = "Marcus"; marcus.Pic = "https://image.shutterstock.com/image-vector/stick-figure-celebration-cheer-260nw-331595411.jpg"; marcus.Power = 2; heroes.Add(marcus); Hero dale = new Hero(); dale.Name = "Dale"; dale.Pic = "https://images2.minutemediacdn.com/image/upload/c_crop,h_1180,w_2100,x_0,y_94/f_auto,q_auto,w_1100/v1555001162/shape/mentalfloss/504106-wikipedia.jpg"; dale.Power = 5; heroes.Add(dale); Assert.AreEqual(5, heroes.GetHeroes().Count()); }
public void Add_AddANewHero_WhenHeroPassed() { HeroesService heroesService = new HeroesService(); Hero hero = new Hero() { Name = "kyle", Pic = "https://images2.minutemediacdn.com/image/upload/c_crop,h_1180,w_2100,x_0,y_94/f_auto,q_auto,w_1100/v1555001162/shape/mentalfloss/504106-wikipedia.jpg", Power = 1.5 }; int id = heroesService.GenerateId(); hero.Id = id; heroesService.Add(hero); Assert.AreEqual(id, heroesService.GetHeroes().Last().Id); }
public void update_hero() { HeroesService heroes = new HeroesService(); Hero hero = new Hero() { Id = 4, Name = "Dale", Pic = "https://images2.minutemediacdn.com/image/upload/c_crop,h_1180,w_2100,x_0,y_94/f_auto,q_auto,w_1100/v1555001162/shape/mentalfloss/504106-wikipedia.jpg", Power = 3 }; heroes.Update(hero); Assert.AreEqual(3, heroes.GetById(4).Power); //update Heroes[Test] }
public async Task Deve_Obter_A_Lista_De_Herois_Dado_A_Quantidade_Menor_Ou_Igual_A_100_E_Maior_Que_Zero(string quantidadeHerois) { var hero = new Hero { data = new Data() }; hero.data.results = new List <Result>() { new Result { id = 10 } }; //Arrang //Mock me disponibiliza um objeto concreto var mockRepo = new Mock <IHeroes>(); //mockRepo.Setup(hero => hero.GetHeroes(quantidadeHerois)).ReturnsAsync(hero); HeroesService heroesService = new HeroesService(null); ListHeroesViewViewModel listHeroesViewViewModel = new ListHeroesViewViewModel(null, heroesService); //action - ação await listHeroesViewViewModel.GetHeroes(quantidadeHerois); //assert - Comparação if (quantidadeHerois.Equals("5")) { Assert.AreEqual(5, listHeroesViewViewModel.Herois.Count); } else if (quantidadeHerois.Equals("10")) { Assert.AreEqual(10, listHeroesViewViewModel.Herois.Count); } else { Assert.AreEqual(100, listHeroesViewViewModel.Herois.Count); } }
public HeroesController(HeroesService service, IDbConnection db) { _service = service; _db = db; }
public ValuesController(HeroesService heroesService) { this.hs = heroesService; }
public void HeroesService_ShouldIntializeNewHeroesList() { HeroesService heroesService = new HeroesService(); Assert.IsNotNull(heroesService.GetHeroes()); }
public HeroesController(IHostingEnvironment env, HeroesService service) { this.service = service; this.env = env; }
public HeroesController(HeroesService heroesService) { _heroesService = heroesService; }