public void CustomHostNamesEnabled_WithConfigurationSectionTrue_ReturnsTrue()
        {
            var configFake = new KuduConfigurationSectionFake();
            configFake.SetFake("enableCustomHostNames", true);

            IKuduConfiguration config = CreateConfiguration(configFake, new NameValueCollection());
            Assert.Equal(true, config.CustomHostNamesEnabled);
        }
Пример #2
0
        public void BasicAuthCredential_WithConfigurationSection_ReturnBasicAuthCredentialProvider( ) {
            var configFake = new KuduConfigurationSectionFake( );
            configFake.SetFake( "basicAuth" , BasicAuthConfigurationElementFake.Fake( "testingUser" , "testingPw" ) );

            IKuduConfiguration config = CreateConfiguration( configFake , new NameValueCollection( ) );
            var testingCredential = new System.Net.NetworkCredential( "testingUser" , "testingPw" );
            Assert.Equal( testingCredential , config.BasicAuthCredential.GetCredentials( ) );
        }
        public void ApplicationsPath_WithConfigurationSection_ReturnsCombinedPath()
        {
            var configFake = new KuduConfigurationSectionFake();
            configFake.SetFake("applications", PathConfigurationElementFake.Fake("path", ".\\sitespath"));

            IKuduConfiguration config = CreateConfiguration(configFake, new NameValueCollection());
            string expected = Path.GetFullPath(".\\root_path\\sitespath");
            Assert.Equal(expected, config.ApplicationsPath);
        }
        public void ServiceSitePath_WithConfigurationSection_ReturnsSetting()
        {
            var configFake = new KuduConfigurationSectionFake();
            configFake.SetFake("serviceSite", PathConfigurationElementFake.Fake("path", ".\\servicepath"));

            IKuduConfiguration config = CreateConfiguration(configFake, new NameValueCollection());
            string expected = Path.GetFullPath(".\\root_path\\servicepath");
            Assert.Equal(expected, config.ServiceSitePath);
        }
 private IKuduConfiguration CreateConfiguration(KuduConfigurationSectionFake configFake, NameValueCollection appSettingsFake)
 {
     Type type = typeof(KuduConfiguration);
     ConstructorInfo ctor = type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null,
         new[] { typeof(string), typeof(KuduConfigurationSection), typeof(NameValueCollection) }, null);
     return (IKuduConfiguration)ctor.Invoke(new object[] { "root_path", configFake, appSettingsFake });
 }
        public void CertificateStores_WithMultipleElements_ConstainsSingleItem()
        {
            var configFake = new KuduConfigurationSectionFake();
            var storesFake = new CertificateStoresConfigurationElementCollectionFake();
            storesFake.Add(new CertificateStoreConfigurationElementFake()
                .SetFake("name", StoreName.Root));
            storesFake.Add(new CertificateStoreConfigurationElementFake()
                .SetFake("name", StoreName.My));

            configFake.SetFake("certificateStores", storesFake);

            IKuduConfiguration config = CreateConfiguration(configFake, new NameValueCollection());
            Assert.Equal(2, config.CertificateStores.Count());
            Assert.Equal(StoreName.Root, config.CertificateStores.ElementAt(0).Name);
            Assert.Equal(StoreName.My, config.CertificateStores.ElementAt(1).Name);
        }
        public void CertificateStores_WithEmptyConfigurationSection_DefaultsToSingleStoreMy()
        {
            var configFake = new KuduConfigurationSectionFake();
            var storesFake = new CertificateStoresConfigurationElementCollectionFake();
            configFake.SetFake("certificateStores", storesFake);

            IKuduConfiguration config = CreateConfiguration(configFake, new NameValueCollection());
            Assert.Equal(StoreName.My, config.CertificateStores.Single().Name);
        }
        public void Bindings_SingleServiceBinding_MapsToBindingConfiguration()
        {
            var configFake = new KuduConfigurationSectionFake();
            var bindingsFake = new BindingsConfigurationElementCollectionFake();
            bindingsFake.AddFake(new ServiceBindingConfigurationElementFake()
                .SetFake("scheme", UriScheme.Http)
                .SetFake("url", "kudu.svc.domain.com"));

            configFake.SetFake("bindings", bindingsFake);

            IKuduConfiguration config = CreateConfiguration(configFake, new NameValueCollection());
            Assert.Equal(1, config.Bindings.Count());
            Assert.Equal(UriScheme.Http, config.Bindings.First().Scheme);
            Assert.Equal("kudu.svc.domain.com", config.Bindings.First().Url);
            Assert.Equal(SiteType.Service, config.Bindings.First().SiteType);
        }