Пример #1
0
        public void ResourceProperty_Verify_CanReadFeed()
        {
            var request = new SDataResourcePropertyRequest(_service)
            {
                ResourceKind       = "employee",
                ResourceSelector   = "1",
                ResourceProperties = { "Contacts" }
            };

            _mock.Setup(s => s.ReadFeed(request)).Returns(TestData.Feed);

            var feed = request.ReadFeed();

            Expect(feed, Is.Not.Null);
        }
        private void btnPropertiesRead_Click(object sender, EventArgs e)
        {
            if (cbIsFeed.Checked)
            {
                var feed  = _sdataResourcePropertyRequest.ReadFeed();
                var table = new DataTable();
                table.Columns.Add("Author");
                table.Columns.Add("Id");
                table.Columns.Add("Title");

                // iterate through the list of entries in the feed
                foreach (var atomentry in feed.Entries)
                {
                    var dr = table.NewRow();
                    dr[0] = atomentry.Authors.Select(author => author.Name).FirstOrDefault();
                    dr[1] = atomentry.Id.Uri.AbsoluteUri;
                    dr[2] = atomentry.Title.Content;

                    table.Rows.Add(dr);
                }

                gridRPPayloads.SelectedObject = null;

                // show it in the grid
                rpGridEntries.DataSource = table;

                rpGridEntries.Refresh();
                rpGridEntries.AutoResizeColumns();
            }
            else
            {
                var entry   = _sdataResourcePropertyRequest.Read();
                var payload = entry.GetSDataPayload();

                rpGridEntries.DataSource = null;

                // show it in the grid
                gridRPPayloads.SelectedObject = payload;
            }
        }