这是我的课:
public class AuditInfo
{
public String ActionDescription { get; set; }
public String ActionWho { get; set; }
public BasicProjectProfile Project { get; set; }
public AuditInfo ()
{ }
public void SaveInfo ()
{
using (CIHEntities _dbContext = new CIHEntities())
{
AuditInfoEntity aie = new AuditInfoEntity();
aie.ActionDescription = this.ActionDescription;
aie.ActionWhen = DateTime.Now;
if (this.ActionWho != null)
{
aie.ActionWho = this.ActionWho;
}
else
{
aie.ActionWho = "Not Specified";
}
aie.ProjectAssoc = _dbContext.ProjectEntity
.Where(r => r.Id == this.Project.Id)
.First();
_dbContext.SaveChanges();
}
}
}
CIHEntities
是一个实体框架数据库。
我想对 SaveInfo 方法进行单元测试,但它实际上不应该保存到数据库中。如何才能做到这一点?
谢谢
埃里克