示例#1
0
        public async Task AddWishAsync_Returns_Unprocessable_When_An_Exception_Is_Thrown()
        {
            var req = TestHelper.CreateHttpRequest(new
            {
                name  = "new wish",
                query = "new.wish"
            });

            _table.SetupOperationToThrow();
            _authService.Setup(s => s.IsAuthenticated(req)).ReturnsAsync(true);

            var resp = await _function.AddWishAsync(req, _table.Object, _log.Object);

            _log.VerifyLoggedException("Add-Wish caused an exception");
            Assert.IsType <UnprocessableEntityObjectResult>(resp);
        }
示例#2
0
        public async Task AddProviderAsync_Returns_Unprocessable_When_Exceptions_Are_Thrown()
        {
            var req = TestHelper.CreateHttpRequest(new
            {
                name   = "Provider",
                apiKey = "abc-123",
                apiUrl = "https://no.where"
            });

            _table.SetupOperationToThrow();
            _authService.Setup(s => s.IsAuthenticated(req)).ReturnsAsync(true);

            var resp = await _function.AddProviderAsync(req, _table.Object, _log.Object);

            _log.VerifyLoggedException("Add-Provider caused an exception");
            Assert.IsType <UnprocessableEntityObjectResult>(resp);
        }
示例#3
0
        public async Task AddToCartAsync_Returns_Unprocessable_When_Exceptions_Are_Thrown()
        {
            var req = TestHelper.CreateHttpRequest("https://nzb.mtighe.dev/api/cart/add/123");

            _authService.Setup(s => s.IsAuthenticated(req)).ReturnsAsync(true);
            var wishTable = new MockCloudTable();

            wishTable.SetupOperationToThrow();

            var result = await _function.AddToCartAsync(req, wishTable.Object, _cartTable.Object, _log.Object, "123");

            _log.VerifyLoggedException("Cart-Add caused an exception");
            Assert.IsType <UnprocessableEntityObjectResult>(result);
        }
示例#4
0
        public async Task GrabNzbFromCartAsync_Returns_ServerError_When_An_Exception_Is_Thrown()
        {
            var req = TestHelper.CreateHttpRequest("https://nzb.mtighe.dev/api/cart/nzb/123");

            _authService.Setup(s => s.IsAuthenticated(req)).ReturnsAsync(true);
            _cartTable.SetupOperationToThrow();

            var result = await _function.GrabNzbFromCartAsync(req, _cartTable.Object, _log.Object, "123");

            _log.VerifyLoggedException("Cart-Grab caused an exception");
            var objResult = Assert.IsType <ObjectResult>(result);

            Assert.Equal(500, objResult.StatusCode);
        }