Ejemplo n.º 1
0
        public async Task GetCollection()
        {
            var layer = new SalesforceLayer <MyContact>(_forceClient, new MyContactObjectDescriptor());

            var getBasket = new GetCollectionBasket <MyContact>(new GetCollectionRequest <MyContact>(10, 20));
            await layer.AddResultAsync(getBasket, new Visit("GetCol", VisitDirections.Down)).ConfigureAwait(false);

            Assert.True(getBasket.AscentPayload.Length == 10);
        }
Ejemplo n.º 2
0
        public async Task Patch()
        {
            var layer = new SalesforceLayer <MyContact>(_forceClient, new MyContactObjectDescriptor());

            var contact = new MyContact
            {
                Forename   = Guid.NewGuid().ToString(),
                Surname    = Guid.NewGuid().ToString(),
                Street     = Guid.NewGuid().ToString(),
                City       = "Glasgow",
                Country    = "United Kingdom",
                PostalCode = "G12AB",
                CanEmail   = true
            };

            var postBasket = new PostBasket <MyContact, string>(contact);
            await layer.AddResultAsync(postBasket, new Visit("Post", VisitDirections.Down)).ConfigureAwait(false);

            var id = postBasket.AscentPayload;

            Assert.False(string.IsNullOrWhiteSpace(id));

            var patchRequest = new PatchRequest <string, MyContact>(
                new Delta <string, MyContact>(id, new Dictionary <string, object>
            {
                { nameof(MyContact.Forename), "Jimmy" },
                { nameof(MyContact.Surname), "Riddle" }
            }));
            var patchBasket = new PatchBasket <string, MyContact, int>(patchRequest);
            await layer.AddResultAsync(patchBasket, new Visit("Patch", VisitDirections.Down)).ConfigureAwait(false);

            Assert.Equal(1, patchBasket.AscentPayload);

            var getBasket = new GetBasket <string, MyContact>(id);
            await layer.AddResultAsync(getBasket, new Visit("Get", VisitDirections.Down)).ConfigureAwait(false);

            var readContact = getBasket.AscentPayload;

            Assert.Equal(id, readContact.Id);
            Assert.Equal("Jimmy", readContact.Forename);
            Assert.Equal("Riddle", readContact.Surname);
            Assert.Equal(contact.Street, readContact.Street);
            Assert.Equal(contact.City, readContact.City);
            Assert.Equal(contact.Country, readContact.Country);
            Assert.Equal(contact.PostalCode, readContact.PostalCode);
            Assert.Equal(contact.CanMailshot, readContact.CanMailshot);
            Assert.Equal(contact.CanEmail, readContact.CanEmail);
            Assert.Equal(contact.CanPhone, readContact.CanPhone);
        }
Ejemplo n.º 3
0
        public async Task Delete()
        {
            var layer = new SalesforceLayer <MyContact>(_forceClient, new MyContactObjectDescriptor());

            var contact = new MyContact
            {
                Forename   = Guid.NewGuid().ToString(),
                Surname    = Guid.NewGuid().ToString(),
                Street     = Guid.NewGuid().ToString(),
                City       = "Glasgow",
                Country    = "United Kingdom",
                PostalCode = "G12AB",
                CanEmail   = true
            };

            var postBasket = new PostBasket <MyContact, string>(contact);
            await layer.AddResultAsync(postBasket, new Visit("Post", VisitDirections.Down)).ConfigureAwait(false);

            var id = postBasket.AscentPayload;

            Assert.False(string.IsNullOrWhiteSpace(id));

            var deleteBasket = new DeleteBasket <string, MyContact, int>(id);
            await layer.AddResultAsync(deleteBasket, new Visit("Delete", VisitDirections.Down)).ConfigureAwait(false);

            Assert.Equal(1, deleteBasket.AscentPayload);

            Exception exception = null;

            try
            {
                var getBasket = new GetBasket <string, MyContact>(id);
                await layer.AddResultAsync(getBasket, new Visit("Get", VisitDirections.Down)).ConfigureAwait(false);
            }
            catch (InvalidOperationException ex)
            {
                exception = ex;
            }

            Assert.NotNull(exception);
            Assert.Contains("Done: True, Count: 0", exception.Message);
        }
Ejemplo n.º 4
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);
        }