public void SingleResource_Verify_CanDelete()
        {
            var request = new SDataSingleResourceRequest(_service)
                          {
                              ResourceKind = "employees",
                              ResourceSelector = "1"
                          };
            _mock.Setup(s => s.ReadEntry(request)).Returns(TestData.Entry);

            request.Entry = request.Read();

            _mock.Setup(s => s.DeleteEntry(request, request.Entry)).Returns(true);

            var result = request.Delete();
            Expect(result);
        }
        public void SingleResource_Verify_CanProcess_SDataBatchRequest()
        {
            var request1 = new SDataSingleResourceRequest(_service)
                           {
                               ResourceKind = "employees",
                               ResourceSelector = "1"
                           };
            var request2 = new SDataSingleResourceRequest(_service)
                           {
                               ResourceKind = "employees",
                               ResourceSelector = "2"
                           };
            var request3 = new SDataSingleResourceRequest(_service)
                           {
                               ResourceKind = "employees",
                               ResourceSelector = "3"
                           };
            _mock.Setup(s => s.ReadEntry(request1)).Returns(TestData.Entry);
            _mock.Setup(s => s.ReadEntry(request2)).Returns(TestData.Entry);
            _mock.Setup(s => s.ReadEntry(request3)).Returns(TestData.Entry);

            request2.Entry = request2.Read();
            request3.Entry = request3.Read();

            _mock.Setup(s => s.UpdateEntry(request2, request2.Entry)).Returns(TestData.Entry);
            _mock.Setup(s => s.DeleteEntry(request3, request3.Entry)).Returns(true);

            var payload2 = request2.Entry.GetSDataPayload();
            payload2.Values["MaritalStatus"] = "Married";

            AtomFeed batchfeed;

            using (var batch = new SDataBatchRequest(_service))
            {
                batch.ResourceKind = "employees";
                request1.Read();
                request2.Update();
                request3.Delete();

                _mock.Setup(s => s.CreateFeed(batch, It.IsAny<AtomFeed>())).Returns(TestData.Feed);
                batchfeed = batch.Commit();
            }

            Expect(batchfeed, Is.Not.Null);
        }
Пример #3
0
        // Functional
        public void deleteActivity()
        {
            SDataResourceCollectionRequest collection = new SDataResourceCollectionRequest(dynamic)
            {
                ResourceKind = "activities"
            };
            var feed = collection.Read();
            // If you want to change the entry being deleted from the first one in the query to another, change the value of ElementAt(value)
            var entry = feed.Entries.ElementAt(0);
            var payload = entry.GetSDataPayload();
            var activity = payload.Values["Description"];
            var startDate = payload.Values["StartDate"];

            SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
            {
                ResourceKind = "activities",
                Entry = entry
            };
            try
            {
                request.Delete();
                Debug.WriteLine("Deleted: " + activity + " " + startDate);
            }
            catch (Exception e) { 
                Log(e.ToString(),fileName);
            }
        }
Пример #4
0
        // Functional
        public void deleteTicket()
        {
            SDataResourceCollectionRequest collection = new SDataResourceCollectionRequest(dynamic)
            {
                ResourceKind = "tickets"
            };
            var feed = collection.Read();
            // If you want to change the entry being deleted from the first one in the query to another, change the value of ElementAt(value)
            var entry = feed.Entries.ElementAt(0);
            var payload = entry.GetSDataPayload();
            var ticket = payload.Values["TicketNumber"];

            SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
            {
                ResourceKind = "tickets",
                Entry = entry
            };
            try
            {
                request.Delete();
                Debug.WriteLine("Deleted: " + ticket);
            }
            catch (Exception e) { 
                Log(e.ToString(),fileName);
            }
        }
Пример #5
0
 private void DeleteResource(SDataService ws, String resourceName, ResourceLocator resourceId)
 {
     var sru = new SDataSingleResourceRequest(ws);
     sru.ResourceKind = resourceName.ToLower() + "s";
     sru.ResourceSelector = "'" + resourceId.Id + "'";
     sru.Delete();
 }