当前位置: 首页>>代码示例>>C#>>正文


C# IEvent.AsQueryable方法代码示例

本文整理汇总了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);
        }
开发者ID:AlexSugak,项目名称:EComWithCQRS,代码行数:30,代码来源:EventViewerControllerTest.cs

示例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);
        }
开发者ID:AlexSugak,项目名称:EComWithCQRS,代码行数:25,代码来源:EventViewerControllerTest.cs


注:本文中的IEvent.AsQueryable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。