コード例 #1
0
        public void CorrelationId_Not_Be_Equal_When_Ids_Are_Not_Equal()
        {
            var baseBytes      = ByteUtil.GenerateRandomByteArray(CorrelationId.GuidByteLength);
            var differentBytes = ByteUtil.GenerateRandomByteArray(CorrelationId.GuidByteLength);

            var id1 = new CorrelationId(baseBytes);
            var id2 = (CorrelationId)null;
            var id3 = new CorrelationId(differentBytes);

            id1.Equals(id2).Should().BeFalse();
            id1.Equals(id3).Should().BeFalse();
            (id1 == id2).Should().BeFalse();
            (id1 == id3).Should().BeFalse();
        }
コード例 #2
0
        private void LogMessage(string logMessage, LogLevel logLevel, bool containsPii)
        {
            if ((logLevel > Level) || (!PiiLoggingEnabled && containsPii))
            {
                return;
            }

            //format log message;
            string correlationId = (CorrelationId.Equals(Guid.Empty))
                ? string.Empty
                : " - " + CorrelationId;

            string os = "N/A";

            if (MsalIdHelper.GetMsalIdParameters().ContainsKey(MsalIdParameter.OS))
            {
                os = MsalIdHelper.GetMsalIdParameters()[MsalIdParameter.OS];
            }


            string log = string.Format(CultureInfo.InvariantCulture, "MSAL {0} {1} {2} [{3}{4}]{5} {6}",
                                       MsalIdHelper.GetMsalVersion(),
                                       MsalIdHelper.GetMsalIdParameters()[MsalIdParameter.Product],
                                       os, DateTime.UtcNow, correlationId, Component, logMessage);

            if (DefaultLoggingEnabled)
            {
                PlatformPlugin.LogMessage(logLevel, log);
            }

            ExecuteCallback(logLevel, log, containsPii);
        }
        /// <summary>
        /// Returns true if ViltConnectorLaunchSessionSuccessResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of ViltConnectorLaunchSessionSuccessResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ViltConnectorLaunchSessionSuccessResponse other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                     ) &&
                 (
                     CorrelationId == other.CorrelationId ||
                     CorrelationId != null &&
                     CorrelationId.Equals(other.CorrelationId)
                 ) &&
                 (
                     Timestamp == other.Timestamp ||
                     Timestamp != null &&
                     Timestamp.Equals(other.Timestamp)
                 ) &&
                 (
                     Data == other.Data ||
                     Data != null &&
                     Data.Equals(other.Data)
                 ));
        }
コード例 #4
0
        /// <summary>
        /// Returns true if ViltConnectorErrorResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of ViltConnectorErrorResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ViltConnectorErrorResponse other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                     ) &&
                 (
                     CorrelationId == other.CorrelationId ||
                     CorrelationId != null &&
                     CorrelationId.Equals(other.CorrelationId)
                 ) &&
                 (
                     Timestamp == other.Timestamp ||
                     Timestamp != null &&
                     Timestamp.Equals(other.Timestamp)
                 ) &&
                 (
                     Error == other.Error ||
                     Error != null &&
                     Error.Equals(other.Error)
                 ));
        }
コード例 #5
0
        private void Log(LogLevel msalLogLevel, string messageWithPii, string messageScrubbed)
        {
            if (msalLogLevel > Logger.Level)
            {
                return;
            }

            //format log message;
            string correlationId = CorrelationId.Equals(Guid.Empty)
                ? string.Empty
                : " - " + CorrelationId;

            var    msalIdParameters = MsalIdHelper.GetMsalIdParameters();
            string os = "N/A";

            if (msalIdParameters.TryGetValue(MsalIdParameter.OS, out string osValue))
            {
                os = osValue;
            }

            bool messageWithPiiExists = !string.IsNullOrWhiteSpace(messageWithPii);
            // If we have a message with PII, and PII logging is enabled, use the PII message, else use the scrubbed message.
            bool   isLoggingPii = messageWithPiiExists && Logger.PiiLoggingEnabled;
            string messageToLog = isLoggingPii ? messageWithPii : messageScrubbed;

            string log = string.Format(CultureInfo.InvariantCulture, "{0} MSAL {1} {2} {3} [{4}{5}]{6} {7}",
                                       isLoggingPii ? "(True)" : "(False)",
                                       MsalIdHelper.GetMsalVersion(),
                                       msalIdParameters[MsalIdParameter.Product],
                                       os, DateTime.UtcNow, correlationId, Component, messageToLog);

            if (Logger.DefaultLoggingEnabled)
            {
                switch (Logger.Level)
                {
                case LogLevel.Error:
                    _platformLogger.Error(log);
                    break;

                case LogLevel.Warning:
                    _platformLogger.Warning(log);
                    break;

                case LogLevel.Info:
                    _platformLogger.Information(log);
                    break;

                case LogLevel.Verbose:
                    _platformLogger.Verbose(log);
                    break;
                }
            }

            ExecuteCallback(msalLogLevel, log, isLoggingPii);
        }
コード例 #6
0
        public void CorrelationId_Be_Equal_When_Ids_Are_Equal()
        {
            var baseBytes = ByteUtil.GenerateRandomByteArray(CorrelationId.GuidByteLength);

            var id1 = new CorrelationId(baseBytes);
            var id2 = new CorrelationId(baseBytes);

            id1.GetHashCode().Should().Be(id2.GetHashCode());
            id1.Equals(id2).Should().BeTrue();
            (id1 == id2).Should().BeTrue();
        }
コード例 #7
0
ファイル: EventMetadata.cs プロジェクト: HammerAlf/Runtime
 /// <inheritdoc/>
 public override bool Equals(EventMetadata other)
 {
     return
         (Id.Equals(other.Id) &&
          Artifact.Equals(other.Artifact) &&
          CorrelationId.Equals(other.CorrelationId) &&
          EventSourceId.Equals(other.EventSourceId) &&
          Occurred.LossyEquals(other.Occurred) &&
          OriginalContext.Equals(other.OriginalContext) &&
          VersionedEventSource.Equals(other.VersionedEventSource));
 }
コード例 #8
0
        public void TestProvidedMethods()
        {
            var i1 = Guid.NewGuid();
            var i2 = Guid.NewGuid();

            var c1 = new CorrelationId(i1);
            var c2 = new CorrelationId(i2);

            Assert.AreEqual(i1.CompareTo(i2), c1.CompareTo(c2));                    // Compare correlation id and correlation id
            Assert.AreEqual(i1.CompareTo(i2), c1.CompareTo(i2));                    // Compare correlation id and Guid
            Assert.AreEqual(i1.CompareTo((object)i2), c1.CompareTo((object)c2));    // Compare correlation id and object cid
            Assert.AreEqual(i1.CompareTo((object)i2), c1.CompareTo((object)i2));    // Compare correlation id and object Guid

            Assert.IsTrue(c1.Equals(new CorrelationId(i1)));                        // Equals correlation id and correlation id
            Assert.IsFalse(c1.Equals(new CorrelationId(i2)));                       // Not equals correlation id and correlation id
            Assert.IsTrue(c1.Equals((object)new CorrelationId(i1)));                // Equals correlation id and object correlation id
            Assert.IsFalse(c1.Equals((object)new CorrelationId(i2)));               // Not equals correlation id and object correlation id

            Assert.IsTrue(c1.Equals(i1));                                           // Equals correlation id and Guid
            Assert.IsFalse(c1.Equals(i2));                                          // Not equals correlation id and Guid
            Assert.IsFalse(c1.Equals((object)i1));                                  // Not equals correlation id and object Guid
            Assert.IsFalse(c1.Equals((object)i2));                                  // Not equals correlation id and object Guid

            Assert.AreEqual(i1.GetHashCode(), c1.GetHashCode());                    // GetHashCode
            Assert.AreNotEqual(i2.GetHashCode(), c1.GetHashCode());                 
            Assert.AreEqual(c1.GetHashCode(), c1.GetHashCode());                    
            Assert.AreNotEqual(c2.GetHashCode(), c1.GetHashCode());                 

            CollectionAssert.AreEqual(i1.ToByteArray(), c1.ToByteArray());          // To byte array
            CollectionAssert.AreNotEqual(i2.ToByteArray(), c1.ToByteArray());
            CollectionAssert.AreEqual(i2.ToByteArray(), c2.ToByteArray());
            CollectionAssert.AreNotEqual(i1.ToByteArray(), c2.ToByteArray());                 


            Assert.AreEqual(i1.ToString(), c1.ToString());                          // To string
            Assert.AreNotEqual(i2.ToString(), c1.ToString());                       
            Assert.AreEqual(i2.ToString(), c2.ToString());                          
            Assert.AreNotEqual(i1.ToString(), c2.ToString());                       
                                                                                    
            Assert.AreEqual(i1.ToString("N"), c1.ToString("N"));                    // To string with format
            Assert.AreNotEqual(i2.ToString("N"), c1.ToString("N"));                 
            Assert.AreEqual(i2.ToString("N"), c2.ToString("N"));                    
            Assert.AreNotEqual(i1.ToString("N"), c2.ToString("N"));                 
                                                                                    
            var c = CultureInfo.CurrentCulture;                                     
            Assert.AreEqual(i1.ToString("D", c), c1.ToString("D", c));              // To string with format and provider
            Assert.AreNotEqual(i2.ToString("D", c), c1.ToString("D", c));           
            Assert.AreEqual(i2.ToString("D", c), c2.ToString("D", c));              
            Assert.AreNotEqual(i1.ToString("D", c), c2.ToString("D", c));           
        }
コード例 #9
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns><see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <see langword="false" />.</returns>
        public bool Equals(StrongTypingClass other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(CorrelationId.Equals(other.CorrelationId) && string.Equals(SomeText, other.SomeText, StringComparison.InvariantCultureIgnoreCase) && Date.Equals(other.Date));
        }
コード例 #10
0
        public bool Equals(AwaInitializeResponse input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     CorrelationId == input.CorrelationId ||
                     (CorrelationId != null && CorrelationId.Equals(input.CorrelationId))
                     ) &&
                 (
                     SentToSelf == input.SentToSelf ||
                     (SentToSelf != null && SentToSelf.Equals(input.SentToSelf))
                 ));
        }
コード例 #11
0
        public bool Equals(AwaUserResponse input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Selection == input.Selection ||
                     (Selection != null && Selection.Equals(input.Selection))
                     ) &&
                 (
                     CorrelationId == input.CorrelationId ||
                     (CorrelationId != null && CorrelationId.Equals(input.CorrelationId))
                 ) &&
                 (
                     Nonce == input.Nonce ||
                     (Nonce != null && Nonce.SequenceEqual(input.Nonce))
                 ));
        }
コード例 #12
0
        /// <summary>
        /// Returns true if BlobStorageInfo instances are equal
        /// </summary>
        /// <param name="other">Instance of BlobStorageInfo to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BlobStorageInfo other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     BlobName == other.BlobName ||
                     BlobName != null &&
                     BlobName.Equals(other.BlobName)
                     ) &&
                 (
                     ContainerName == other.ContainerName ||
                     ContainerName != null &&
                     ContainerName.Equals(other.ContainerName)
                 ) &&
                 (
                     CorrelationId == other.CorrelationId ||
                     CorrelationId != null &&
                     CorrelationId.Equals(other.CorrelationId)
                 ) &&
                 (
                     HostName == other.HostName ||
                     HostName != null &&
                     HostName.Equals(other.HostName)
                 ) &&
                 (
                     SasToken == other.SasToken ||
                     SasToken != null &&
                     SasToken.Equals(other.SasToken)
                 ));
        }
コード例 #13
0
ファイル: Table.cs プロジェクト: KieranIAtom/Gaspra.Functions
 public bool Equals([AllowNull] Table other)
 {
     return(other != null &&
            CorrelationId.Equals(other.CorrelationId));
 }
コード例 #14
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj == null)
            {
                return(false);
            }

            if (GetType() != obj.GetType())
            {
                return(false);
            }

            var other = (MessageProperties)obj;

            if (AppId == null)
            {
                if (other.AppId != null)
                {
                    return(false);
                }
            }
            else if (!AppId.Equals(other.AppId))
            {
                return(false);
            }

            if (ClusterId == null)
            {
                if (other.ClusterId != null)
                {
                    return(false);
                }
            }
            else if (!ClusterId.Equals(other.ClusterId))
            {
                return(false);
            }

            if (ContentEncoding == null)
            {
                if (other.ContentEncoding != null)
                {
                    return(false);
                }
            }
            else if (!ContentEncoding.Equals(other.ContentEncoding))
            {
                return(false);
            }

            if (ContentLength != other.ContentLength)
            {
                return(false);
            }

            if (ContentType == null)
            {
                if (other.ContentType != null)
                {
                    return(false);
                }
            }
            else if (!ContentType.Equals(other.ContentType))
            {
                return(false);
            }

            if (CorrelationId == null)
            {
                if (other.CorrelationId != null)
                {
                    return(false);
                }
            }
            else if (!CorrelationId.Equals(other.CorrelationId))
            {
                return(false);
            }

            if (DeliveryMode != other.DeliveryMode)
            {
                return(false);
            }

            if (DeliveryTag != other.DeliveryTag)
            {
                return(false);
            }

            if (Expiration == null)
            {
                if (other.Expiration != null)
                {
                    return(false);
                }
            }
            else if (!Expiration.Equals(other.Expiration))
            {
                return(false);
            }

            if (!Headers.Equals(other.Headers))
            {
                return(false);
            }

            if (MessageCount == null)
            {
                if (other.MessageCount != null)
                {
                    return(false);
                }
            }
            else if (!MessageCount.Equals(other.MessageCount))
            {
                return(false);
            }

            if (MessageId == null)
            {
                if (other.MessageId != null)
                {
                    return(false);
                }
            }
            else if (!MessageId.Equals(other.MessageId))
            {
                return(false);
            }

            if (Priority == null)
            {
                if (other.Priority != null)
                {
                    return(false);
                }
            }
            else if (!Priority.Equals(other.Priority))
            {
                return(false);
            }

            if (ReceivedExchange == null)
            {
                if (other.ReceivedExchange != null)
                {
                    return(false);
                }
            }
            else if (!ReceivedExchange.Equals(other.ReceivedExchange))
            {
                return(false);
            }

            if (ReceivedRoutingKey == null)
            {
                if (other.ReceivedRoutingKey != null)
                {
                    return(false);
                }
            }
            else if (!ReceivedRoutingKey.Equals(other.ReceivedRoutingKey))
            {
                return(false);
            }

            if (Redelivered == null)
            {
                if (other.Redelivered != null)
                {
                    return(false);
                }
            }
            else if (!Redelivered.Equals(other.Redelivered))
            {
                return(false);
            }

            if (ReplyTo == null)
            {
                if (other.ReplyTo != null)
                {
                    return(false);
                }
            }
            else if (!ReplyTo.Equals(other.ReplyTo))
            {
                return(false);
            }

            if (Timestamp == null)
            {
                if (other.Timestamp != null)
                {
                    return(false);
                }
            }
            else if (!Timestamp.Equals(other.Timestamp))
            {
                return(false);
            }

            if (Type == null)
            {
                if (other.Type != null)
                {
                    return(false);
                }
            }
            else if (!Type.Equals(other.Type))
            {
                return(false);
            }

            if (UserId == null)
            {
                if (other.UserId != null)
                {
                    return(false);
                }
            }
            else if (!UserId.Equals(other.UserId))
            {
                return(false);
            }

            return(true);
        }
コード例 #15
0
 public bool Equals([AllowNull] ExtendedProperty other)
 {
     return(other != null &&
            CorrelationId.Equals(other.CorrelationId));
 }
コード例 #16
0
 public void TestRefEquals()
 {
     var c = new CorrelationId();
     Assert.IsTrue(c.Equals(c));
     Assert.IsTrue(c.Equals((object)c));
     Assert.IsFalse(c.Equals((object)null));
     Assert.IsFalse(c.Equals((CorrelationId)null));
 }
コード例 #17
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns><see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <see langword="false" />.</returns>
        public bool Equals(SampleXmlClass other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(Code == other.Code && string.Equals(String, other.String, StringComparison.InvariantCultureIgnoreCase) && CorrelationId.Equals(other.CorrelationId) && Equals(StrongTyping, other.StrongTyping));
        }
コード例 #18
0
 public bool Equals([AllowNull] ForeignKeyConstraint other)
 {
     return(other != null &&
            CorrelationId.Equals(other.CorrelationId));
 }