Exemple #1
0
        /// <summary>
        /// Overloaded ToString function for formatting the output on the console.
        /// </summary>
        /// <param name="partitionHealthState"> Object of type PartitionHealthState </param>
        /// <returns>
        /// Returns formatted string.
        /// </returns>
        public static string ToString(PartitionHealthState partitionHealthState)
        {
            var strBuilder = new StringBuilder();

            strBuilder.Append(string.Format(CultureInfo.CurrentCulture, "{0, -21} : {1}", "PartitionId", partitionHealthState.PartitionId));
            strBuilder.Append(Environment.NewLine);
            strBuilder.Append(string.Format(CultureInfo.CurrentCulture, "{0, -21} : {1}", "AggregatedHealthState", partitionHealthState.AggregatedHealthState));
            strBuilder.Append(Environment.NewLine);

            return(strBuilder.ToString());
        }
Exemple #2
0
        /// <summary>
        /// Serializes the object to JSON.
        /// </summary>
        /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param>
        /// <param name="obj">The object to serialize to JSON.</param>
        internal static void Serialize(JsonWriter writer, PartitionHealthState obj)
        {
            // Required properties are always serialized, optional properties are serialized when not null.
            writer.WriteStartObject();
            writer.WriteProperty(obj.AggregatedHealthState, "AggregatedHealthState", HealthStateConverter.Serialize);
            if (obj.PartitionId != null)
            {
                writer.WriteProperty(obj.PartitionId, "PartitionId", PartitionIdConverter.Serialize);
            }

            writer.WriteEndObject();
        }
        public void ServiceHealthSerializationTest()
        {
            ServiceHealth serviceHealth = this.random.CreateRandom <ServiceHealth>();

            var partitionHealthState = new PartitionHealthState()
            {
                AggregatedHealthState = this.random.CreateRandom <HealthState>(),
                PartitionId           = Guid.NewGuid()
            };

            serviceHealth.PartitionHealthStates = new List <PartitionHealthState>()
            {
                partitionHealthState
            };

            TestUsingSerializer(this.Serializer, serviceHealth);
        }