public void ComparingUserAgents() { UserAgent baseAgent = new UserAgent("Something 2"); UserAgent agent0 = new UserAgent("Something 2"); UserAgent agent1 = new UserAgent("Something 1"); UserAgent agent2 = new UserAgent("Something 2"); UserAgent agent3 = new UserAgent("Something 2"); UserAgent agent4 = new UserAgent("Something 2"); var field0 = new AgentField("Foo"); field0.SetValue("One", 1); var field1 = new AgentField("Foo"); field1.SetValue("One", 1); var field2 = new AgentField("Foo"); // Same, different value field2.SetValue("Two", 1); var field3 = new AgentField("Foo"); // Same, different confidence field3.SetValue("One", 2); var field4 = new AgentField(null); // Same, different default field4.SetValue("One", 1); // We compare the base agent with 4 variations baseAgent.SetImmediateForTesting("Field", field0); agent0.SetImmediateForTesting("Field", field1); // Same agent1.SetImmediateForTesting("Field", field1); // Different useragent agent2.SetImmediateForTesting("Field", field2); // Different field value agent3.SetImmediateForTesting("Field", field3); // Different field confidence agent4.SetImmediateForTesting("Field", field4); // Different field default value // Check em baseAgent.Should().BeEquivalentTo(baseAgent); baseAgent.Should().BeEquivalentTo(agent0); agent0.Should().BeEquivalentTo(baseAgent); baseAgent.GetHashCode().Should().Be(agent0.GetHashCode()); Log.Info(baseAgent.ToString("Field")); baseAgent.Equals(agent2).Should().BeFalse(); baseAgent.Equals(agent3).Should().BeFalse(); baseAgent.Equals(agent4).Should().BeFalse(); agent1.Equals("String").Should().BeFalse(); "String".Equals(agent1).Should().BeFalse(); }
public bool Equals(RobotifyMetaTag other) { var userAgentEqual = UserAgent.Equals(other.UserAgent); var directivesIncluded = Directives.ToImmutableHashSet().IsSubsetOf(other.Directives.ToImmutableHashSet()); return(userAgentEqual && directivesIncluded); }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || GetType() != o.GetType()) { return(false); } Site site = (Site)o; if (CycleRetryTimes != site.CycleRetryTimes) { return(false); } if (RetryTimes != site.RetryTimes) { return(false); } if (SleepTime != site.SleepTime) { return(false); } if (Timeout != site.Timeout) { return(false); } if (!AcceptStatCode?.Equals(site.AcceptStatCode) ?? site.AcceptStatCode != null) { return(false); } if (!Encoding?.Equals(site.Encoding) ?? site.Encoding != null) { return(false); } if (!_defaultCookies?.Equals(site._defaultCookies) ?? site._defaultCookies != null) { return(false); } if (!Domain?.Equals(site.Domain) ?? site.Domain != null) { return(false); } if (!_headers?.Equals(site._headers) ?? site._headers != null) { return(false); } if (!_startRequests?.Equals(site._startRequests) ?? site._startRequests != null) { return(false); } if (!UserAgent?.Equals(site.UserAgent) ?? site.UserAgent != null) { return(false); } return(true); }
/// <summary> /// Returns true if AttachmentRaw instances are equal /// </summary> /// <param name="other">Instance of AttachmentRaw to be compared</param> /// <returns>Boolean</returns> public bool Equals(AttachmentRaw other) { // credit: http://stackoverflow.com/a/10454552/677735 if (other == null) { return(false); } return (( ContentType == other.ContentType || ContentType != null && ContentType.Equals(other.ContentType) ) && ( Slug == other.Slug || Slug != null && Slug.Equals(other.Slug) ) && ( UserAgent == other.UserAgent || UserAgent != null && UserAgent.Equals(other.UserAgent) ) && ( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Rid == other.Rid || Rid != null && Rid.Equals(other.Rid) ) && ( Ts == other.Ts || Ts != null && Ts.Equals(other.Ts) ) && ( Self == other.Self || Self != null && Self.Equals(other.Self) ) && ( Etag == other.Etag || Etag != null && Etag.Equals(other.Etag) ) && ( Permissions == other.Permissions || Permissions != null && Permissions.Equals(other.Permissions) )); }