public async Task GetByIdAsync_ShouldReturnPatient_WhenExist() { // Arrange int r = new Random().Next(); _mediator.Send(Arg.Any <GetPatientById.Query>()) .Returns(new GetPatientById.Response(new PatientDto { Id = r, FamilyName = "Blazor" })); // Act var actionResult = await _sut.GetByIdAsync(r); // Assert if (actionResult.Result is OkObjectResult result) { result.StatusCode.Should().Be(200); if (result.Value is PatientDto value) { value.Id.Should().Be(r); value.FamilyName.Should().Be("Blazor"); } } }