public void VerifyCanSetRoleNameFromHeaders()
        {
            var roleNameContainer = new RoleNameContainer(hostNameSuffix: ".azurewebsites.net");

            var headers = new HeaderDictionary();

            headers.Add("WAS-DEFAULT-HOSTNAME", "d.e.f.azurewebsites.net");
            roleNameContainer.Set(headers);

            Assert.Equal("d.e.f", roleNameContainer.RoleName);
        }
        public void VerifyWhenEnvironmentVariableIsNull()
        {
            try
            {
                Environment.SetEnvironmentVariable("WEBSITE_HOSTNAME", null);

                var roleNameContainer = new RoleNameContainer(hostNameSuffix: ".azurewebsites.net");

                Assert.Equal(string.Empty, roleNameContainer.RoleName);
                Assert.False(roleNameContainer.IsAzureWebApp);
            }
            finally
            {
                this.ClearEnvironmentVariable();
            }
        }
        public void VerifyCanSetRoleNameFromEnvironmentVariableAndSetsIsWebAppProperty()
        {
            try
            {
                Environment.SetEnvironmentVariable("WEBSITE_HOSTNAME", "a.b.c.azurewebsites.net");

                var roleNameContainer = new RoleNameContainer(hostNameSuffix: ".azurewebsites.net");

                Assert.Equal("a.b.c", roleNameContainer.RoleName);
                Assert.True(roleNameContainer.IsAzureWebApp);
            }
            finally
            {
                this.ClearEnvironmentVariable();
            }
        }
        public void VerifyEmptyHeadersDoNotOverwriteEnvironmentVaribaleValue()
        {
            try
            {
                Environment.SetEnvironmentVariable("WEBSITE_HOSTNAME", "a.b.c.azurewebsites.net");
                var roleNameContainer = new RoleNameContainer(hostNameSuffix: ".azurewebsites.net");

                Assert.Equal("a.b.c", roleNameContainer.RoleName);

                roleNameContainer.Set(new HeaderDictionary()); // empty headers

                Assert.Equal("a.b.c", roleNameContainer.RoleName);
            }
            finally
            {
                this.ClearEnvironmentVariable();
            }
        }