public void GivenAnInvalidTask_ReturnsNotFound() { // Arrange var dto = new SetTaskCollectibleTypeAndSourceRequest(TestConstants.AllOnesGuid, CollectibleType.Item, Source.Dungeon); // Act var result = _controller.SetTaskCollectibleTypeAndSource(dto); // Assert Assert.IsInstanceOf <NotFoundResult>(result.Result); }
public ActionResult <Guid> SetTaskCollectibleTypeAndSource(SetTaskCollectibleTypeAndSourceRequest request) { var task = _context.Tasks.Find(request.TaskId); if (task is null) { return(NotFound()); } task.CollectibleType = request.CollectibleType; task.Source = request.Source; _context.SaveChanges(); return(task.Id); }
public void GivenAValidTask_AndValidProperties_UpdatesTaskInDatabase() { // Arrange var task = new Task(DefaultPlayer.Id, TaskType.Collectible); Context.Tasks.Add(task); Context.SaveChanges(); var dto = new SetTaskCollectibleTypeAndSourceRequest(task.Id, CollectibleType.Item, Source.Dungeon); // Act var result = _controller.SetTaskCollectibleTypeAndSource(dto); var foundTask = Context.Tasks.Find(result.Value); // Assert foundTask.Should().NotBeNull(); foundTask.CollectibleType.Should().Be(dto.CollectibleType); foundTask.Source.Should().Be(dto.Source); }