public async void SavePersonAsync_with_valid_id_should_return_a_Person() { // Setup Guid personId = Guid.NewGuid(); _savePersonComponent.Setup(x => x.SavePersonAsync(It.IsAny <Library.Entities.Person>())).Returns(Task.FromResult(Dummies.GetDummiePerson(DummieInstance.ValidInstance))); // Act var result = await _savePersonComponent.Object.SavePersonAsync(Dummies.GetDummiePerson(DummieInstance.ValidInstance)); var expectedType = typeof(Library.Entities.Person); // TODO: Should be a Task return var actualType = result.GetType(); //Assert Assert.True(expectedType.Equals(actualType)); }
public async Task GetPersonByIdAsync_Should_return_StatusCodeResult_204_when_no_person_found() { // Setup Guid personId = Guid.NewGuid(); _getPersonComponent.Setup(x => x.GetPersonByIdAsync(It.IsAny <Guid>())).Returns(Task.FromResult(Dummies.GetDummiePerson(Dummies.DummieInstance.NullObject))); // Act var result = await personController.GetPersonByIdAsync(personId); var expectedType = new StatusCodeResult(204).GetType(); var actualType = result.GetType(); //Assert Assert.True(expectedType.Equals(actualType)); //Check if the execute was called at least once on the controller method _getPersonComponent.Verify(x => x.GetPersonByIdAsync(personId), Times.Once); }
public async Task SavePersonAsync_Should_Return_OkObjectResult_when_save_successfull() { //Setup _savePersonComponent.Setup(x => x.SavePersonAsync(It.IsAny <Person>())).Returns(Task.FromResult(Dummies.GetDummiePerson(DummieInstance.NewInstance))); _getPersonComponent.Setup(x => x.GetPersonByIdAsync(It.IsAny <Guid>())).Returns(Task.FromResult(Dummies.GetDummiePerson(DummieInstance.NewInstance))); //Act var result = await personController.SavePersonAsync(Dummies.GetDummiePersonModel(DummieInstance.NewInstance)); var expectedType = new OkObjectResult(result).GetType(); var actualType = result.GetType(); //Assert Assert.True(expectedType.Equals(actualType)); //Check if the execute was called at least once on the controller method _savePersonComponent.Verify(x => x.SavePersonAsync(It.IsAny <Person>()), Times.Once); _getPersonComponent.Verify(x => x.GetPersonByIdAsync(It.IsAny <Guid>()), Times.Once); }