public void AtomFeedReader_Verify_CanRead() { var request = new SDataResourceCollectionRequest(_service); _mock.Setup(s => s.ReadFeed(request)).Returns(TestData.Feed); var reader = request.ExecuteReader(); Expect(reader, Is.Not.Null); }
public void AtomFeedReader_EnumeratorMatchesIndexer() { var request = new SDataResourceCollectionRequest(_service); _mock.Setup(s => s.ReadFeed(request)).Returns(TestData.Feed); var reader = request.ExecuteReader(); var i = 0; foreach (var entry in reader) { Expect(entry, Is.EqualTo(reader[i])); i++; } }
public void AtomFeedReader_IndexerMatchesCurrent() { var request = new SDataResourceCollectionRequest(_service); _mock.Setup(s => s.ReadFeed(request)).Returns(TestData.Feed); var reader = request.ExecuteReader(); for (var i = 0; i < reader.Count; i++) { Expect(i, Is.EqualTo(reader.CurrentIndex)); Expect(reader[i], Is.EqualTo(reader.Current)); reader.MoveNext(); } Expect(!reader.MoveNext()); }
public void AtomFeedReader_CurrentMatchesEnumerator() { var request = new SDataResourceCollectionRequest(_service); _mock.Setup(s => s.ReadFeed(request)).Returns(TestData.Feed); var reader = request.ExecuteReader(); var enumerator = reader.GetEnumerator(); do { enumerator.MoveNext(); Expect(reader.Current, Is.EqualTo(enumerator.Current)); } while (reader.MoveNext()); Expect(!enumerator.MoveNext()); }
private void btnReaderRead_Click(object sender, EventArgs e) { try { _sdataResourceCollectionRequest = new SDataResourceCollectionRequest(Service) { ResourceKind = tbCollectionResourceKind.Text, StartIndex = (int) numStartIndex.Value, Count = (int) numCount.Value }; _feed = null; _reader = _sdataResourceCollectionRequest.ExecuteReader(); tbReaderCount.Text = _reader.Count.ToString(); UpdateReaderGrid(); } catch (SDataClientException ex) { MessageBox.Show(ex.Message); } }
public void AtomFeedReader_MultiPageEnumerator() { var page1 = new AtomFeed(); var page2 = new AtomFeed(); using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(Resources.TestFeed))) { page1.Load(stream); stream.Seek(0, SeekOrigin.Begin); page2.Load(stream); } page1.SetOpenSearchStartIndex(1); page1.SetOpenSearchItemsPerPage(1); ((IList<AtomEntry>) page1.Entries).RemoveAt(1); page2.SetOpenSearchStartIndex(2); page2.SetOpenSearchItemsPerPage(1); ((IList<AtomEntry>) page2.Entries).RemoveAt(0); var pages = new Stack<AtomFeed>(new[] {page2, page1}); var request = new SDataResourceCollectionRequest(_service); _mock.Setup(s => s.ReadFeed(request)).Returns(pages.Pop).AtMost(2); var reader = request.ExecuteReader(); reader.ToList(); }