Пример #1
0
        /// <summary>
        /// Returns true if Wearable instances are equal
        /// </summary>
        /// <param name="other">Instance of Wearable to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Wearable other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     PersonId == other.PersonId ||
                     PersonId != null &&
                     PersonId.Equals(other.PersonId)
                     ) &&
                 (
                     ThingId == other.ThingId ||
                     ThingId != null &&
                     ThingId.Equals(other.ThingId)
                 ) &&
                 (
                     Timestamp == other.Timestamp ||
                     Timestamp != null &&
                     Timestamp.Equals(other.Timestamp)
                 ));
        }
Пример #2
0
        /// <summary>
        /// Returns true if Thing instances are equal
        /// </summary>
        /// <param name="other">Instance of Thing to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ExportCsv other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ObservationType == other.ObservationType ||
                     ObservationType != null &&
                     ObservationType.Equals(other.ObservationType)
                     ) &&
                 (
                     ThingId == other.ThingId ||
                     ThingId != null &&
                     ThingId.Equals(other.ThingId)
                 ) &&
                 (
                     EndTime == other.EndTime ||
                     EndTime != null &&
                     EndTime.Equals(other.EndTime)
                 ) &&
                 (
                     StartTime == other.StartTime ||
                     StartTime != null &&
                     StartTime.Equals(other.StartTime)
                 ));
        }
Пример #3
0
        /// <summary>
        /// Determines whether specified instance of <see cref="ResultInfo" /> is equal to caller
        /// object.
        /// </summary>
        /// <param name="other">Other object to compare.</param>
        /// <returns><c>true</c> if values are memberwise equals, <c>false</c> otherwise.</returns>
        private bool IsEqual(ResultInfo other)
        {
            const double tolerance = 1e-6;

            return(ThingId.Equals(other.ThingId) &&
                   Math.Abs(RatingValue - other.RatingValue) < tolerance &&
                   RatingId.Equals(other.RatingId));
        }
Пример #4
0
        /// <summary>
        /// Determines whether specified instance of <see cref="BasicInfo" /> is equal to caller
        /// object.
        /// </summary>
        /// <param name="other">Other object to compare.</param>
        /// <returns><c>true</c> if values are memberwise equals, <c>false</c> otherwise.</returns>
        protected bool IsEqual(BasicInfo other)
        {
            const double eps = 1e-6;

            return(ThingId.Equals(other.ThingId) &&
                   string.Equals(Title, other.Title, StringComparison.Ordinal) &&
                   VoteCount.Equals(other.VoteCount) &&
                   Math.Abs(VoteAverage - other.VoteAverage) < eps);
        }
Пример #5
0
        public void Equals_SameIdString_ReturnsTrue()
        {
            const string driver  = "Driver1";
            const string gateway = "Gateway1";
            const string thing   = "Thing1";

            var thingId = new ThingId(new GatewayId(driver, gateway), thing);

            Assert.True(thingId.Equals($"{driver}:{gateway}:{thing}"));
        }
Пример #6
0
        public void Equals_NullId_ReturnsFalse()
        {
            const string driver  = "Driver1";
            const string gateway = "Gateway1";
            const string thing   = "Thing1";

            var thingId = new ThingId(new GatewayId(driver, gateway), thing);

            Assert.False(thingId.Equals((IdBase)null));
        }
Пример #7
0
        public void Equals_OtherIdWithSameValue_ReturnsTrue()
        {
            const string driver  = "Driver1";
            const string gateway = "Gateway1";
            const string thing   = "Thing1";

            var thingId  = new ThingId(new GatewayId(driver, gateway), thing);
            var thingId2 = new ThingId(new GatewayId(driver, gateway), thing);

            Assert.True(thingId.Equals(thingId2));
        }
Пример #8
0
        public void Equals_SameIdObject_ReturnsTrue()
        {
            const string driver  = "Driver1";
            const string gateway = "Gateway1";
            const string thing   = "Thing1";

            var thingId = new ThingId(new GatewayId(driver, gateway), thing);

            object id = thingId;

            Assert.True(thingId.Equals(id));
        }
Пример #9
0
        public void Equals_NotSameIdStringObject_ReturnsFalse()
        {
            const string driver  = "Driver1";
            const string gateway = "Gateway1";
            const string thing   = "Thing1";
            const string driver2 = "Driver2";

            var thingId = new ThingId(new GatewayId(driver, gateway), thing);

            object id = $"{driver2}:{gateway}:{thing}";

            Assert.False(thingId.Equals(id));
        }
Пример #10
0
        /// <summary>
        /// Returns true if Observation instances are equal
        /// </summary>
        /// <param name="other">Instance of Observation to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Observation other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ThingId == other.ThingId ||
                     ThingId != null &&
                     ThingId.Equals(other.ThingId)
                     ) &&
                 (
                     DatastreamId == other.DatastreamId ||
                     DatastreamId != null &&
                     DatastreamId.Equals(other.DatastreamId)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     Personid == other.Personid ||
                     Personid != null &&
                     Personid.Equals(other.Personid)
                 ) &&
                 (
                     Zoneid == other.Zoneid ||
                     Zoneid != null &&
                     Zoneid.Equals(other.Zoneid)
                 ) &&
                 (
                     PhenomenTime == other.PhenomenTime ||
                     PhenomenTime != null &&
                     PhenomenTime.Equals(other.PhenomenTime)
                 ) &&
                 (
                     ObservationResult == other.ObservationResult ||
                     ObservationResult != null &&
                     ObservationResult.Equals(other.ObservationResult)
                 ));
        }