public void TestFilterConstructor_01() { DateTime now = DateTime.Now; Filter filter = new Filter(); filter.IsFullData = true; filter.PostUrl = "PostUrl"; filter.Name = "FilterName"; filter.Rules.Add(new Rule(RuleType.Actor, "ActorOne")); Filter filter2 = new Filter( "FilterName", "PostUrl", true, new Rule(RuleType.Actor, "ActorOne")); Assert.IsTrue(filter.DeepEquals(filter2)); }
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"); }
/// <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(Filter that) { if (this == that) return true; else if (that == null) return false; return (string.Equals(this.PostUrl, that.PostUrl) && string.Equals(this.Name, that.Name) && this.IsFullData == that.IsFullData && ListUtils.AreDeepEqual<Rule>(this.Rules, that.Rules)); }
private void TestDeepEquals(Filter objectA, Filter 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)); }
public void TestFilterSerialize_02() { Filter filter = new Filter( "FilterName", "PostUrl", true, new Rule(RuleType.Actor, "ActorOne"), new Rule(RuleType.Actor, "ActorTwo")); string str = XmlHelper.Instance.ToXmlString<Filter>(filter); Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<filter xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" name=\"FilterName\" fullData=\"true\">" + "<postURL>PostUrl</postURL>" + "<rule type=\"actor\">ActorOne</rule>" + "<rule type=\"actor\">ActorTwo</rule>" + "</filter>", str); }
public void TestFilterDeserialize_01() { Filter filter = new Filter( "FilterName", "PostUrl", true, new Rule(RuleType.Actor, "ActorOne")); string str = XmlHelper.Instance.ToXmlString<Filter>(filter); Filter des = XmlHelper.Instance.FromXmlString<Filter>(str); Assert.IsTrue(filter.DeepEquals(des)); }