Esempio n. 1
0
        public void GetRaceById()
        {
            DndRace expected = new DndRace()
            {
                Name = "Dwarf", RacialBonuses = new int[] { 0, 0, 2, 0, 0, 0 }
            };

            DndApi api = new DndApi();

            var actual = api.GetRaceById(1);

            Assert.That(actual.Name, Is.EqualTo(expected.Name));
            Assert.That(actual.RacialBonuses, Is.EqualTo(expected.RacialBonuses));
        }
Esempio n. 2
0
 public DndRace Get_RaceById(int id)
 {
     try
     {
         DndApi dndApi = new DndApi();
         return(dndApi.GetRaceById(id));
     }
     catch (DndApiException e)
     {
         throw new HttpResponseException(this.Request.CreateResponse <object>(HttpStatusCode.BadRequest, e.Message));
     }
     catch (Exception e)
     {
         throw new HttpResponseException(this.Request.CreateResponse <object>(HttpStatusCode.InternalServerError, e.Message));
     }
 }
Esempio n. 3
0
        public List <DndRace> Get_AllRaces()
        {
            try
            {
                List <DndRace> races  = new List <DndRace>();
                DndApi         dndApi = new DndApi();

                Dictionary <string, int> raceIdList = dndApi.GetRaceOrClassesNameIdList(true);
                foreach (int raceId in raceIdList.Values)
                {
                    races.Add(dndApi.GetRaceById(raceId));
                }

                return(races);
            }
            catch (DndApiException e)
            {
                throw new HttpResponseException(this.Request.CreateResponse <object>(HttpStatusCode.BadRequest, e.Message));
            }
            catch (Exception e)
            {
                throw new HttpResponseException(this.Request.CreateResponse <object>(HttpStatusCode.InternalServerError, e.Message));
            }
        }