public async Task DeleteCollection()
        {
            var layer = GetLayer();

            InsertFrogs(layer, 10);

            var deleteBasket = new DeleteCollectionBasket <Frog, int>(
                new DeleteCollectionRequest <Frog>(new Filter <Frog>(new[]
                                                                     { new InFilterTerm(nameof(Frog.Id), new object[] { 2, 4, 6, 8 }) })));

            await layer.AddResultAsync(deleteBasket, new Visit("something", VisitDirections.Down)).ConfigureAwait(false);

            Assert.Equal(4, deleteBasket.AscentPayload);

            var getBasket = new GetCollectionBasket <Frog>(new GetCollectionRequest <Frog>());
            await layer.AddResultAsync(getBasket, new Visit("something", VisitDirections.Down)).ConfigureAwait(false);

            Assert.Equal(6, getBasket.AscentPayload.Length);
            foreach (var frog in getBasket.AscentPayload)
            {
                Assert.NotEqual(2, frog.Id);
                Assert.NotEqual(4, frog.Id);
                Assert.NotEqual(6, frog.Id);
                Assert.NotEqual(8, frog.Id);
            }
        }
        public async Task DeleteCollection()
        {
            var mine   = new FrogMine("allowed");
            var basket = new DeleteCollectionBasket <Frog, int>(new DeleteCollectionRequest <Frog>(new Filter <Frog>(new[]
            {
                new FilterTerm(nameof(Frog.Name), FilterOperators.StartsWith, "abc")
            })));

            await mine.SendAsync(basket);

            Assert.Equal(5, basket.AscentPayload);

            mine   = new FrogMine("DeleteCollection");
            basket = new DeleteCollectionBasket <Frog, int>(new DeleteCollectionRequest <Frog>(new Filter <Frog>(new[]
            {
                new FilterTerm(nameof(Frog.Name), FilterOperators.StartsWith, "abc")
            })));
            await mine.SendAsync(basket);

            Assert.Equal(5, basket.AscentPayload);

            mine   = new FrogMine("not-allowed");
            basket = new DeleteCollectionBasket <Frog, int>(new DeleteCollectionRequest <Frog>(new Filter <Frog>(new[]
            {
                new FilterTerm(nameof(Frog.Name), FilterOperators.StartsWith, "abc")
            })));
            await Assert.ThrowsAnyAsync <ShaftException>(() => mine.SendAsync(basket));
        }
Example #3
0
        public void Construct()
        {
            var filter  = new Filter <Frog>(new[] { new FilterTerm(nameof(Frog.Name), FilterOperators.StartsWith, "Fr") });
            var request = new DeleteCollectionRequest <Frog>(filter);

            Assert.Same(filter, request.Filter);

            var basket = new DeleteCollectionBasket <Frog, int>(request);

            Assert.Equal(typeof(Frog), basket.DataType);
            Assert.Same(request, basket.DescentPayload);
        }
Example #4
0
        /// <inheritdoc />
        public async Task <IActionResult> DeleteCollectionAsync(string filter)
        {
            try
            {
                var parsedFilter = new FilterParser <T>(filter).Parse();

                var basket = new DeleteCollectionBasket <T, TResult>(new DeleteCollectionRequest <T>(parsedFilter));
                await _shaft.SendAsync(basket);

                return(new OkObjectResult(basket.AscentPayload));
            }
            catch (Exception ex)
            {
                return(GetErrorResult(ex));
            }
        }
Example #5
0
        public async Task DeleteCollection()
        {
            var layer = new SalesforceLayer <MyContact>(_forceClient, new MyContactObjectDescriptor());

            var deleteBasket = new DeleteCollectionBasket <MyContact, int>(
                new DeleteCollectionRequest <MyContact>(new Filter <MyContact>(new[]
            {
                new FilterTerm(nameof(MyContact.Forename), FilterOperators.Equal, "Tim"),
            })));

            Exception exception = null;

            try
            {
                await layer.AddResultAsync(deleteBasket, new Visit("DeleteC", VisitDirections.Down))
                .ConfigureAwait(false);
            }
            catch (NotSupportedException ex)
            {
                exception = ex;
            }

            Assert.NotNull(exception);
        }