public Monster(MonsterResponse monster) { this.Name = monster.Name; this.Exp = monster.Exp; this.HP = monster.HP; this.MovementSpeed = monster.MovementSpeed; this.SeeingInvisible = monster.SeeingInvisible; this.ImageLink = monster.ImageLink; }
public ServiceResponse <MonsterResponse> ReadById(int id) { MonsterResponse monster; using (MonstersContext db = new MonstersContext()) { if (!db.Monsters.Any(x => x.Id == id)) { return(new ServiceResponse <MonsterResponse>(null, HttpStatusCode.NotFound, "There is not existing monster with given id!")); } monster = new MonsterResponse(db.Monsters.FirstOrDefault(x => x.Id == id)); } return(new ServiceResponse <MonsterResponse>(monster, HttpStatusCode.OK, "Monster downloaded!")); }
public async Task PostCreateMonsterAsync_ShouldCreateMonster_ThenReturnMonsterResponse() { const int groupId = 8; var createMonsterRequest = new CreateMonsterRequest(); var createdMonster = new Monster(); var monsterResponse = new MonsterResponse(); _monsterService.CreateMonsterAsync(_executionContext, groupId, createMonsterRequest) .Returns(createdMonster); _mapper.Map <MonsterResponse>(createdMonster) .Returns(monsterResponse); var result = await _controller.PostCreateMonsterAsync(_executionContext, groupId, createMonsterRequest); result.Value.Should().BeSameAs(monsterResponse); result.StatusCode.Should().Be(StatusCodes.Status201Created); }
public MonsterController(IWARepository repo) { this.repo = repo; this.response = new MonsterResponse(); }