Example #1
0
        private void SetUpNotificationsRepository()
        {
            _notificationsRepository.Setup(r => r.Where(It.IsAny <Expression <Func <Notification, bool> > >()))
            .Returns((Expression <Func <Notification, bool> > predicate) =>
            {
                var notifications = new TestAsyncEnumerable <Notification>(new[]
                {
                    new Notification
                    {
                        Id      = 1,
                        Icon    = "face",
                        Message = "El cliente manolo se ha registrado.",
                        State   = NotificationState.Pending,
                        Title   = "Nuevo cliente",
                        UserId  = "333-555-333"
                    },
                    new Notification
                    {
                        Id      = 1,
                        Icon    = "payments",
                        Message = "El cliente manolo ha realizado el pego de su factura.",
                        State   = NotificationState.Pending,
                        Title   = "Pago de factura",
                        UserId  = "333-555-332"
                    }
                });

                return(notifications.Where(predicate));
            });

            _notificationsRepository.Setup(r => r.FindByIdAsync(1)).ReturnsAsync(new Notification
            {
                Id      = 1,
                Icon    = "face",
                Message = "El cliente Manolo se ha registrado",
                Title   = "Registro de cliente",
                State   = NotificationState.Pending,
                UserId  = "333-555-555"
            });
            _notificationsRepository.Setup(r => r.FindByIdAsync(3)).ReturnsAsync((Notification)null);

            _notificationsRepository.Setup(r => r.Update(It.IsAny <Notification>())).Verifiable();
        }
Example #2
0
        public async void IAsyncQueryable_HowItWorks()
        {
            IQueryable <TestEntity> tests = new TestAsyncEnumerable <TestEntity>(new List <TestEntity>()
            {
                new TestEntity()
                {
                    Name = "satoshi"
                },
                new TestEntity()
                {
                    Name = "kaoru"
                }
            }.AsQueryable());

            IList <TestEntity> result = await tests.Where(t => t.Name == "satoshi").ToListAsync();

            _output.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));

            Assert.Equal("", JsonConvert.SerializeObject(result, Formatting.Indented));
        }