Exemplo n.º 1
0
        public void GetById_ShouldReturnNull_WhenUnknownIdPassed()
        {
            HeroesService heroesService = new HeroesService();

            Hero hero = heroesService.GetById(5000);

            Assert.IsNull(hero);
        }
Exemplo n.º 2
0
        public void GetHeroes_ShouldReturnAllHeroes()
        {
            HeroesService heroesService = new HeroesService();

            IEnumerable <Hero> heroes = heroesService.GetHeroes();

            Assert.AreEqual(5, heroes.Count());
        }
Exemplo n.º 3
0
        public void GenerateId_ShouldReturnNextId()
        {
            HeroesService heroesService = new HeroesService();

            int id = heroesService.GenerateId();

            Assert.AreEqual(id, heroesService.GetHeroes().Last().Id + 1);
        }
Exemplo n.º 4
0
        public void GetById_ShouldReturnSpecifiedHero_WhenExisitingIdPassed()
        {
            HeroesService heroesService = new HeroesService();

            Hero hero = heroesService.GetById(1);

            Assert.AreEqual("Pasha", hero.Name);
        }
Exemplo n.º 5
0
        public void Remove_ShouldRemoveSpecifiedHero_WhenExistingIdPassed()
        {
            HeroesService heroesService = new HeroesService();

            heroesService.Remove(5);

            Assert.AreEqual(4, heroesService.GetHeroes().Count());
        }
Exemplo n.º 6
0
        public void SearchHeroes_ShouldReturnHeroesWithCorrectName_WhenKnownNameIsPassed()
        {
            HeroesService heroesService = new HeroesService();
            string        name          = "ky";

            IEnumerable <Hero> filtered = heroesService.SearchHeroes(name);

            Assert.AreEqual(1, filtered.Count());
        }
Exemplo n.º 7
0
        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());
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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());
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 16
0
 public HeroesController(HeroesService service, IDbConnection db)
 {
     _service = service;
     _db      = db;
 }
Exemplo n.º 17
0
 public ValuesController(HeroesService heroesService)
 {
     this.hs = heroesService;
 }
Exemplo n.º 18
0
        public void HeroesService_ShouldIntializeNewHeroesList()
        {
            HeroesService heroesService = new HeroesService();

            Assert.IsNotNull(heroesService.GetHeroes());
        }
 public HeroesController(IHostingEnvironment env, HeroesService service)
 {
     this.service = service;
     this.env     = env;
 }
Exemplo n.º 20
0
 public HeroesController(HeroesService heroesService)
 {
     _heroesService = heroesService;
 }