< Summary

Class:Azure.Messaging.EventHubs.Consumer.LastEnqueuedEventProperties
Assembly:Azure.Messaging.EventHubs
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.Messaging.EventHubs\src\Consumer\LastEnqueuedEventProperties.cs
Covered lines:31
Uncovered lines:1
Coverable lines:32
Total lines:157
Line coverage:96.8% (31 of 32)
Covered branches:21
Total branches:24
Branch coverage:87.5% (21 of 24)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_SequenceNumber()-100%100%
get_Offset()-100%100%
get_EnqueuedTime()-100%100%
get_LastReceivedTime()-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
Equals(...)-100%85.71%
Equals(...)-80%50%
GetHashCode()-100%100%
ToString()-100%100%
op_Equality(...)-100%100%
op_Inequality(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.Messaging.EventHubs\src\Consumer\LastEnqueuedEventProperties.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.ComponentModel;
 6using Azure.Core;
 7
 8namespace Azure.Messaging.EventHubs.Consumer
 9{
 10    /// <summary>
 11    ///   A set of information about the enqueued state of a partition, as observed by the consumer.
 12    /// </summary>
 13    ///
 14    public struct LastEnqueuedEventProperties : IEquatable<LastEnqueuedEventProperties>
 15    {
 16        /// <summary>
 17        ///   The sequence number of the last observed event to be enqueued in the partition.
 18        /// </summary>
 19        ///
 9420        public long? SequenceNumber { get; }
 21
 22        /// <summary>
 23        ///   The offset of the last observed event to be enqueued in the partition.
 24        /// </summary>
 25        ///
 11026        public long? Offset { get; }
 27
 28        /// <summary>
 29        ///   The date and time, in UTC, that the last observed event was enqueued in the partition.
 30        /// </summary>
 31        ///
 7832        public DateTimeOffset? EnqueuedTime { get; }
 33
 34        /// <summary>
 35        ///   The date and time, in UTC, that the information about the last enqueued event was received.
 36        /// </summary>
 37        ///
 6238        public DateTimeOffset? LastReceivedTime { get; }
 39
 40        /// <summary>
 41        ///   Initializes a new instance of the <see cref="LastEnqueuedEventProperties"/> class.
 42        /// </summary>
 43        ///
 44        /// <param name="lastSequenceNumber">The sequence number observed the last event to be enqueued in the partition
 45        /// <param name="lastOffset">The offset of the last event to be enqueued in the partition.</param>
 46        /// <param name="lastEnqueuedTime">The date and time, in UTC, that the last event was enqueued in the partition.
 47        /// <param name="lastReceivedTime">The date and time, in UTC, that the information was last received.</param>
 48        ///
 49        public LastEnqueuedEventProperties(long? lastSequenceNumber,
 50                                           long? lastOffset,
 51                                           DateTimeOffset? lastEnqueuedTime,
 52                                           DateTimeOffset? lastReceivedTime)
 53        {
 4854            SequenceNumber = lastSequenceNumber;
 4855            Offset = lastOffset;
 4856            EnqueuedTime = lastEnqueuedTime;
 4857            LastReceivedTime = lastReceivedTime;
 4858        }
 59
 60        /// <summary>
 61        ///   Initializes a new instance of the <see cref="LastEnqueuedEventProperties"/> class.
 62        /// </summary>
 63        ///
 64        /// <param name="sourceEvent">The event to use as the source for the partition information.</param>
 65        ///
 66        internal LastEnqueuedEventProperties(EventData sourceEvent) :
 1867            this(sourceEvent?.LastPartitionSequenceNumber,
 1868                 sourceEvent?.LastPartitionOffset,
 1869                 sourceEvent?.LastPartitionEnqueuedTime,
 1870                 sourceEvent?.LastPartitionPropertiesRetrievalTime)
 71        {
 1872        }
 73
 74        /// <summary>
 75        ///   Determines whether the specified <see cref="LastEnqueuedEventProperties" /> is equal to this instance.
 76        /// </summary>
 77        ///
 78        /// <param name="other">The <see cref="LastEnqueuedEventProperties" /> to compare with this instance.</param>
 79        ///
 80        /// <returns><c>true</c> if the specified <see cref="LastEnqueuedEventProperties" /> is equal to this instance; 
 81        ///
 82        public bool Equals(LastEnqueuedEventProperties other)
 83        {
 4884            return (Offset == other.Offset)
 4885                && (SequenceNumber == other.SequenceNumber)
 4886                && (EnqueuedTime == other.EnqueuedTime)
 4887                && (LastReceivedTime == other.LastReceivedTime);
 88        }
 89
 90        /// <summary>
 91        ///   Determines whether the specified <see cref="System.Object" /> is equal to this instance.
 92        /// </summary>
 93        ///
 94        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
 95        ///
 96        /// <returns><c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>
 97        ///
 98        [EditorBrowsable(EditorBrowsableState.Never)]
 99        public override bool Equals(object obj) =>
 10100            obj switch
 10101            {
 20102                LastEnqueuedEventProperties other => Equals(other),
 0103                _ => false
 10104            };
 105
 106        /// <summary>
 107        ///   Returns a hash code for this instance.
 108        /// </summary>
 109        ///
 110        /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a ha
 111        ///
 112        [EditorBrowsable(EditorBrowsableState.Never)]
 113        public override int GetHashCode()
 114        {
 4115            var hashCode = new HashCodeBuilder();
 4116            hashCode.Add(Offset);
 4117            hashCode.Add(SequenceNumber);
 4118            hashCode.Add(EnqueuedTime);
 4119            hashCode.Add(LastReceivedTime);
 120
 4121            return hashCode.ToHashCode();
 122        }
 123
 124        /// <summary>
 125        ///   Converts the instance to string representation.
 126        /// </summary>
 127        ///
 128        /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
 129        ///
 130        [EditorBrowsable(EditorBrowsableState.Never)]
 2131        public override string ToString() => $"Sequence: [{ SequenceNumber }] | Offset: [{ Offset }] | Enqueued: [{ Enqu
 132
 133        /// <summary>
 134        ///   Determines whether the specified <see cref="LastEnqueuedEventProperties" /> instances are equal to each ot
 135        /// </summary>
 136        ///
 137        /// <param name="left">The first <see cref="LastEnqueuedEventProperties" /> to consider.</param>
 138        /// <param name="right">The second <see cref="LastEnqueuedEventProperties" /> to consider.</param>
 139        ///
 140        /// <returns><c>true</c> if the two specified <see cref="LastEnqueuedEventProperties" /> instances are equal; ot
 141        ///
 142        public static bool operator ==(LastEnqueuedEventProperties left,
 10143                                       LastEnqueuedEventProperties right) => left.Equals(right);
 144
 145        /// <summary>
 146        ///   Determines whether the specified <see cref="LastEnqueuedEventProperties" /> instances are not equal to eac
 147        /// </summary>
 148        ///
 149        /// <param name="left">The first <see cref="LastEnqueuedEventProperties" /> to consider.</param>
 150        /// <param name="right">The second <see cref="LastEnqueuedEventProperties" /> to consider.</param>
 151        ///
 152        /// <returns><c>true</c> if the two specified <see cref="LastEnqueuedEventProperties" /> instances are not equal
 153        ///
 154        public static bool operator !=(LastEnqueuedEventProperties left,
 10155                                       LastEnqueuedEventProperties right) => (!left.Equals(right));
 156    }
 157}