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)); }
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)); }
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)); } }
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)); } }