class 是否具有属性但没有逻辑单元可测试?
Is a class with properties but no logic unit testable?
我有一个 class 如下。这本身就是单元测试的候选者吗?
我可以为此编写什么样的测试/覆盖率 class?
public class Cart : ICart
{
public int Id { get; set; }
public ABCCompany Company { get; set; }
public decimal Subtotal { get; set; }
public decimal DiscountValue { get; set; }
public decimal DiscountedSubtotal{ get; set; }
public ICartDiscounts Discounts { get; set; }
public IList<ICartItem> Items { get; set; }
}
它没有逻辑可以测试所以...不;它不是真正的单元测试。
有人可能会争辩说可以测试 getter 和 setter;但是这样做真的没有意义,因为逻辑是框架提供的。
我有一个 class 如下。这本身就是单元测试的候选者吗? 我可以为此编写什么样的测试/覆盖率 class?
public class Cart : ICart
{
public int Id { get; set; }
public ABCCompany Company { get; set; }
public decimal Subtotal { get; set; }
public decimal DiscountValue { get; set; }
public decimal DiscountedSubtotal{ get; set; }
public ICartDiscounts Discounts { get; set; }
public IList<ICartItem> Items { get; set; }
}
它没有逻辑可以测试所以...不;它不是真正的单元测试。
有人可能会争辩说可以测试 getter 和 setter;但是这样做真的没有意义,因为逻辑是框架提供的。