happy-geeks_geeks-core-library/GeeksCoreLibrary/Core/Extensions/HostEnvironmentExtensions.cs
using System;
using Microsoft.Extensions.Hosting;

namespace GeeksCoreLibrary.Core.Extensions
{
    /// <summary>
    /// Additional extension methods for <see cref="IHostEnvironment"/>.
    /// </summary>
    public static class HostEnvironmentExtensions
    {
        /// <summary>
        /// Checks if the current host environment name is Test.
        /// </summary>
        /// <param name="hostEnvironment">An instance of <see cref="IHostEnvironment"/>.</param>
        /// <returns>True if the environment name is Test, otherwise false.</returns>
        public static bool IsTest(this IHostEnvironment hostEnvironment)
        {
            if (hostEnvironment == null)
            {
                throw new ArgumentNullException(nameof(hostEnvironment));
            }

            return hostEnvironment.IsEnvironment("Test");
        }
        
        /// <summary>
        /// Checks if the current host environment name is Acceptance.
        /// </summary>
        /// <param name="hostEnvironment">An instance of <see cref="IHostEnvironment"/>.</param>
        /// <returns>True if the environment name is Acceptance, otherwise false.</returns>
        public static bool IsAcceptance(this IHostEnvironment hostEnvironment)
        {
            if (hostEnvironment == null)
            {
                throw new ArgumentNullException(nameof(hostEnvironment));
            }

            return hostEnvironment.IsEnvironment("Acceptance");
        }

        /// <summary>
        /// Checks if the current host environment name is Live.
        /// </summary>
        /// <param name="hostEnvironment">An instance of <see cref="IHostEnvironment"/>.</param>
        /// <returns>True if the environment name is Live, otherwise false.</returns>
        public static bool IsLive(this IHostEnvironment hostEnvironment)
        {
            if (hostEnvironment == null)
            {
                throw new ArgumentNullException(nameof(hostEnvironment));
            }

            return hostEnvironment.IsEnvironment("Live");
        }
    }
}
