public void AddDiplomaReturnsDiploma() { //Arrange diplomaRepository.Setup(d => d.Post(It.IsAny <Diploma>())).ReturnsAsync((Diploma d) => { return(d); }); long doctorId = 1; //Act var result = (controller.AddDiplomaToDoctor(doctorId, new Diploma()).Result as OkObjectResult).Value; //Assert Assert.IsInstanceOfType(result, typeof(Diploma)); Assert.AreEqual(doctorId, (result as Diploma)?.DoctorId); }