Exemplo n.º 1
0
        public void GetClassByIdTestSpellcaster()
        {
            DndClass expected = new DndClass()
            {
                Name = "Wizard", HitDie = 6, Spellcaster = true
            };

            DndApi api = new DndApi();

            var actual = api.GetClassById(12);

            Assert.That(actual.Name, Is.EqualTo(expected.Name));
            Assert.That(actual.HitDie, Is.EqualTo(expected.HitDie));
            Assert.That(actual.Spellcaster, Is.EqualTo(expected.Spellcaster));
        }
Exemplo n.º 2
0
        public void GetClassByIdTest()
        {
            DndClass expected = new DndClass()
            {
                Name = "Barbarian", HitDie = 12, Spellcaster = false
            };

            DndApi api = new DndApi();

            var actual = api.GetClassById(1);

            Assert.That(actual.Name, Is.EqualTo(expected.Name));
            Assert.That(actual.HitDie, Is.EqualTo(expected.HitDie));
            Assert.That(actual.Spellcaster, Is.EqualTo(expected.Spellcaster));
        }
Exemplo n.º 3
0
 public DndClass Get_ClassById(int id)
 {
     try
     {
         DndApi dndApi = new DndApi();
         return(dndApi.GetClassById(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));
     }
 }
Exemplo n.º 4
0
        public List <DndClass> Get_AllClasses()
        {
            try
            {
                List <DndClass> classes = new List <DndClass>();
                DndApi          dndApi  = new DndApi();

                Dictionary <string, int> classIdList = dndApi.GetRaceOrClassesNameIdList(false);
                foreach (int classId in classIdList.Values)
                {
                    classes.Add(dndApi.GetClassById(classId));
                }

                return(classes);
            }
            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));
            }
        }