Ejemplo n.º 1
0
        public async Task WishSearchAsync_Logs_Exceptions()
        {
            var ctx = new SearchWishContext
            {
                Provider = new Provider(),
                Wish     = new Wish()
            };

            _client.Setup(c => c.SearchAsync(ctx.Provider, ctx.Wish)).ThrowsAsync(new Exception("uh oh!"));

            var results = await _function.WishSearchAsync(ctx, _log.Object);

            _log.VerifyLoggedException("NewznabClient caused an exception");
            Assert.Empty(results);
        }
Ejemplo n.º 2
0
        public async Task WishSearchAsync_Invokes_The_NewznabClient()
        {
            var ctx = new SearchWishContext
            {
                Provider = new Provider(),
                Wish     = new Wish()
            };

            _client.Setup(c => c.SearchAsync(ctx.Provider, ctx.Wish))
            .ReturnsAsync(Enumerable.Empty <WishResult>());

            await _function.WishSearchAsync(ctx, _log.Object);

            _client.Verify(c => c.SearchAsync(ctx.Provider, ctx.Wish), Times.Once());
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <WishResult> > WishSearchAsync(
            [ActivityTrigger] SearchWishContext context,
            ILogger log)
        {
            try
            {
                var results = await _client.SearchAsync(context.Provider, context.Wish);

                foreach (var result in results)
                {
                    result.BelongsTo(context.Wish);
                }

                return(results);
            }
            catch (Exception ex)
            {
                log.LogCritical(ex, "NewznabClient caused an exception");
                return(Enumerable.Empty <WishResult>());
            }
        }
Ejemplo n.º 4
0
        public async Task WishSearchAsync_Associates_Wish_Results_To_Their_Wish()
        {
            var ctx = new SearchWishContext
            {
                Provider = new Provider(),
                Wish     = new Wish {
                    Name = "A Wish"
                }
            };

            _client.Setup(c => c.SearchAsync(ctx.Provider, ctx.Wish))
            .ReturnsAsync(new[] { new WishResult {
                                  } });

            var results = await _function.WishSearchAsync(ctx, _log.Object);

            _client.Verify(c => c.SearchAsync(ctx.Provider, ctx.Wish), Times.Once());
            Assert.All(results, r =>
            {
                Assert.Equal("A Wish", r.WishName);
                Assert.NotNull(r.RowKey);
            });
        }