~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/gapps/mailitementrytest.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-06-27 16:11:49 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090627161149-b74nc297di2842u1
* New upstream release
  + Pidgin plugin now supports initial text for messages (LP: #338608)
  + Pidgin plugin opens conversations on the correct IM network (LP: #370965)
* debian/rules:
  + Update get-orig-source target.  Upstream no longer ships gdata* binaries,
    so we no longer need to strip them
* debian/patches/00_use_system_gdata
  + Drop.  Upstream now builds against system libgdata.
* debian/patches/04_fix_pidgin_dbus_ints
* debian/patches/10_fix_rhythmbox_file
* debian/patches/15_twitter_api
* debian/patches/20_twitter_overflow:
  + Drop.  Included upstream.
* debian/patches/01_firefox_iceweasel_rename:
  + Refresh for new version
* debian/patches/02_fix_banshee_plugin:
  + Drop refernce to /usr/lib/banshee-1/Banshee.CollectionIndexer.dll.
    This is unnecessary, and causes errors when Banshee isn't installed.
* debian/patches/00_debian_default_plugins:
  + Enable a bunch of useful plugins that do not require configuration from 
    the "Official" plugin set by default.  Makes Do more useful out of the 
    box.
* debian/control:
  + Bump versioned build-dep on gnome-do to 0.8.2
  + Split out gnome-do-plugin-evolution package, now that this is possible.
    libevolution5.0-cil has an annoyingly large dependency stack.
    (LP: #351535) (Closes: #524993).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2007 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
 
 
16
 
using Google.GData.Apps;
17
 
using Google.GData.Apps.Migration;
18
 
using Google.GData.Client;
19
 
using Google.GData.Extensions;
20
 
using Google.GData.Extensions.Apps;
21
 
using System;
22
 
using System.Text;
23
 
using System.IO;
24
 
using System.Xml;
25
 
using NUnit.Framework;
26
 
 
27
 
namespace Google.GData.Apps.UnitTests
28
 
{
29
 
    [TestFixture]
30
 
    [Category("GoogleApps")]
31
 
    public class MailItemEntryTest
32
 
    {
33
 
        private MailItemEntry entry;
34
 
 
35
 
        [SetUp]
36
 
        public void Init()
37
 
        {
38
 
            entry = new MailItemEntry();
39
 
        }
40
 
 
41
 
        [TearDown]
42
 
        public void Dispose()
43
 
        {
44
 
 
45
 
        }
46
 
 
47
 
        [Test]
48
 
        public void GetRfc822MsgTest()
49
 
        {
50
 
            Assert.IsNull(entry.Rfc822Msg, "Rfc822Msg should initially be null after construction");
51
 
        }
52
 
 
53
 
        [Test]
54
 
        public void SetRfc822MsgTest()
55
 
        {
56
 
            entry.Rfc822Msg = new Rfc822MsgElement("Hi");
57
 
 
58
 
            Assert.IsNotNull(entry.Rfc822Msg, "Rfc822Msg should not be null after setting");
59
 
            Assert.AreEqual("Hi", entry.Rfc822Msg.ToString(),
60
 
                "Entry's Rfc822Msg does not have correct value after setting");
61
 
        }
62
 
 
63
 
        [Test]
64
 
        public void GetLabelsTest()
65
 
        {
66
 
            Assert.IsNotNull(entry.Labels, "Labels should initially not be null after construction");
67
 
        }
68
 
 
69
 
        [Test]
70
 
        public void AddLabelTest()
71
 
        {
72
 
            LabelElement label = new LabelElement("Friends");
73
 
            entry.Labels.Add(label);
74
 
 
75
 
            Assert.AreEqual(1, entry.Labels.Count, "Entry's label collection should have size 1 after insertion");
76
 
            Assert.IsTrue(entry.Labels.Contains(label), "Entry's label collection does not contain label after insertion");
77
 
        }
78
 
 
79
 
        [Test]
80
 
        public void GetMailItemPropertiesTest()
81
 
        {
82
 
            Assert.IsNotNull(entry.MailItemProperties,
83
 
                "MailItemProperties should initially not be null after construction");
84
 
        }
85
 
 
86
 
        [Test]
87
 
        public void AddMailItemPropertiesTest()
88
 
        {
89
 
            entry.MailItemProperties.Add(MailItemPropertyElement.INBOX);
90
 
 
91
 
            Assert.AreEqual(1, entry.MailItemProperties.Count,
92
 
                "Entry's mail item property collection should have size 1 after insertion");
93
 
            Assert.IsTrue(entry.MailItemProperties.Contains(MailItemPropertyElement.INBOX),
94
 
                "Entry's mail item property collection does not contain INBOX property after insertion");
95
 
        }
96
 
 
97
 
        [Test]
98
 
        public void ParseXmlTest()
99
 
        {
100
 
            string xmlElementText = "<entry xmlns=\"http://www.w3.org/2005/Atom\" " +
101
 
                "xmlns:gd=\"http://schemas.google.com/g/2005\">" + Rfc822MsgTest.xmlElementAsText +
102
 
                LabelTest.xmlElementAsText + LabelTest.xmlElementAsText.Replace("Friends", "Acquaintances") +
103
 
                MailItemPropertyTest.xmlElementAsText +
104
 
                MailItemPropertyTest.xmlElementAsText.Replace("SENT", "STARRED") +
105
 
                "<gd:when startTime=\"2005-10-06\"/></entry>";
106
 
 
107
 
            // Parse the XML back into a new MigrationEntry
108
 
            XmlDocument document = new XmlDocument();
109
 
            document.LoadXml(xmlElementText);
110
 
 
111
 
            foreach (XmlNode node in document.FirstChild.ChildNodes)
112
 
            {
113
 
                ExtensionElementEventArgs e = new ExtensionElementEventArgs();
114
 
                e.ExtensionElement = node;
115
 
                entry.Parse(e, new AtomFeedParser());
116
 
            }
117
 
 
118
 
            // Verify that the labels are correct
119
 
            Assert.AreEqual(2, entry.Labels.Count, "Parsed MailItemEntry should have exactly two labels");
120
 
            Assert.AreEqual("Friends", entry.Labels[0].LabelName,
121
 
                "Parsed MailItemEntry does not contain a \"Friends\" label");
122
 
            Assert.AreEqual("Acquaintances", entry.Labels[1].LabelName,
123
 
                "Parsed MailItemEntry does not contain an \"Acquaintances\" label");
124
 
 
125
 
            // Verify that the mail item properties are correct
126
 
            Assert.AreEqual(2, entry.MailItemProperties.Count,
127
 
                "Parsed MailItemEntry should have exactly two mail item properties");
128
 
            Assert.AreEqual("IS_SENT", entry.MailItemProperties[0].Value.ToString(),
129
 
                "Parsed MailItemEntry does not contain a SENT property.");
130
 
            Assert.AreEqual("IS_STARRED", entry.MailItemProperties[1].Value.ToString(),
131
 
                "Parsed MailItemEntry does not contain the STARRED property.");
132
 
 
133
 
            // Verify that the RFC822 message is correct
134
 
            Assert.AreEqual("Hi", entry.Rfc822Msg.ToString(), "Parsed MailItemEntry has incorrect Rfc822Msg");
135
 
        }
136
 
 
137
 
        [Test]
138
 
        public void SaveXmlTest()
139
 
        {
140
 
            // Set up the MailItemEntry.
141
 
            entry.Rfc822Msg = new Rfc822MsgElement("Hi");
142
 
            entry.Labels.Add(new LabelElement("Friends"));
143
 
            entry.Labels.Add(new LabelElement("Acquaintances"));
144
 
            entry.MailItemProperties.Add(MailItemPropertyElement.SENT);
145
 
            entry.MailItemProperties.Add(MailItemPropertyElement.TRASH);
146
 
 
147
 
            // Save it as a string using an XmlWriter.
148
 
            StringBuilder sb = new StringBuilder();
149
 
            XmlWriter writer = new XmlTextWriter(new StringWriter(sb));
150
 
            entry.SaveToXml(writer);
151
 
            writer.Close();
152
 
 
153
 
            string savedXml = sb.ToString();
154
 
 
155
 
            // Assertions
156
 
            Assert.IsTrue(savedXml.IndexOf(Rfc822MsgTest.xmlElementAsText) != 0,
157
 
                "Saved XML form of MailItemEntry does not contain correct rfc822Msg element");
158
 
            Assert.IsTrue(savedXml.IndexOf(LabelTest.xmlElementAsText) != 0,
159
 
                "Saved XML form of MailItemEntry does not contain \"Friends\" label element");
160
 
            Assert.IsTrue(savedXml.IndexOf(LabelTest.xmlElementAsText.Replace("Friends", "Acquaintances"))!=0,
161
 
                "Saved XML form of MailItemEntry does not contain \"Acquaintances\" label element");
162
 
            Assert.IsTrue(savedXml.IndexOf(MailItemPropertyTest.xmlElementAsText) !=0,
163
 
                "Saved XML form of MailItemEntry does not contain SENT property");
164
 
            Assert.IsTrue(savedXml.IndexOf(MailItemPropertyTest.xmlElementAsText.Replace("SENT", "TRASH")) !=0,
165
 
                "Saved XML form of MailItemEntry does not contain TRASH property");
166
 
        }
167
 
    }
168
 
}