public void Delete_GivenPoco_ShouldDeletePoco() { // Arrange DB.Insert(_person); _order.PersonId = _person.Id; DB.Insert(_order); _orderLine.OrderId = _order.Id; DB.Insert(_orderLine); DB.Insert(_note); // Act DB.Delete(_orderLine); DB.Delete(_order); DB.Delete(_person); DB.Delete(_note); _person = DB.SingleOrDefault<Person>(_person.Id); _order = DB.SingleOrDefault<Order>(_order.Id); _orderLine = DB.SingleOrDefault<OrderLine>(_orderLine.Id); _note = DB.SingleOrDefault<Note>(_note.Id); // Assert _person.ShouldBeNull(); _order.ShouldBeNull(); _orderLine.ShouldBeNull(); _note.ShouldBeNull(); }
public void ShouldBe(Order other) { Id.ShouldBe(other.Id); PersonId.ShouldBe(other.PersonId); PoNumber.ShouldBe(other.PoNumber); Status.ShouldBe(other.Status); CreatedOn.ShouldBe(other.CreatedOn); CreatedBy.ShouldBe(other.CreatedBy); }
public void ShouldNotBe(Order other, bool sameIds) { if (sameIds) { Id.ShouldBe(other.Id); PersonId.ShouldBe(other.PersonId); } else { Id.ShouldNotBe(other.Id); PersonId.ShouldNotBe(other.PersonId); } PoNumber.ShouldNotBe(other.PoNumber); Status.ShouldNotBe(other.Status); CreatedOn.ShouldNotBe(other.CreatedOn); CreatedBy.ShouldNotBe(other.CreatedBy); }
private void AddOrders(int ordersToAdd) { var orderStatuses = Enum.GetValues(typeof(OrderStatus)).Cast<int>().ToArray(); var people = new List<Person>(4); for (var i = 0; i < 4; i++) { var p = new Person { Id = Guid.NewGuid(), Age = 18 + i, Dob = new DateTime(1980 - (18 + 1), 1, 1, 1, 1, 1, DateTimeKind.Utc), }; DB.Insert(p); people.Add(p); } for (var i = 0; i < ordersToAdd; i++) { var order = new Order { PoNumber = "PO" + i, Status = (OrderStatus) orderStatuses.GetValue(i%orderStatuses.Length), PersonId = people.Skip(i%4).Take(1).Single().Id, CreatedOn = new DateTime(1990 - (i%4), 1, 1, 1, 1, 1, DateTimeKind.Utc), CreatedBy = "Harry" + i }; DB.Insert(order); for (var j = 0; j < 2; j++) { DB.Insert(new OrderLine { OrderId = order.Id, Quantity = (short) j, SellPrice = 9.99m*j, Total = 9.99m*j*j }); } } }
private static void UpdateProperties(Order order) { order.PoNumber = "Feta's Order"; order.Status = OrderStatus.Pending; order.CreatedOn = new DateTime(1949, 1, 11, 4, 2, 4, DateTimeKind.Utc); order.CreatedBy = "Jen"; }