Exemplo n.º 1
0
        public async Task GetAssignmentByIdAsync_ReturnsAssignment_WhenAssignmentExists()
        {
            // Arrange
            var assignmentId  = Guid.NewGuid();
            var assignmentDto = new AssignmentDto {
                Id = assignmentId, Name = "Assignment"
            };

            _stubAssignmentService.Setup(x => x.GetAssignmentByIdAsync(assignmentId))
            .ReturnsAsync(assignmentDto);

            // Act
            var actionResult = await _assignmentsController.GetAssignmentByIdAsync(assignmentId);

            var result     = actionResult.Result as OkObjectResult;
            var assignment = result.Value as AssignmentDto;

            // Assert
            Assert.AreEqual(assignmentId, assignment.Id);
        }