public async void ByName_Not_Exists() { var mock = new ServiceMockFacade <IMachineRepository>(); mock.RepositoryMock.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Machine>(null)); var service = new MachineService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.MachineModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLMachineMapperMock, mock.DALMapperMockFactory.DALMachineMapperMock); ApiMachineResponseModel response = await service.ByName(default(string)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.ByName(It.IsAny <string>())); }