OrderLine.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Shouldly;
  2. namespace PetaPoco.Tests.Integration.Models
  3. {
  4. [TableName("OrderLines")]
  5. [PrimaryKey("Id")]
  6. public class OrderLine
  7. {
  8. [Column]
  9. public int Id { get; set; }
  10. [Column]
  11. public int OrderId { get; set; }
  12. [Column(Name = "Qty")]
  13. public short Quantity { get; set; }
  14. [Column]
  15. public decimal SellPrice { get; set; }
  16. [Column]
  17. public OrderLineStatus Status { get; set; }
  18. [ResultColumn]
  19. public decimal Total
  20. {
  21. get { return SellPrice * Quantity; }
  22. }
  23. public void ShouldBe(OrderLine other)
  24. {
  25. Id.ShouldBe(other.Id);
  26. OrderId.ShouldBe(other.OrderId);
  27. Quantity.ShouldBe(other.Quantity);
  28. Status.ShouldBe(other.Status);
  29. SellPrice.ShouldBe(other.SellPrice);
  30. }
  31. public void ShouldNotBe(OrderLine other, bool sameIds)
  32. {
  33. if (sameIds)
  34. {
  35. Id.ShouldBe(other.Id);
  36. OrderId.ShouldBe(other.OrderId);
  37. }
  38. else
  39. {
  40. Id.ShouldNotBe(other.Id);
  41. OrderId.ShouldNotBe(other.OrderId);
  42. }
  43. Quantity.ShouldNotBe(other.Quantity);
  44. Status.ShouldNotBe(other.Status);
  45. SellPrice.ShouldNotBe(other.SellPrice);
  46. }
  47. }
  48. }