~ubuntu-branches/debian/squeeze/gnome-do-plugins/squeeze

« back to all changes in this revision

Viewing changes to BundledLibraries/libgoogle-data-mono-1.4.0.2/src/unittests/coretest.cs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2009-05-07 21:14:41 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090507211441-i6kxltm429t90x26
Tags: 0.8.1.3+dfsg-2
* debian/patches/00_use_system_gdata.dpatch: Patch build system to use
  system copy of gdata libs, allowing Google plugins to be enabled.
* debian/patches/00_dfsg_autofoo.dpatch: Drop, now obsolete.
* debian/control: Add libgdata1.4-cil build-dep for above.
* debian/patches/10_fix_rhythmbox_file.dpatch: Add. Look in the correct place
  for the rhythmbox database (Closes: #526337).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2006 Google Inc.
 
2
 *
 
3
 * Licensed under the Apache License, Version 2.0 (the "License");
 
4
 * you may not use this file except in compliance with the License.
 
5
 * You may obtain a copy of the License at
 
6
 *
 
7
 *     http://www.apache.org/licenses/LICENSE-2.0
 
8
 *
 
9
 * Unless required by applicable law or agreed to in writing, software
 
10
 * distributed under the License is distributed on an "AS IS" BASIS,
 
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
12
 * See the License for the specific language governing permissions and
 
13
 * limitations under the License.
 
14
*/
 
15
/* Change history
 
16
* Oct 13 2008  Joe Feser       joseph.feser@gmail.com
 
17
* Removed warnings
 
18
 
19
*/
 
20
 
 
21
#define USE_TRACING
 
22
#define DEBUG
 
23
 
 
24
using System;
 
25
using System.IO;
 
26
using System.Xml; 
 
27
using System.Collections;
 
28
using System.Configuration;
 
29
using System.Net;
 
30
using System.Web;
 
31
using NUnit.Framework;
 
32
using Google.GData.Client;
 
33
using Google.GData.Extensions;
 
34
using Google.GData.Calendar;
 
35
 
 
36
 
 
37
 
 
38
 
 
39
namespace Google.GData.Client.UnitTests
 
40
{
 
41
 
 
42
 
 
43
    // dummy class to make porting autogenerated tests easier
 
44
    public class TestContext
 
45
    {
 
46
    }
 
47
 
 
48
    [TestFixture]
 
49
    public class CoreTestSuite : BaseTestClass
 
50
    {
 
51
        //////////////////////////////////////////////////////////////////////
 
52
        /// <summary>default empty constructor</summary> 
 
53
        //////////////////////////////////////////////////////////////////////
 
54
        public CoreTestSuite()
 
55
        {
 
56
        }
 
57
 
 
58
        //////////////////////////////////////////////////////////////////////
 
59
        /// <summary>[Test] public QueryObjectTest()</summary> 
 
60
        //////////////////////////////////////////////////////////////////////
 
61
        [Test] public void QueryObjectTest()
 
62
        {
 
63
            Tracing.TraceInfo("Entering QueryObject Test"); 
 
64
 
 
65
            FeedQuery query = new FeedQuery();
 
66
            query.Uri = new Uri(this.defaultHost);
 
67
 
 
68
            AtomCategory aCat = new AtomCategory("Test", new AtomUri("urn:test.com")); 
 
69
            QueryCategory qCat = new QueryCategory(aCat);
 
70
            query.Categories.Add(qCat);
 
71
 
 
72
            aCat = new AtomCategory("TestNotAndOr", new AtomUri("urn:test.com")); 
 
73
            qCat = new QueryCategory(aCat);
 
74
            qCat.Operator = QueryCategoryOperator.OR; 
 
75
            qCat.Excluded = true; 
 
76
 
 
77
            query.Categories.Add(qCat);
 
78
 
 
79
 
 
80
            aCat = new AtomCategory("ANDTHISONE", new AtomUri("")); 
 
81
            qCat = new QueryCategory(aCat);
 
82
            query.Categories.Add(qCat);
 
83
 
 
84
            aCat = new AtomCategory("AnotherOrWithoutCategory"); 
 
85
            qCat = new QueryCategory(aCat);
 
86
            qCat.Operator = QueryCategoryOperator.OR; 
 
87
            qCat.Excluded = true; 
 
88
            query.Categories.Add(qCat);
 
89
 
 
90
            query.Query = "Hospital";
 
91
            query.NumberToRetrieve = 20; 
 
92
            Tracing.TraceInfo("query: "  + query.Uri);  
 
93
 
 
94
            Uri uri =  query.Uri; 
 
95
            Tracing.TraceInfo("Uri: query= " + uri.Query); 
 
96
            query.Uri = uri; 
 
97
            Tracing.TraceInfo("Parsed Query URI: " + query.Uri); 
 
98
            Assert.IsTrue(uri.AbsolutePath.Equals(query.Uri.AbsolutePath), "both query URIs should be identical, uri: " + uri.AbsolutePath + " compared to query: " + query.Uri.AbsolutePath); 
 
99
 
 
100
            query.CategoryQueriesAsParameter = true;
 
101
 
 
102
            uri = query.Uri;
 
103
            Tracing.TraceInfo("Uri: query= " + uri.Query); 
 
104
            query.Uri = uri; 
 
105
            Tracing.TraceInfo("Parsed Query URI: " + query.Uri.AbsoluteUri); 
 
106
            Assert.IsTrue(uri.AbsolutePath.Equals(query.Uri.AbsolutePath), "both query URIs should be identical, uri: " + uri.AbsolutePath + " compared to query: " + query.Uri.AbsolutePath); 
 
107
 
 
108
        }
 
109
        /////////////////////////////////////////////////////////////////////////////
 
110
 
 
111
        //////////////////////////////////////////////////////////////////////
 
112
        /// <summary>[Test] creates a feed object from scratch</summary> 
 
113
        //////////////////////////////////////////////////////////////////////
 
114
        [Test]public void CreateFeed() 
 
115
        {
 
116
            Tracing.TraceInfo("Entering Create Feed Test"); 
 
117
            AtomFeed feed = new AtomFeed(new Uri("http://dummy"), null);
 
118
 
 
119
            AtomEntry entry; 
 
120
 
 
121
            for (int i = 1; i <= this.iIterations; i++)
 
122
            {
 
123
                entry = ObjectModelHelper.CreateAtomEntry(i);
 
124
                feed.Entries.Add(entry);
 
125
            }
 
126
 
 
127
            Tracing.TraceInfo("now persisting feed"); 
 
128
 
 
129
            ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("CreateFeed"));
 
130
 
 
131
            Tracing.TraceInfo("now loadiing feed from disk");
 
132
 
 
133
            Service service = new Service();
 
134
            service.RequestFactory = this.factory; 
 
135
 
 
136
            FeedQuery query = new FeedQuery();
 
137
            query.Uri = new Uri(CreateUriLogFileName("CreateFeed"));
 
138
 
 
139
            feed = service.Query(query);
 
140
 
 
141
            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
 
142
            Assert.AreEqual(this.iIterations, feed.Entries.Count, "Feed.Entries should have 50 elements");
 
143
            if (feed.Entries != null)
 
144
            {
 
145
                for (int i = 1; i <= this.iIterations; i++)
 
146
                {
 
147
                    entry = ObjectModelHelper.CreateAtomEntry(i);
 
148
                    AtomEntry theOtherEntry = feed.Entries[i-1];
 
149
                    Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry));
 
150
                }
 
151
            }
 
152
        }
 
153
        /////////////////////////////////////////////////////////////////////////////
 
154
 
 
155
        //////////////////////////////////////////////////////////////////////
 
156
        /// <summary>[Test] creates a new entry, saves and loads it back</summary> 
 
157
        //////////////////////////////////////////////////////////////////////
 
158
        [Test] public void CreateEntrySaveAndLoad()
 
159
        {
 
160
 
 
161
            Tracing.TraceMsg("Entering Create/Save/Load test");
 
162
 
 
163
            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);
 
164
 
 
165
            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateEntrySaveAndLoad"));
 
166
 
 
167
 
 
168
            // let's try loading this... 
 
169
            Service service = new Service();
 
170
            service.RequestFactory = this.factory; 
 
171
 
 
172
            FeedQuery query = new FeedQuery();
 
173
            query.Uri = new Uri(CreateUriLogFileName("CreateEntrySaveAndLoad"));
 
174
            AtomFeed feed = service.Query(query);
 
175
            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
 
176
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");
 
177
            // that feed should have ONE entry
 
178
            if (feed.Entries != null)
 
179
            {
 
180
                AtomEntry theOtherEntry = feed.Entries[0];
 
181
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry));
 
182
            }
 
183
 
 
184
        }
 
185
        /////////////////////////////////////////////////////////////////////////////
 
186
 
 
187
        //////////////////////////////////////////////////////////////////////
 
188
        /// <summary>[Test] Creates a feedquery and checks if the SSL translation works</summary> 
 
189
        //////////////////////////////////////////////////////////////////////
 
190
        [Test] public void QuerySSLTest()
 
191
        {
 
192
 
 
193
            Tracing.TraceMsg("Entering QuerySSLTest test");
 
194
 
 
195
            FeedQuery query = new FeedQuery();
 
196
            query.Uri = new Uri("http://www.google.com/");
 
197
            Assert.AreEqual("http://www.google.com/", query.Uri.ToString(), "both uris should be http now");
 
198
            query.UseSSL = true;
 
199
            Assert.AreEqual("https://www.google.com/", query.Uri.ToString(), "both uris should be https now");
 
200
            query.UseSSL = false;
 
201
            Assert.AreEqual("http://www.google.com/", query.Uri.ToString(), "both uris should be http now");
 
202
 
 
203
            // now construct the other way round
 
204
 
 
205
            query = new FeedQuery();
 
206
            query.Uri = new Uri("https://www.google.com/");
 
207
 
 
208
            Assert.IsTrue(query.UseSSL, "Use SSL should be true due to detection of the https string");
 
209
 
 
210
            Assert.AreEqual("https://www.google.com/", query.Uri.ToString(), "both uris should be https now");
 
211
            query.UseSSL = false;
 
212
            Assert.AreEqual("http://www.google.com/", query.Uri.ToString(), "both uris should be http now");
 
213
            query.UseSSL = true;
 
214
            Assert.AreEqual("https://www.google.com/", query.Uri.ToString(), "both uris should be https now");
 
215
        }
 
216
        /////////////////////////////////////////////////////////////////////////////
 
217
 
 
218
 
 
219
      
 
220
 
 
221
        //////////////////////////////////////////////////////////////////////
 
222
        /// <summary>[Test] creates a new entry, saves and loads it back
 
223
        ///   uses HTML content to test the persistence/encoding code
 
224
        /// </summary> 
 
225
        //////////////////////////////////////////////////////////////////////
 
226
        [Test] public void CreateHTMLEntrySaveAndLoad()
 
227
        {
 
228
 
 
229
            Tracing.TraceMsg("Entering CreateHTMLEntrySaveAndLoad");
 
230
 
 
231
            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);
 
232
            entry.Content.Type = "html"; 
 
233
            entry.Content.Content = HttpUtility.HtmlDecode("<b>this is a &lt;test&gt;</b>"); 
 
234
 
 
235
            Tracing.TraceMsg("Content: " + entry.Content.Content);
 
236
 
 
237
            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateHTMLEntrySaveAndLoad"));
 
238
 
 
239
 
 
240
            // let's try loading this... 
 
241
            Service service = new Service();
 
242
            service.RequestFactory = this.factory; 
 
243
 
 
244
            FeedQuery query = new FeedQuery();
 
245
            query.Uri = new Uri(CreateUriLogFileName("CreateHTMLEntrySaveAndLoad"));
 
246
            AtomFeed feed = service.Query(query);
 
247
            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
 
248
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");
 
249
            // that feed should have ONE entry
 
250
            if (feed.Entries != null)
 
251
            {
 
252
                AtomEntry theOtherEntry = feed.Entries[0];
 
253
                Tracing.TraceMsg("Loaded Content: " + theOtherEntry.Content.Content);
 
254
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry));
 
255
            }
 
256
 
 
257
        }
 
258
        /////////////////////////////////////////////////////////////////////////////
 
259
 
 
260
        //////////////////////////////////////////////////////////////////////
 
261
        /// <summary>[Test] creates a new entry, saves and loads it back
 
262
        ///   uses XHTML content to test the persistence/encoding code
 
263
        /// </summary> 
 
264
        //////////////////////////////////////////////////////////////////////
 
265
        [Test] public void CreateXHTMLEntrySaveAndLoad()
 
266
        {
 
267
 
 
268
            Tracing.TraceMsg("Entering CreateXHTMLEntrySaveAndLoad");
 
269
 
 
270
            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);
 
271
            entry.Content.Type = "xhtml"; 
 
272
            entry.Content.Content = HttpUtility.HtmlDecode("<div xmlns=\"http://www.w3.org/2005/Atom\"><b>this is a test</b></div>"); 
 
273
 
 
274
            Tracing.TraceMsg("Content: " + entry.Content.Content);
 
275
 
 
276
            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateXHTMLEntrySaveAndLoad"));
 
277
 
 
278
            Tracing.TraceMsg("saved in... CreateXHTMLEntrySaveAndLoad");
 
279
 
 
280
 
 
281
            // let's try loading this... 
 
282
            Service service = new Service();
 
283
            service.RequestFactory = this.factory; 
 
284
 
 
285
            FeedQuery query = new FeedQuery();
 
286
            query.Uri = new Uri(CreateUriLogFileName("CreateXHTMLEntrySaveAndLoad"));
 
287
            AtomFeed feed = service.Query(query);
 
288
 
 
289
            Tracing.TraceMsg("loaded in... CreateXHTMLEntrySaveAndLoad");
 
290
 
 
291
            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
 
292
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");
 
293
 
 
294
 
 
295
            // that feed should have ONE entry
 
296
            if (feed.Entries != null)
 
297
            {
 
298
                Tracing.TraceMsg("checking entries... CreateXHTMLEntrySaveAndLoad");
 
299
                AtomEntry theOtherEntry = feed.Entries[0];
 
300
 
 
301
                Assert.IsTrue(theOtherEntry.Content != null, "the entry should have a content element");
 
302
                Assert.IsTrue(theOtherEntry.Content.Type.Equals("xhtml"), "the entry should have a content element of type xhtml");
 
303
                Assert.IsTrue(theOtherEntry.Content.Content != null, "the entry should have a content element that is not empty");
 
304
 
 
305
                Tracing.TraceMsg("Loaded Content: " + theOtherEntry.Content.Content);
 
306
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry));
 
307
                Tracing.TraceMsg("done comparing entries... CreateXHTMLEntrySaveAndLoad");
 
308
            }
 
309
 
 
310
        }
 
311
        /////////////////////////////////////////////////////////////////////////////
 
312
 
 
313
 
 
314
        ////////////////////////////////////////////////////////////////////
 
315
        /// <summary>[Test] creates a new feed, saves and loads it back</summary> 
 
316
        //////////////////////////////////////////////////////////////////////
 
317
        [Test] public void CreateFeedObjectSaveAndLoad()
 
318
        {
 
319
 
 
320
            Tracing.TraceMsg("Entering CreateFeedObjectSaveAndLoad test");
 
321
 
 
322
            Service service = new Service(); 
 
323
            AtomFeed feed=new AtomFeed(new Uri("http://www.atomfeed.com/"),service);
 
324
            feed.Self="http://www.atomfeed.com/self";
 
325
            feed.Feed="http://www.atomfeed.com/feed";
 
326
            feed.NextChunk="http://www.atomfeed.com/next";
 
327
            feed.PrevChunk="http://www.atomfeed.com/prev";
 
328
            feed.Post = "http://www.atomfeed.com/post"; 
 
329
 
 
330
            ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("CreateFeedSaveAndLoad"));
 
331
 
 
332
 
 
333
            // let's try loading this... 
 
334
            service.RequestFactory = this.factory; 
 
335
 
 
336
            FeedQuery query = new FeedQuery();
 
337
            query.Uri = new Uri(CreateUriLogFileName("CreateFeedSaveAndLoad"));
 
338
 
 
339
            feed = service.Query(query);
 
340
 
 
341
 
 
342
            Assert.AreEqual("http://www.atomfeed.com/self", feed.Self, "Feed.Self is not correct");
 
343
            Assert.AreEqual("http://www.atomfeed.com/feed", feed.Feed, "Feed.Feed is not correct");
 
344
            Assert.AreEqual("http://www.atomfeed.com/next", feed.NextChunk, "Feed.Next is not correct");
 
345
            Assert.AreEqual("http://www.atomfeed.com/prev", feed.PrevChunk, "Feed.Prev is not correct");
 
346
            Assert.AreEqual("http://www.atomfeed.com/post", feed.Post, "Feed.Post is not correct");
 
347
 
 
348
        }
 
349
        /////////////////////////////////////////////////////////////////////////////
 
350
 
 
351
        
 
352
 
 
353
 
 
354
        ////////////////////////////////////////////////////////////////////
 
355
        /// <summary>[Test] creates a new entry, saves and loads it back</summary> 
 
356
        //////////////////////////////////////////////////////////////////////
 
357
        [Test] public void CreateEmptyEntrySaveAndLoad()
 
358
        {
 
359
 
 
360
            Tracing.TraceMsg("Entering Create/Save/Load test");
 
361
 
 
362
            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);
 
363
 
 
364
            entry.Content.Type = "text";
 
365
            entry.Content.Content = ""; 
 
366
 
 
367
            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateEmptyEntrySaveAndLoad"));
 
368
 
 
369
 
 
370
            // let's try loading this... 
 
371
            Service service = new Service();
 
372
            service.RequestFactory = this.factory; 
 
373
 
 
374
            FeedQuery query = new FeedQuery();
 
375
            query.Uri = new Uri(CreateUriLogFileName("CreateEmptyEntrySaveAndLoad"));
 
376
            AtomFeed feed = service.Query(query);
 
377
            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
 
378
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");
 
379
            // that feed should have ONE entry
 
380
            if (feed.Entries != null)
 
381
            {
 
382
                AtomEntry theOtherEntry = feed.Entries[0];
 
383
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry), "Entries should be identical");
 
384
            }
 
385
 
 
386
        }
 
387
        /////////////////////////////////////////////////////////////////////////////
 
388
 
 
389
        //////////////////////////////////////////////////////////////////////
 
390
        /// <summary>[Test] queries the remote feed, saves it, loads it and compares it</summary> 
 
391
        /// <param name="uriToQuery">the host to access, including query parameters</param>
 
392
        //////////////////////////////////////////////////////////////////////
 
393
        internal void RemoteHostQueryAndCompare(Uri uriToQuery)
 
394
        {
 
395
 
 
396
            Tracing.TraceMsg("Entering RemoteHostQueryAndCompare");
 
397
 
 
398
            int iCount = 0; 
 
399
            FeedQuery query = new FeedQuery();
 
400
            query.Uri = uriToQuery; 
 
401
 
 
402
            Service service = new Service();
 
403
            service.RequestFactory = this.factory; 
 
404
 
 
405
            AtomFeed f = service.Query(query);
 
406
 
 
407
            ObjectModelHelper.DumpAtomObject(f, CreateDumpFileName("QueryRemoteHost"));
 
408
 
 
409
            iCount = f.Entries.Count;
 
410
 
 
411
            // let's try loading this... 
 
412
            Service service2 = new Service();
 
413
            FeedQuery query2 = new FeedQuery();
 
414
            query2.Uri = new Uri(CreateUriLogFileName("QueryRemoteHost"));
 
415
 
 
416
            AtomFeed feed = service2.Query(query2);
 
417
            Assert.AreEqual(iCount, feed.Entries.Count, "loaded feed has different number of entries");
 
418
 
 
419
 
 
420
            Tracing.TraceInfo("Comparing feed objects as source"); 
 
421
            Assert.IsTrue(ObjectModelHelper.IsSourceIdentical(f, feed), "Feeds are not identical"); 
 
422
            if (feed.Entries != null)
 
423
            {
 
424
                AtomEntry theOtherEntry;
 
425
 
 
426
                Tracing.TraceInfo("Comparing Entries"); 
 
427
                for (int i = 0; i < feed.Entries.Count; i++)
 
428
                {
 
429
                    theOtherEntry = feed.Entries[i];
 
430
                    Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(f.Entries[i], theOtherEntry), "Entries are not identical");
 
431
                }
 
432
 
 
433
            }
 
434
 
 
435
            Tracing.TraceInfo("Leaving RemoteHostQueryAndCompare for : " + uriToQuery.AbsoluteUri); 
 
436
 
 
437
        }
 
438
        /////////////////////////////////////////////////////////////////////////////
 
439
 
 
440
 
 
441
 
 
442
        //////////////////////////////////////////////////////////////////////
 
443
        /// <summary>[Test] walks over the list of remotehosts out of the 
 
444
        /// unitTestExternalHosts
 
445
        /// add key="Host1" value="http://www.franklinmint.fm/2005/09/26/test_entry2.xml" 
 
446
        /// section in the config file and queries and compares the object model
 
447
        /// </summary> 
 
448
        //////////////////////////////////////////////////////////////////////
 
449
        [Test] public void RemoteHostQueryTest()
 
450
        {
 
451
            Tracing.TraceInfo("Entering RemoteHostQueryTest()"); 
 
452
            if (this.externalHosts != null)
 
453
            {
 
454
                for (int i=0; i< this.iIterations; i++) 
 
455
                {
 
456
                    Tracing.TraceInfo("Having a dictionary RemoteHostQueryTest()"); 
 
457
                    foreach (DictionaryEntry de in this.externalHosts )
 
458
                    {
 
459
                        Tracing.TraceInfo("Using DictionaryEntry for external Query: " + de.Value); 
 
460
                        Uri uriToQuery = new Uri((string) de.Value); 
 
461
                        RemoteHostQueryAndCompare(uriToQuery); 
 
462
    
 
463
                    }
 
464
                }
 
465
            }
 
466
        }
 
467
        /////////////////////////////////////////////////////////////////////////////
 
468
 
 
469
 
 
470
        //////////////////////////////////////////////////////////////////////
 
471
        /// <summary>creates a number or rows and delets them again</summary> 
 
472
        //////////////////////////////////////////////////////////////////////
 
473
        [Test] public void DefaultHostExtensionTest()
 
474
        {
 
475
            Tracing.TraceMsg("Entering DefaultHostExtensionTest");
 
476
 
 
477
            if (this.strRemoteHost != null) 
 
478
            {
 
479
 
 
480
                FeedQuery query = new FeedQuery();
 
481
                Service service = new Service();
 
482
 
 
483
                service.NewAtomEntry += new FeedParserEventHandler(this.OnParsedNewEntry); 
 
484
                service.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewExtensionElement);
 
485
 
 
486
 
 
487
                service.RequestFactory  =  (IGDataRequestFactory) new GDataLoggingRequestFactory(this.ServiceName, this.ApplicationName); 
 
488
 
 
489
                query.Uri = new Uri(this.strRemoteHost);
 
490
 
 
491
                AtomFeed returnFeed = service.Query(query);
 
492
 
 
493
                ObjectModelHelper.DumpAtomObject(returnFeed,CreateDumpFileName("ExtensionFeed")); 
 
494
            }
 
495
        }
 
496
        /////////////////////////////////////////////////////////////////////////////
 
497
 
 
498
        //////////////////////////////////////////////////////////////////////
 
499
        /// <summary>tests the tokenizer collection</summary> 
 
500
        //////////////////////////////////////////////////////////////////////
 
501
        [Test] public void TestTokenCollection() 
 
502
        {
 
503
            Tracing.TraceMsg("Entering TestTokenCollection");
 
504
            String toTest = "Test=Test?other=whatever\nTest2=Line2?other=whatishere";
 
505
 
 
506
            TokenCollection tokens = new TokenCollection(toTest, new char[] {'\n', '='});
 
507
            TokenCollection tokenSmart = new TokenCollection(toTest, '=', true, 2);
 
508
 
 
509
            int iTokens = 0;
 
510
            foreach (string token in tokens)
 
511
            {
 
512
                // tokens should have 5 tokens, as the = signs split into 5
 
513
                iTokens++;
 
514
                if (iTokens == 1)
 
515
                {
 
516
                    Assert.IsTrue(token.Equals("Test"), "The first token should be Test, but it is: " + token);
 
517
                }
 
518
                if (iTokens == 4)
 
519
                {
 
520
                    Assert.IsTrue(token.Equals("Test2"), "The fourth token should be Test2 but it is: " + token);
 
521
                }
 
522
            }
 
523
 
 
524
            iTokens = 0;
 
525
            foreach (string token in tokenSmart)
 
526
            {
 
527
                // tokens should have 5 tokens, as the = signs split into 5
 
528
                iTokens++;
 
529
                if (iTokens == 1)
 
530
                {
 
531
                    Assert.IsTrue(token.Equals("Test"), "The first smart token should be Test, but it is: " + token);
 
532
                }
 
533
                if (iTokens == 4)
 
534
                {
 
535
                    Assert.IsTrue(token.Equals("Line2?other=whatishere"), "The fourth smart token should be whatishere, but it is: " + token);
 
536
                }
 
537
            }
 
538
        }
 
539
 
 
540
        //////////////////////////////////////////////////////////////////////
 
541
        /// <summary>checks if the feedquery object is stable</summary> 
 
542
        //////////////////////////////////////////////////////////////////////
 
543
        [Test]
 
544
        public void TestFeedQuery()
 
545
        {
 
546
            Tracing.TraceMsg("Entering DefaultHostExtensionTest");
 
547
 
 
548
            try
 
549
            {
 
550
                FeedQuery query = new FeedQuery();
 
551
                query.NumberToRetrieve = 20;
 
552
                Uri u = query.Uri;
 
553
 
 
554
            }
 
555
            catch (UriFormatException)
 
556
            {
 
557
                // ignore this.
 
558
            }
 
559
            catch (Exception)
 
560
            {
 
561
                Assert.Fail("That should not have crashed");
 
562
            }
 
563
 
 
564
        }
 
565
        /////////////////////////////////////////////////////////////////////////////
 
566
 
 
567
 
 
568
    } /// end of CoreTestSuite
 
569
}
 
570
 
 
571
 
 
572
 
 
573