I have looked very closely at the screen shots in the last few storefront episodes (since Rob contracted a mild case of DDD fever). I have modeled my own application repositry very closely on the one I see in the screenshots. I have written a test which fails and I don't know how to go about fixing the problem. Any suggestions would be welcomed.
Using the SqlOrderRepository as an example I could write a test something like this
[TestMethod]
public void Order_shouldHave_Constant_Identity()
{
OrderProcessing.Order order1 = orderRepository
.GetOrders()
.Where(o=>o.OrderID == 1)
.SingleOrDefault();
OrderProcessing.Order order2 = orderRepository
.GetOrders()
.Where(o=>0.OrderID == 1)
.SingleOrDefault();
Assert.AreSame(order1, order2, "Getting the same order twice should return the same object");
}
Note that I attempt to retrieve the same OrderId both times. The Assert.AreSame fails as the two objects are not the same. This obviously opens the door to all sorts of nasty things happening.
I'm guessing that I need to introduce some kind of identity map for the domain objects but I don't know how to go about it. Any suggestions? (Hey Rob, an answer of 'Wait until after MIX, all will be revealed" would do for me)
thanks for any help