< Summary

Class:Azure.Messaging.EventGrid.CloudEvent
Assembly:Azure.Messaging.EventGrid
File(s):C:\Git\azure-sdk-for-net\sdk\eventgrid\Azure.Messaging.EventGrid\src\Customization\CloudEvent.cs
Covered lines:16
Uncovered lines:0
Coverable lines:16
Total lines:56
Line coverage:100% (16 of 16)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Id()-100%100%
get_Source()-100%100%
get_Data()-100%100%
get_Type()-100%100%
get_Time()-100%100%
get_DataSchema()-100%100%
get_DataContentType()-100%100%
get_Subject()-100%100%
get_ExtensionAttributes()-100%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections;
 6using System.Collections.Generic;
 7using Azure.Core;
 8
 9namespace Azure.Messaging.EventGrid
 10{
 11    /// <summary> Properties of an event published to an Event Grid topic using the CloudEvent 1.0 Schema. </summary>
 12    public class CloudEvent
 13    {
 14        /// <summary> Initializes a new instance of CloudEvent. </summary>
 15        /// <param name="source"> Identifies the context in which an event happened. The combination of id and source mu
 16        /// <param name="type"> Type of event related to the originating occurrence. </param>
 23417        public CloudEvent(string source, string type)
 18        {
 23419            Argument.AssertNotNull(source, nameof(source));
 23420            Argument.AssertNotNull(type, nameof(type));
 21
 23422            Source = source;
 23423            Type = type;
 23424            ExtensionAttributes = new Dictionary<string, object>();
 23425        }
 26
 27        /// <summary> An identifier for the event. The combination of id and source must be unique for each distinct eve
 68828        public string Id { get; set; } = Guid.NewGuid().ToString();
 29
 30        /// <summary> Identifies the context in which an event happened. The combination of id and source must be unique
 45431        public string Source { get; set; }
 32
 33        /// <summary> Event data specific to the event type. </summary>
 99434        public object Data { get; set; }
 35
 36        /// <summary> Type of event related to the originating occurrence. </summary>
 45837        public string Type { get; set; }
 38
 39        /// <summary> The time (in UTC) the event was generated, in RFC3339 format. </summary>
 68840        public DateTimeOffset? Time { get; set; } = DateTimeOffset.UtcNow;
 41
 42        /// <summary> Identifies the schema that data adheres to. </summary>
 23443        public string DataSchema { get; set; }
 44
 45        /// <summary> Content type of data value. </summary>
 23446        public string DataContentType { get; set; }
 47
 48        /// <summary> This describes the subject of the event in the context of the event producer (identified by source
 45449        public string Subject { get; set; }
 50
 51        /// <summary>
 52        /// Extension attributes that can be additionally added to the CloudEvent envelope.
 53        /// </summary>
 30054        public Dictionary<string, object> ExtensionAttributes { get; }
 55    }
 56}