本文整理汇总了C#中IEvent.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# IEvent.AsQueryable方法的具体用法?C# IEvent.AsQueryable怎么用?C# IEvent.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEvent
的用法示例。
在下文中一共展示了IEvent.AsQueryable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_Paginate
public void Can_Paginate()
{
// Arrange
// create the mock repository
Mock<IEventStore> mock = new Mock<IEventStore>();
var allEvents = new IEvent[]
{
new UserCreated(new UserId("[email protected]")) {Version = 1, Date = DateTime.Now},
new UserCreated(new UserId("[email protected]")) {Version = 2, Date = DateTime.Now},
new UserCreated(new UserId("[email protected]")) {Version = 3, Date = DateTime.Now},
new UserCreated(new UserId("[email protected]")) {Version = 4, Date = DateTime.Now},
new UserCreated(new UserId("[email protected]")) {Version = 5, Date = DateTime.Now}
};
mock.Setup(m => m.GetEventsForAggregate(It.IsAny<string>())).Returns(allEvents.AsQueryable());
// create instance of a controller; set the page size
EventViewerController controller = new EventViewerController(mock.Object);
controller.PageSize = 3;
// Action
EventViewerViewModel result = (EventViewerViewModel)((ViewResultBase)controller.Index("1", null, 2)).Model;
// Assert
EventViewModel[] eventArray = result.Events.ToArray();
Assert.IsTrue(eventArray.Length == 2);
Assert.AreEqual(eventArray[0].EventVersion, 4);
Assert.AreEqual(eventArray[1].EventVersion, 5);
}
示例2: Can_Get_Details
public void Can_Get_Details()
{
// Arrange
// - create the mock repository
Mock<IEventStore> mock = new Mock<IEventStore>();
var allEvents = new IEvent[]
{
new ProductAddedToOrder() {Id = new OrderId(777), Date = DateTime.Now, Version = 1},
new ProductAddedToOrder() {Id = new OrderId(777), Date = DateTime.Now, Version = 3},
new ProductAddedToOrder() {Id = new OrderId(777), Date = DateTime.Now, Version = 5}
};
mock.Setup(m => m.GetEventsForAggregate(It.IsAny<string>())).Returns(allEvents.AsQueryable());
// create instance of a controller
EventViewerController controller = new EventViewerController(mock.Object);
// Action: try to find event with Version = 3
var result = ((ViewResultBase)controller.Details("777", 3)).Model as EventDetailsViewModel;
// Assert
Assert.IsNotNull(result);
Assert.IsNotNull(result.EventDetails);
}