コード例 #1
0
 /// <summary>
 /// Is this RosetteSentimentEntity the same as the other entity?
 /// </summary>
 /// <param name="other">The other entity</param>
 /// <returns>True if the entities are equal (sentiment is ignored).</returns>
 public bool EntityEquals(RosetteEntity other)
 {
     List<bool> conditions = new List<bool>() {
        this.Mention == other.Mention &&
        this.NormalizedMention != null && other.NormalizedMention != null ? this.NormalizedMention.Equals(other.NormalizedMention) : this.NormalizedMention == other.NormalizedMention,
        this.Mention != null && other.Mention != null ? this.Mention.Equals(other.Mention) : this.Mention == other.Mention,
        this.ID != null && other.ID != null ? this.ID.Equals(other.ID) : this.ID == other.ID,
        this.EntityType != null && other.EntityType != null ? this.EntityType.Equals(other.EntityType) : this.EntityType == other.EntityType,
        this.Count != null && other.Count != null ? this.Count.Equals(other.Count) : this.Count == other.Count
        };
        return conditions.All(condition => condition);
 }
コード例 #2
0
        /// <summary>
        /// Is this RosetteSentimentEntity the same as the other entity?
        /// </summary>
        /// <param name="other">The other entity</param>
        /// <returns>True if the entities are equal (sentiment is ignored).</returns>
        public bool EntityEquals(RosetteEntity other)
        {
            List <bool> conditions = new List <bool>()
            {
                this.Mention == other.Mention &&
                this.NormalizedMention != null && other.NormalizedMention != null?this.NormalizedMention.Equals(other.NormalizedMention) : this.NormalizedMention == other.NormalizedMention,
                    this.Mention != null && other.Mention != null?this.Mention.Equals(other.Mention) : this.Mention == other.Mention,
                        this.ID != null && other.ID != null?this.ID.Equals(other.ID) : this.ID == other.ID,
                            this.EntityType != null && other.EntityType != null?this.EntityType.Equals(other.EntityType) : this.EntityType == other.EntityType,
                                this.Count != null && other.Count != null?this.Count.Equals(other.Count) : this.Count == other.Count
            };

            return(conditions.All(condition => condition));
        }
コード例 #3
0
 /// <summary>
 /// Equals override
 /// </summary>
 /// <param name="obj">The object to compare against</param>
 /// <returns>True if equal</returns>
 public override bool Equals(object obj)
 {
     if (obj is RosetteEntity)
     {
         RosetteEntity other      = obj as RosetteEntity;
         List <bool>   conditions = new List <bool>()
         {
             this.ID != null && other.ID != null?this.ID.Equals(other.ID) : this.ID == other.ID,
                 this.Count == other.Count,
                 this.EntityType == other.EntityType,
                 this.Mention == other.Mention,
                 this.NormalizedMention == other.NormalizedMention,
                 this.GetHashCode() == other.GetHashCode()
         };
         return(conditions.All(condition => condition));
     }
     else
     {
         return(false);
     }
 }
コード例 #4
0
 public void EntityTestFull()
 {
     Init();
     RosetteEntity e0 = new RosetteEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2);
     RosetteEntity e1 = new RosetteEntity("The Hollywood Reporter", "The Hollywood Reporter", new EntityID("Q61503"), "ORGANIZATION", 1);
     List<RosetteEntity> entities = new List<RosetteEntity>() { e0, e1 };
     string headersAsString = " { \"Content-Type\": \"application/json\", \"date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"server\": \"openresty\", \"strict-transport-security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"content-length\": \"72\", \"connection\": \"Close\" }";
     Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
     Dictionary<string, object> content = new Dictionary<string, object>();
     content.Add("entities", entities);
     EntitiesResponse expected = new EntitiesResponse(entities, responseHeaders, content, null);
     String mockedContent = expected.ContentToString();
     HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
     _mockHttp.When(_testUrl + "entities").Respond(mockedMessage);
     EntitiesResponse response = _rosetteApi.Entity("Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, “The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.”");
     Assert.AreEqual(expected, response);
 }