本文整理汇总了C#中UnitOfWork.GetById方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.GetById方法的具体用法?C# UnitOfWork.GetById怎么用?C# UnitOfWork.GetById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.GetById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: if_no_events_found_then_should_throw_aggregate_not_found_exception
public void if_no_events_found_then_should_throw_aggregate_not_found_exception()
{
Guid id = Guid.NewGuid();
var mock = new MockRepository();
var eventStore = mock.Stub<IEventStore>();
Expect.Call(eventStore.GetAllEvents(id))
.Return(new List<IDomainEvent>());
mock.ReplayAll();
var unitOfWork = new UnitOfWork(eventStore);
Assert.Throws<AggregateNotFoundException>(() => unitOfWork.GetById<MockAggregate>(id));
}
示例2: should_call_load_history_on_aggregate
public void should_call_load_history_on_aggregate()
{
Guid id = Guid.NewGuid();
var events = new List<IDomainEvent>
{
new MockEvent(),
new MockEvent()
};
var mock = new MockRepository();
var eventStore = mock.Stub<IEventStore>();
Expect.Call(eventStore.GetAllEvents(id))
.Return(events);
mock.ReplayAll();
var unitOfWork = new UnitOfWork(eventStore);
var aggregate = unitOfWork.GetById<MockAggregate>(id);
aggregate.History.Count().ShouldBe(2);
}