/// <summary>
        /// Copies this FCM options, and validates the content of it to ensure that it can
        /// be serialized into the JSON format expected by the FCM service.
        /// </summary>
        internal FcmOptions CopyAndValidate()
        {
            var copy = new FcmOptions()
            {
                AnalyticsLabel = this.AnalyticsLabel,
            };

            AnalyticsLabelChecker.ValidateAnalyticsLabel(copy.AnalyticsLabel);

            return(copy);
        }
        /// <summary>
        /// Copies this FCM options, and validates the content of it to ensure that it can
        /// be serialized into the JSON format expected by the FCM service.
        /// </summary>
        internal ApnsFcmOptions CopyAndValidate()
        {
            var copy = new ApnsFcmOptions()
            {
                AnalyticsLabel = this.AnalyticsLabel,
                ImageUrl       = this.ImageUrl,
            };

            AnalyticsLabelChecker.ValidateAnalyticsLabel(copy.AnalyticsLabel);

            if (copy.ImageUrl != null && !Uri.IsWellFormedUriString(copy.ImageUrl, UriKind.Absolute))
            {
                throw new ArgumentException($"Malformed image URL string: {copy.ImageUrl}.");
            }

            return(copy);
        }
 public void AnalyticsLabelInvalidCharacters()
 {
     Assert.Throws <ArgumentException>(() => AnalyticsLabelChecker.ValidateAnalyticsLabel("label(label)"));
 }
 public void AnalyticsLabelEmtpty()
 {
     Assert.Throws <ArgumentException>(() => AnalyticsLabelChecker.ValidateAnalyticsLabel(string.Empty));
 }
 public void AnalyticsLabelTooLong()
 {
     Assert.Throws <ArgumentException>(() => AnalyticsLabelChecker.ValidateAnalyticsLabel(new string('a', 51)));
 }