Esempio n. 1
0
        public void GivenAnInvalidPlayerId_ReturnsNotFound()
        {
            // Arrange
            var dto = new SetPlayerProfileRequest(TestConstants.AllOnesGuid, null, null, null);

            // Act
            var result = _controller.SetPlayerProfile(dto);

            // Assert
            Assert.IsInstanceOf <NotFoundResult>(result.Result);
        }
Esempio n. 2
0
        public ActionResult <Guid> SetPlayerProfile(SetPlayerProfileRequest request)
        {
            var player = _context.Players.Find(request.PlayerId);

            if (player is null)
            {
                return(NotFound());
            }

            player.DisplayName     = request.DisplayName;
            player.DefaultRealm    = request.DefaultRealm;
            player.DefaultTaskType = request.DefaultTaskType;

            _context.SaveChanges();

            return(player.Id);
        }
Esempio n. 3
0
        public void GivenValidProfileValues_UpdatesPlayerInDatabase(string name, TaskType?taskType, string realm)
        {
            // Arrange
            var player = new Player();

            Context.Players.Add(player);
            Context.SaveChanges();

            var dto = new SetPlayerProfileRequest(player.Id, name, taskType, realm);

            // Act
            var result = _controller.SetPlayerProfile(dto);

            // Assert
            var foundPlayer = Context.Players.Find(result.Value);

            foundPlayer.DisplayName.Should().Be(name);
            foundPlayer.DefaultTaskType.Should().Be(taskType);
            foundPlayer.DefaultRealm.Should().Be(realm);
        }