Inheritance: IResource, IDeepCompare
コード例 #1
0
        public void TestCreateDeletePublishers()
        {
            Publisher publisher = null;
            Result result = null;

            publisher = new Publisher(PublisherType.My, "hydrogentestpublisher", RuleType.Actor);
            result = gnipConnection.Create(publisher);

            Assert.IsTrue(result.IsSuccess);

            // get the newly created publisher
            publisher = gnipConnection.GetPublisher(PublisherType.My, "hydrogentestpublisher");
            Assert.IsNotNull(publisher);
            Assert.AreEqual("hydrogentestpublisher", publisher.Name);

            // delete it
            result = gnipConnection.Delete(publisher);
            Assert.IsTrue(result.IsSuccess);

            try
            {
                // get the newly created publisher
                publisher = gnipConnection.GetPublisher(PublisherType.My, "hydrogentestpublisher");
                Assert.Fail("Expecting exception");
            }
            catch (GnipException)
            {
            }
        }
コード例 #2
0
 public void TestPublisherConstructor_02()
 {
     Publisher publisher = new Publisher(PublisherType.My, "foobar", RuleType.Actor, RuleType.Tag);
     Assert.AreEqual(PublisherType.My, publisher.Type);
     Assert.AreEqual("foobar", publisher.Name);
     Assert.AreEqual(2, publisher.SupportedRuleTypes.Count);
     Assert.IsTrue(publisher.SupportedRuleTypes.Contains(RuleType.Actor));
     Assert.IsTrue(publisher.SupportedRuleTypes.Contains(RuleType.Tag));
 }
コード例 #3
0
        public void TestPublisherConstructor_01()
        {
            List<RuleType> oneRuleType = new List<RuleType>();
            oneRuleType.Add(RuleType.Actor);
            oneRuleType.Add(RuleType.Regarding);

            Publisher publisher = new Publisher(PublisherType.My, "foobar", oneRuleType);
            Assert.AreEqual(PublisherType.My, publisher.Type);
            Assert.AreEqual("foobar", publisher.Name);
            Assert.AreEqual(oneRuleType.Count, publisher.SupportedRuleTypes.Count);
            Assert.IsTrue(publisher.SupportedRuleTypes.Contains(RuleType.Actor));
            Assert.IsTrue(publisher.SupportedRuleTypes.Contains(RuleType.Regarding));

            Publisher publisher2 = new Publisher();
            publisher2.Name = "foobar";
            publisher2.SupportedRuleTypes.AddRange(oneRuleType);
            Assert.IsTrue(publisher2.SupportedRuleTypes.Contains(RuleType.Actor));
            Assert.IsTrue(publisher2.SupportedRuleTypes.Contains(RuleType.Regarding));
        }
コード例 #4
0
        public override void SetUp()
        {
            XmlHelper.Instance.ValidateXml = true;
            XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("gnip.log4net.xml"));

            Log.Debug("========== Test setUp() start");
            Log.Debug("Attempting to connect to Gnip at " +  testConfig.Host + " using username " + testConfig.Username);

            config = new Config(testConfig.Username,
                testConfig.Password,
                new System.Uri(testConfig.Host),
                testConfig.RequestTimeout,
                testConfig.ReadWriteTimeout);

            gnipConnection = new GnipConnection(config);
            // Auto sync to the servers time.
            gnipConnection.TimeCorrection = gnipConnection.GetServerTimeDelta();

            string localPublisherId = testConfig.Publisher;
            localPublisher = gnipConnection.GetPublisher(testConfig.PublisherType, localPublisherId);
            if (localPublisher == null)
            {
                throw new AssertionException("No Publisher of type " + testConfig.PublisherType + " found with name " + localPublisherId + ".  Be sure " + "to provide the name of a publisher you own in the test.properties file.");
            }

            activities = new Activities();
            activity1 = new Activity(new Actor("joe"), "update1");
            activities.Items.Add(activity1);
            activity2 = new Activity(new Actor("tom"), "update2");
            activities.Items.Add(activity2);
            activity3 = new Activity(new Actor("jane"), "update3");
            activities.Items.Add(activity3);

            filterToCreate = new Filter("tomFilter");
            filterToCreate.Rules.Add(new Rule(RuleType.Actor, "tom"));

            notificationFilterToCreate = new Filter("janeFilter");
            notificationFilterToCreate.IsFullData = false;
            notificationFilterToCreate.Rules.Add(new Rule(RuleType.Actor, "jane"));

            Log.Debug("Test setUp() end\n");
        }
コード例 #5
0
ファイル: Publisher.cs プロジェクト: electromute/gnip-dotnet
        /// <summary>
        /// Determins if this equals that by performing a deep equals 
        /// looking at all elements of all member listsand objects.
        /// </summary>
        /// <param name="that">The object to compare for equality.</param>
        /// <returns>True if this is equal to that, false otherwise.</returns>
        public bool DeepEquals(Publisher that)
        {
            if(this == that)
                return true;
            else if(that == null)
                return false;

            return (this.Type == that.Type &&
                string.Equals(this.Name, that.Name) &&
                ListUtils.AreEqualIgnoreOrder<RuleType>(this.SupportedRuleTypes, that.SupportedRuleTypes));
        }
コード例 #6
0
 private void TestDeepEquals(Publisher objectA, Publisher objectB, bool expect, bool expectDeep)
 {
     Assert.AreEqual(expectDeep, objectA.DeepEquals(objectB));
     Assert.AreEqual(expectDeep, objectB.DeepEquals(objectA));
     Assert.AreEqual(expect, objectA.Equals(objectB));
     Assert.AreEqual(expect, objectB.Equals(objectA));
 }
コード例 #7
0
 public void TestPublisherSerialize_03()
 {
     Publisher publisher = new Publisher(PublisherType.My, "foobar");
     string str = XmlHelper.Instance.ToXmlString<Publisher>(publisher);
     Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                     "<publisher xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" name=\"foobar\">" +
                     "<supportedRuleTypes />" +
                     "</publisher>",
                     str);
 }
コード例 #8
0
 public void TestPublisherDeserialize_03()
 {
     Publisher publisher = new Publisher(PublisherType.My, "foobar", RuleType.Actor);
     string str = XmlHelper.Instance.ToXmlString<Publisher>(publisher);
     Publisher des = XmlHelper.Instance.FromXmlString<Publisher>(str);
     Assert.AreEqual(publisher.Name, des.Name);
     Assert.AreEqual(publisher.SupportedRuleTypes.Count, des.SupportedRuleTypes.Count);
     for (int idx = 0; idx < publisher.SupportedRuleTypes.Count; idx++)
     {
         Assert.AreEqual(publisher.SupportedRuleTypes[idx], des.SupportedRuleTypes[idx]);
     }
 }