public async void ByName_Not_Exists() { var mock = new ServiceMockFacade <IUserRoleRepository>(); mock.RepositoryMock.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <UserRole>(null)); var service = new UserRoleService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.UserRoleModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLUserRoleMapperMock, mock.DALMapperMockFactory.DALUserRoleMapperMock); ApiUserRoleResponseModel response = await service.ByName(default(string)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.ByName(It.IsAny <string>())); }