public void when_formatting_settings_without_facility_it_should_suppress_the_facility()
 {
     var settings = new SeoSettings
     {
         TargetCity = "Plainsboro",
         TargetState = "AL"
     };
     Assert.AreEqual("- Plainsboro, (AL)", settings.ToString());
 }
 public void when_formatting_settings_without_facility_state()
 {
     var settings = new SeoSettings
     {
         FacilityName = "Princeton-Plainsboro Teaching Hospital",
         FacilityCity = "Princeton",
         TargetCity = "Plainsboro",
         TargetState = "AL"
     };
     Assert.AreEqual("- Plainsboro, (AL) - Princeton-Plainsboro Teaching Hospital, Princeton, ", settings.ToString());
 }
 public void when_formatting_settings_without_facility_name()
 {
     var settings = new SeoSettings
     {
         FacilityCity = "Princeton",
         FacilityState = "NJ",
         TargetCity = "Plainsboro",
         TargetState = "AL"
     };
     Assert.AreEqual("- Plainsboro, (AL)", settings.ToString());
 }
 public void when_formatting_settings_it_should_be_the_default_format()
 {
     var settings = new SeoSettings
     {
         FacilityName = "Princeton-Plainsboro Teaching Hospital",
         FacilityCity = "Princeton",
         FacilityState = "NJ",
         TargetCity = "Plainsboro",
         TargetState = "AL"
     };
     Assert.AreEqual("- Plainsboro, (AL) - Princeton-Plainsboro Teaching Hospital, Princeton, NJ", settings.ToString());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventPageTitle"/> class.
 /// </summary>
 /// <param name="theEvent">The event.</param>
 /// <param name="seoSettings">The seo settings.</param>
 public EventPageTitle(Event theEvent, SeoSettings seoSettings)
 {
     if (theEvent == null)
     {
         throw new ArgumentNullException("theEvent");
     }
     if (seoSettings == null)
     {
         throw new ArgumentNullException("seoSettings");
     }
     _event = theEvent;
     _seoSettings = seoSettings;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProviderPageTitle"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="seoSettings">The seo settings.</param>
 public ProviderPageTitle(Provider provider, SeoSettings seoSettings)
 {
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     if (seoSettings == null)
     {
         throw new ArgumentNullException("seoSettings");
     }
     _provider = provider;
     _seoSettings = seoSettings;
 }
        public static string GetFacilityNameCityStateText(SeoSettings settings)
        {
            string name = settings.FacilityName;
            string city = settings.FacilityCity;
            string state = settings.FacilityState;
            string targetCity = settings.TargetCity;
            string targetState = settings.TargetState;

            //If targetState = facilty state, then suppress facility state
            if (state == targetState)
                state = string.Empty;

            //If targetCity = facilty city, then suppress facility city
            if (city == targetCity)
                city = string.Empty;

            var targetCityStateText = GetCityStateText(targetCity, targetState, settings.TargetStateFullName); //We do not want full state name on target
            var cityStateText = GetCityStateText(city, state, settings.FacilityStateFullName);

            //If targetCityState = facilty city state, then suppress facility city state
            if (cityStateText == targetCityStateText)
                cityStateText = string.Empty;

            //both present
            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(cityStateText))
                return name + ", " + cityStateText;

            //neither present
            if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(cityStateText))
                return string.Empty;

            //only cityState
            if (string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(cityStateText))
                return cityStateText;

            //only facility name
            if (!string.IsNullOrEmpty(name) && string.IsNullOrEmpty(cityStateText))
                return name;

            return string.Empty;
        }
Exemple #8
0
 /// <summary>
 /// Determines whether the specified <see cref="SeoSettings" /> is equal to this instance.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 public bool Equals(SeoSettings other)
 {
     return string.Equals(FacilityName, other.FacilityName)
         && string.Equals(FacilityCity, other.FacilityCity)
         && string.Equals(FacilityState, other.FacilityState)
         && string.Equals(TargetCity, other.TargetCity)
         && string.Equals(TargetState, other.TargetState)
         && string.Equals(TargetStateFullName, other.TargetStateFullName)
         && string.Equals(DefaultMetaTags, other.DefaultMetaTags);
 }
 /// <summary>
 /// Determines whether the specified settings have same facility and target state.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <returns>
 /// 	<c>true</c> if the specified settings have same facility and target state; otherwise, <c>false</c>.
 /// </returns>
 private static bool HasSameFacilityAndTargetState(SeoSettings settings)
 {
     if (String.IsNullOrEmpty(settings.FacilityState) && String.IsNullOrEmpty(settings.TargetState))
         return true;
     return settings.FacilityState.Equals(settings.TargetState);
 }
        /// <summary>
        /// Gets the format to use.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <returns>The format string to use.</returns>
        private static string GetFormatToUse(SeoSettings settings)
        {
            string targetFormat = GetTargetFormat(settings, 0);
            string facilityFormat = GetFacilityFormat(settings, 3);

            if (String.IsNullOrEmpty(targetFormat) && String.IsNullOrEmpty(facilityFormat))
            {
                return "";
            }
            if (String.IsNullOrEmpty(targetFormat))
            {
                return "- " + facilityFormat;
            }
            if (String.IsNullOrEmpty(facilityFormat))
            {
                return "- " + targetFormat;
            }
            return "- " + targetFormat + " - " + facilityFormat;
        }
 public void when_formatting_settings_with_the_same_location_and_target_city_it_should_show_both()
 {
     var settings = new SeoSettings
     {
         FacilityName = "Princeton-Plainsboro Teaching Hospital",
         FacilityCity = "Princeton",
         FacilityState = "NJ",
         TargetCity = "Princeton",
         TargetState = "AL"
     };
     Assert.AreEqual("- Princeton, (AL) - Princeton-Plainsboro Teaching Hospital ", settings.ToString());
 }
 private static SeoSettings CreateSeoSettingsForDifferentMarketArea()
 {
     var settings = new SeoSettings();
     settings.FacilityCity = Guid.NewGuid().ToString();
     settings.FacilityName = Guid.NewGuid().ToString();
     settings.FacilityState = Guid.NewGuid().ToString();
     settings.TargetCity = Guid.NewGuid().ToString();
     settings.TargetState = Guid.NewGuid().ToString();
     return settings;
 }
 public void when_formatting_settings_without_target_it_should_suppress_the_target()
 {
     var settings = new SeoSettings
     {
         FacilityName = "Princeton-Plainsboro Teaching Hospital",
         FacilityCity = "Princeton",
         FacilityState = "NJ"
     };
     Assert.AreEqual("- Princeton-Plainsboro Teaching Hospital, Princeton, NJ", settings.ToString());
 }
 public void when_formatting_settings_with_the_same_location_and_target_state_it_should_suppress_the_location_state()
 {
     var settings = new SeoSettings
     {
         FacilityName = "Princeton-Plainsboro Teaching Hospital",
         FacilityCity = "Princeton",
         FacilityState = "NJ",
         TargetCity = "Plainsboro",
         TargetState = "NJ"
     };
     Assert.AreEqual("- Plainsboro, (NJ) - Princeton-Plainsboro Teaching Hospital, Princeton", settings.ToString());
 }
 /// <summary>
 /// Gets the format for the facility section of the settings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="startingIndex">The index of the first element in the format.</param>
 /// <returns>The format.</returns>
 internal static String GetFacilityFormat(SeoSettings settings, int startingIndex)
 {
     if (String.IsNullOrEmpty(settings.FacilityName) && String.IsNullOrEmpty(settings.FacilityCity) && String.IsNullOrEmpty(settings.FacilityState))
     {
         return null;
     }
     var format = new StringBuilder();
     if (!String.IsNullOrEmpty(settings.FacilityName))
     {
         format.Append("{").Append(startingIndex).Append("}");
     }
     if (!String.IsNullOrEmpty(settings.FacilityCity) && (HasSameFacilityAndTargetCity(settings)))
     {
         format.Append(" ");
     }
     else if (!String.IsNullOrEmpty(settings.FacilityState) && (HasSameFacilityAndTargetState(settings)))
     {
         if (format.Length > 0)
         {
             format.Append(", ").Append("{").Append(startingIndex + 1).Append("}");
         }
     }
     else
     {
         if (format.Length > 0)
         {
             format.Append(", ").Append("{").Append(startingIndex + 1).Append("}").Append(", ").Append("{").Append(startingIndex + 2).Append("}");
         }
     }
     return format.ToString();
 }
 public override void SetUp()
 {
     base.SetUp();
     _seoSettingsForDifferentMarketArea = CreateSeoSettingsForDifferentMarketArea();
     _seoSettingsForMatchingMarketArea = CreateSeoSettingsForMatchingMarketArea();
     _seoSettingsForDifferentFacility = CreateSeoSettingsForDifferentFacility();
     _seoSettingsForMatchingFacility = CreateSeoSettingsForMatchingFacility();
 }
 /// <summary>
 /// Gets the format for the target section of the settings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="startingIndex">The index of the first element in the format.</param>
 /// <returns>The format.</returns>
 internal static String GetTargetFormat(SeoSettings settings, int startingIndex)
 {
     if (String.IsNullOrEmpty(settings.TargetCity) && String.IsNullOrEmpty(settings.TargetState))
     {
         return null;
     }
     if (String.IsNullOrEmpty(settings.TargetCity))
     {
         return "{" + (startingIndex + 1) + "} ({" + (startingIndex + 2) + "})";
     }
     if (String.IsNullOrEmpty(settings.TargetState))
     {
         return "{" + startingIndex + "}";
     }
     return "{" + startingIndex + "}, {" + (startingIndex + 1) + "} ({" + (startingIndex + 2) + "})";
 }
 private static SeoSettings CreateSeoSettingsForMatchingMarketArea()
 {
     var settings = new SeoSettings();
     settings.FacilityCity = Guid.NewGuid().ToString();
     settings.FacilityName = Guid.NewGuid().ToString();
     settings.FacilityState = Guid.NewGuid().ToString();
     settings.TargetCity = "Birmingham";
     settings.TargetState = "AL";
     return settings;
 }
 public void when_formatting_blank_settings_it_should_be_blank()
 {
     var settings = new SeoSettings();
     Assert.AreEqual(string.Empty, settings.ToString());
 }