我的测试用例总是失败,告诉我哪里错了,代码如下
public class EmployeeService
{
private readonly IRepository _repository;
public EmployeeService(IRepository repository)
{
_repository = repository;
}
public bool SaveEmployeeData(Employee employee,bool isSaveNeeded)
{
bool result = false;
try
{
if (isSaveNeeded)
{
result= _repository.Save(employee);
}
}
catch (Exception ex)
{
throw new Exception();
}
return result;
}
}
我的测试用例是
[TestMethod()]
public void SaveEmployeeDataTest()
{
var a = new Mock<IRepository>();
a.Setup(s => s.Save(new Employee())).Returns(true).Verifiable();
var result = new EmployeeService(a.Object).SaveEmployeeData(new Employee(), true);
Assert.IsTrue(result);
}
它总是失败。