public void AddDiagnosysReturnsPatientDiagnosys() { //Arrange repository.Setup(r => r.Exists(It.IsAny <object[]>())).ReturnsAsync(true); diagnosysRepository.Setup(dr => dr.Exists(It.IsAny <object[]>())).ReturnsAsync(false); diagnosysRepository.Setup(dr => dr.Post(It.IsAny <PatientDiagnosys>())).ReturnsAsync((PatientDiagnosys d) => { return(d); }); long patientId = 1; //Act var result = (controller.AddDiagnosys(patientId, new PatientDiagnosys()).Result as OkObjectResult).Value; //Assert Assert.IsInstanceOfType(result, typeof(PatientDiagnosys)); Assert.AreEqual(patientId, (result as PatientDiagnosys).PatientId); }