public void AddEmailReturnsPersonEmail() { //Arrange moq.Setup(m => m.Get(It.IsAny <object[]>())).Returns <object[]>(id => Task.FromResult(new Person { Id = (long)id[0], Emails = new List <PersonEmails>() })); moq.Setup(m => m.Put(It.IsAny <Person>())).Returns <Person>(p => Task.FromResult(p)); long personId = 1; long emailId = personId + 1; //Act var result = (controller.AddEmail(new PersonEmails { PersonId = personId, EmailId = emailId }).Result as OkObjectResult)?.Value; //Assert Assert.IsInstanceOfType(result, typeof(PersonEmails)); Assert.AreEqual(personId, (result as PersonEmails)?.PersonId); Assert.AreEqual(emailId, (result as PersonEmails)?.EmailId); }