< Summary

Class:Azure.Messaging.EventGrid.Models.CloudEventInternal
Assembly:Azure.Messaging.EventGrid
File(s):C:\Git\azure-sdk-for-net\sdk\eventgrid\Azure.Messaging.EventGrid\src\Customization\CloudEventInternal.cs
C:\Git\azure-sdk-for-net\sdk\eventgrid\Azure.Messaging.EventGrid\src\Generated\Models\CloudEventInternal.cs
C:\Git\azure-sdk-for-net\sdk\eventgrid\Azure.Messaging.EventGrid\src\Generated\Models\CloudEventInternal.Serialization.cs
Covered lines:103
Uncovered lines:32
Coverable lines:135
Total lines:290
Line coverage:76.2% (103 of 135)
Covered branches:36
Total branches:46
Branch coverage:78.2% (36 of 46)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Id()-100%100%
get_Source()-100%100%
get_DataBase64()-100%100%
get_Type()-100%100%
get_Time()-100%100%
get_Specversion()-100%100%
get_Dataschema()-100%100%
get_Datacontenttype()-100%100%
get_Subject()-100%100%
get_AdditionalProperties()-100%100%
GetEnumerator()-100%100%
System.Collections.IEnumerable.GetEnumerator()-100%100%
TryGetValue(...)-100%100%
ContainsKey(...)-100%100%
get_Keys()-100%100%
get_Values()-100%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.get_Count()-100%100%
Add(...)-100%100%
Remove(...)-100%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.get_IsReadOnly()-100%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Add(...)-100%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Remove(...)-100%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Contains(...)-100%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.CopyTo(...)-100%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Clear()-100%100%
get_Item(...)-100%100%
set_Item(...)-100%100%
.ctor(...)-100%100%
get_Data()-100%100%
.ctor(...)-73.33%50%
.ctor(...)-100%100%
get_Id()-100%100%
get_Source()-100%100%
get_DataBase64()-100%100%
get_Type()-100%100%
get_Time()-100%100%
get_Specversion()-100%100%
get_Dataschema()-100%100%
get_Datacontenttype()-100%100%
get_Subject()-100%100%
get_AdditionalProperties()-100%100%
GetEnumerator()-0%100%
System.Collections.IEnumerable.GetEnumerator()-0%100%
TryGetValue(...)-0%100%
ContainsKey(...)-0%100%
get_Keys()-0%100%
get_Values()-0%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.get_Count()-0%100%
Add(...)-100%100%
Remove(...)-0%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.get_IsReadOnly()-0%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Add(...)-0%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Remove(...)-0%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Contains(...)-0%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.CopyTo(...)-0%100%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Clear()-0%100%
get_Item(...)-0%100%
set_Item(...)-0%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-87.5%85.71%
DeserializeCloudEventInternal(...)-82.98%83.33%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventgrid\Azure.Messaging.EventGrid\src\Customization\CloudEventInternal.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Text;
 7using System.Text.Json;
 8using Azure.Core;
 9
 10namespace Azure.Messaging.EventGrid.Models
 11{
 12    [CodeGenModel("CloudEvent")]
 13    internal partial class CloudEventInternal
 14    {
 48615        public JsonElement? Data { get; set; }
 16    }
 17}

C:\Git\azure-sdk-for-net\sdk\eventgrid\Azure.Messaging.EventGrid\src\Generated\Models\CloudEventInternal.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections;
 10using System.Collections.Generic;
 11using System.Text.Json;
 12using Azure.Core;
 13
 14namespace Azure.Messaging.EventGrid.Models
 15{
 16    /// <summary> Properties of an event published to an Event Grid topic using the CloudEvent 1.0 Schema. </summary>
 17    internal partial class CloudEventInternal : IDictionary<string, object>
 18    {
 19        /// <summary> Initializes a new instance of CloudEventInternal. </summary>
 20        /// <param name="id"> An identifier for the event. The combination of id and source must be unique for each dist
 21        /// <param name="source"> Identifies the context in which an event happened. The combination of id and source mu
 22        /// <param name="type"> Type of event related to the originating occurrence. </param>
 23        /// <param name="specversion"> The version of the CloudEvents specification which the event uses. </param>
 24        /// <exception cref="ArgumentNullException"> <paramref name="id"/>, <paramref name="source"/>, <paramref name="t
 11025        public CloudEventInternal(string id, string source, string type, string specversion)
 26        {
 11027            if (id == null)
 28            {
 029                throw new ArgumentNullException(nameof(id));
 30            }
 11031            if (source == null)
 32            {
 033                throw new ArgumentNullException(nameof(source));
 34            }
 11035            if (type == null)
 36            {
 037                throw new ArgumentNullException(nameof(type));
 38            }
 11039            if (specversion == null)
 40            {
 041                throw new ArgumentNullException(nameof(specversion));
 42            }
 43
 11044            Id = id;
 11045            Source = source;
 11046            Type = type;
 11047            Specversion = specversion;
 11048            AdditionalProperties = new ChangeTrackingDictionary<string, object>();
 11049        }
 50
 51        /// <summary> Initializes a new instance of CloudEventInternal. </summary>
 52        /// <param name="id"> An identifier for the event. The combination of id and source must be unique for each dist
 53        /// <param name="source"> Identifies the context in which an event happened. The combination of id and source mu
 54        /// <param name="data"> Event data specific to the event type. </param>
 55        /// <param name="dataBase64"> Event data specific to the event type, encoded as a base64 string. </param>
 56        /// <param name="type"> Type of event related to the originating occurrence. </param>
 57        /// <param name="time"> The time (in UTC) the event was generated, in RFC3339 format. </param>
 58        /// <param name="specversion"> The version of the CloudEvents specification which the event uses. </param>
 59        /// <param name="dataschema"> Identifies the schema that data adheres to. </param>
 60        /// <param name="datacontenttype"> Content type of data value. </param>
 61        /// <param name="subject"> This describes the subject of the event in the context of the event producer (identif
 62        /// <param name="additionalProperties"> . </param>
 763        internal CloudEventInternal(string id, string source, JsonElement? data, string dataBase64, string type, DateTim
 64        {
 765            Id = id;
 766            Source = source;
 767            Data = data;
 768            DataBase64 = dataBase64;
 769            Type = type;
 770            Time = time;
 771            Specversion = specversion;
 772            Dataschema = dataschema;
 773            Datacontenttype = datacontenttype;
 774            Subject = subject;
 775            AdditionalProperties = additionalProperties;
 776        }
 77
 78        /// <summary> An identifier for the event. The combination of id and source must be unique for each distinct eve
 23479        public string Id { get; set; }
 80        /// <summary> Identifies the context in which an event happened. The combination of id and source must be unique
 23481        public string Source { get; set; }
 82        /// <summary> Event data specific to the event type, encoded as a base64 string. </summary>
 18583        public string DataBase64 { get; set; }
 84        /// <summary> Type of event related to the originating occurrence. </summary>
 24485        public string Type { get; set; }
 86        /// <summary> The time (in UTC) the event was generated, in RFC3339 format. </summary>
 34487        public DateTimeOffset? Time { get; set; }
 88        /// <summary> The version of the CloudEvents specification which the event uses. </summary>
 22789        public string Specversion { get; set; }
 90        /// <summary> Identifies the schema that data adheres to. </summary>
 23491        public string Dataschema { get; set; }
 92        /// <summary> Content type of data value. </summary>
 23493        public string Datacontenttype { get; set; }
 94        /// <summary> This describes the subject of the event in the context of the event producer (identified by source
 34495        public string Subject { get; set; }
 15096        internal IDictionary<string, object> AdditionalProperties { get; }
 97        /// <inheritdoc />
 098        public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => AdditionalProperties.GetEnumerator();
 99        /// <inheritdoc />
 0100        IEnumerator IEnumerable.GetEnumerator() => AdditionalProperties.GetEnumerator();
 101        /// <inheritdoc />
 0102        public bool TryGetValue(string key, out object value) => AdditionalProperties.TryGetValue(key, out value);
 103        /// <inheritdoc />
 0104        public bool ContainsKey(string key) => AdditionalProperties.ContainsKey(key);
 105        /// <inheritdoc />
 0106        public ICollection<string> Keys => AdditionalProperties.Keys;
 107        /// <inheritdoc />
 0108        public ICollection<object> Values => AdditionalProperties.Values;
 109        /// <inheritdoc />
 0110        int ICollection<KeyValuePair<string, object>>.Count => AdditionalProperties.Count;
 111        /// <inheritdoc />
 40112        public void Add(string key, object value) => AdditionalProperties.Add(key, value);
 113        /// <inheritdoc />
 0114        public bool Remove(string key) => AdditionalProperties.Remove(key);
 115        /// <inheritdoc />
 0116        bool ICollection<KeyValuePair<string, object>>.IsReadOnly => AdditionalProperties.IsReadOnly;
 117        /// <inheritdoc />
 0118        void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> value) => AdditionalProperties.A
 119        /// <inheritdoc />
 0120        bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> value) => AdditionalPropertie
 121        /// <inheritdoc />
 0122        bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> value) => AdditionalPropert
 123        /// <inheritdoc />
 0124        void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] destination, int offset) =>
 125        /// <inheritdoc />
 0126        void ICollection<KeyValuePair<string, object>>.Clear() => AdditionalProperties.Clear();
 127        /// <inheritdoc />
 128        public object this[string key]
 129        {
 0130            get => AdditionalProperties[key];
 0131            set => AdditionalProperties[key] = value;
 132        }
 133    }
 134}

C:\Git\azure-sdk-for-net\sdk\eventgrid\Azure.Messaging.EventGrid\src\Generated\Models\CloudEventInternal.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using System.Text.Json;
 11using Azure.Core;
 12
 13namespace Azure.Messaging.EventGrid.Models
 14{
 15    internal partial class CloudEventInternal : IUtf8JsonSerializable
 16    {
 17        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 18        {
 22019            writer.WriteStartObject();
 22020            writer.WritePropertyName("id");
 22021            writer.WriteStringValue(Id);
 22022            writer.WritePropertyName("source");
 22023            writer.WriteStringValue(Source);
 22024            if (Optional.IsDefined(Data))
 25            {
 12026                writer.WritePropertyName("data");
 12027                Data.Value.WriteTo(writer);
 28            }
 22029            if (Optional.IsDefined(DataBase64))
 30            {
 6031                writer.WritePropertyName("data_base64");
 6032                writer.WriteStringValue(DataBase64);
 33            }
 22034            writer.WritePropertyName("type");
 22035            writer.WriteStringValue(Type);
 22036            if (Optional.IsDefined(Time))
 37            {
 22038                writer.WritePropertyName("time");
 22039                writer.WriteStringValue(Time.Value, "O");
 40            }
 22041            writer.WritePropertyName("specversion");
 22042            writer.WriteStringValue(Specversion);
 22043            if (Optional.IsDefined(Dataschema))
 44            {
 045                writer.WritePropertyName("dataschema");
 046                writer.WriteStringValue(Dataschema);
 47            }
 22048            if (Optional.IsDefined(Datacontenttype))
 49            {
 050                writer.WritePropertyName("datacontenttype");
 051                writer.WriteStringValue(Datacontenttype);
 52            }
 22053            if (Optional.IsDefined(Subject))
 54            {
 22055                writer.WritePropertyName("subject");
 22056                writer.WriteStringValue(Subject);
 57            }
 60058            foreach (var item in AdditionalProperties)
 59            {
 8060                writer.WritePropertyName(item.Key);
 8061                writer.WriteObjectValue(item.Value);
 62            }
 22063            writer.WriteEndObject();
 22064        }
 65
 66        internal static CloudEventInternal DeserializeCloudEventInternal(JsonElement element)
 67        {
 1468            string id = default;
 1469            string source = default;
 1470            Optional<JsonElement> data = default;
 1471            Optional<string> dataBase64 = default;
 1472            string type = default;
 1473            Optional<DateTimeOffset> time = default;
 1474            string specversion = default;
 1475            Optional<string> dataschema = default;
 1476            Optional<string> datacontenttype = default;
 1477            Optional<string> subject = default;
 1478            IDictionary<string, object> additionalProperties = default;
 1479            Dictionary<string, object> additionalPropertiesDictionary = default;
 16080            foreach (var property in element.EnumerateObject())
 81            {
 6682                if (property.NameEquals("id"))
 83                {
 1484                    id = property.Value.GetString();
 1485                    continue;
 86                }
 5287                if (property.NameEquals("source"))
 88                {
 1489                    source = property.Value.GetString();
 1490                    continue;
 91                }
 3892                if (property.NameEquals("data"))
 93                {
 1094                    data = property.Value.Clone();
 1095                    continue;
 96                }
 2897                if (property.NameEquals("data_base64"))
 98                {
 299                    dataBase64 = property.Value.GetString();
 2100                    continue;
 101                }
 26102                if (property.NameEquals("type"))
 103                {
 10104                    type = property.Value.GetString();
 10105                    continue;
 106                }
 16107                if (property.NameEquals("time"))
 108                {
 0109                    time = property.Value.GetDateTimeOffset("O");
 0110                    continue;
 111                }
 16112                if (property.NameEquals("specversion"))
 113                {
 14114                    specversion = property.Value.GetString();
 14115                    continue;
 116                }
 2117                if (property.NameEquals("dataschema"))
 118                {
 0119                    dataschema = property.Value.GetString();
 0120                    continue;
 121                }
 2122                if (property.NameEquals("datacontenttype"))
 123                {
 0124                    datacontenttype = property.Value.GetString();
 0125                    continue;
 126                }
 2127                if (property.NameEquals("subject"))
 128                {
 0129                    subject = property.Value.GetString();
 0130                    continue;
 131                }
 2132                additionalPropertiesDictionary ??= new Dictionary<string, object>();
 2133                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
 134            }
 14135            additionalProperties = additionalPropertiesDictionary;
 14136            return new CloudEventInternal(id, source, Optional.ToNullable(data), dataBase64.Value, type, Optional.ToNull
 137        }
 138    }
 139}