Skip to content

Instantly share code, notes, and snippets.

@ankitvijay

ankitvijay/OrderTests.cs

Last active May 6, 2020
Embed
What would you like to do?
DDD Example - Version 1
public class OrderTests
{
[Fact]
public void OrderItemsShouldNotBeManipulatedOutsideOrder()
{
var order = new Order();
order.AddOrderItem(new OrderItem(1, "Laptop"));
order.AddOrderItem(new OrderItem(2, "Keyboard"));
Assert.True(order.OrderItems.Count == 2);
var orderItem = new OrderItem(3, "Mouse");
var orderItems = (ICollection<OrderItem>)order.OrderItems;
orderItems.Add(orderItem);
Assert.True(order.OrderItems.Count == 2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.