// FIXME: Disable for now. AsAsyncEnumerable issue. //[TestMethod] public void Get_Orders() { // Arrange var orderDataService = new OrderDataService(sourceService.Object, iLoggerFactory.Object.CreateLogger <OrderDataService>()); var rnd = new Random(); var ordersQty = 40; var currDate = DateTime.UtcNow; var itms = Enumerable.Range(1, ordersQty).Select(x => new Order() { Amount = rnd.Next(x * 1000) + new Random().Next(x) / 100, DateCreated = currDate.AddDays(x) }.OrderToDbOrder()).ToList(); var idForCheck = itms[new Random().Next(ordersQty)].Id; var badIdForCheck = -10000; var firstNum = rnd.Next(ordersQty - 1); var firstDate = itms[firstNum].DateCreated; var secondNum = rnd.Next(firstNum, ordersQty); var secondDate = itms[secondNum].DateCreated; var ordersMock = TestHelper.ToDbSetMock(itms); sourceService.Setup(x => x.Orders).Returns(ordersMock.Object); sourceService.Setup(x => x.Set <DbOrder>()).Returns(ordersMock.Object); // Action var result = orderDataService.Get(null, null, null).Result; var resultId = orderDataService.Get(idForCheck, null, null).Result; var resultbadId = orderDataService.Get(badIdForCheck, null, null).Result; var resultDates = orderDataService.Get(null, firstDate, secondDate).Result; // Assert ordersMock.Verify(x => x.Where(It.IsAny <Expression <Func <Order, bool> > >()), Times.Exactly(4)); sourceService.Verify(x => x.Set <DbOrder>(), Times.Exactly(4)); Assert.AreEqual(ordersQty, result.Count); Assert.AreEqual(1, resultId.Count); Assert.AreEqual(0, resultbadId.Count); resultDates.ForEach(os => { Assert.IsTrue(os.DateCreated >= firstDate && os.DateCreated < secondDate); }); }