Ejemplo n.º 1
0
        public void TestJsonCreationForHost()
        {
            var config = new HostConfig
            {
                Runtime =
                {
                    Audit = new AuditElement {Enabled = true},
                    LogInfo = new LogElement
                    {
                        ProviderType = "KonfDB.Infrastructure.Logging.Logger, KonfDBC",
                        Parameters = @"-path:konfdb\log.txt"
                    },
                    ServiceSecurity = ServiceSecurityMode.None
                }
            };
            config.Runtime.Server.Add(new ServiceTypeConfiguration {Port = 8885, Type = EndPointType.TCP});
            config.Runtime.Server.Add(new ServiceTypeConfiguration {Port = 8880, Type = EndPointType.HTTP});
            config.Runtime.Server.Add(new ServiceTypeConfiguration {Port = 8890, Type = EndPointType.WSHTTP});
            config.Runtime.Server.Add(new ServiceTypeConfiguration {Port = 8882, Type = EndPointType.REST});
            config.Runtime.SuperUser.Username = "******";
            config.Runtime.SuperUser.Password = "******";

            config.Caching.Enabled = false;
            config.Caching.ProviderType = typeof (InMemoryCacheStore).AssemblyQualifiedName;
            config.Caching.Parameters = "-duration:30 -mode:Absolute";

            config.Certificate.DefaultKey = "testCert";
            config.Certificate.Certificates.Add(new CertificateProviderConfiguration
            {
                CertificateKey = "testCert",
                StoreLocation = StoreLocation.LocalMachine,
                StoreName = StoreName.My,
                FindBy = X509FindType.FindBySubjectName,
                Value = "localhost"
            });

            config.Database.DefaultKey = "localsql";
            config.Database.Databases.Add(new DatabaseProviderConfiguration
            {
                Key = "localsql",
                Host = @"localhost\sqlexpress",
                Port = 8080,
                InstanceName = "konf",
                Username = "******",
                Password = "******",
                Location = @"c:\temp",
                ProviderType = "MsSql"
            });
            config.Database.Databases.Add(new DatabaseProviderConfiguration
            {
                Key = "azure",
                Host = @"tcp:lbxcft14aq.database.windows.net",
                Port = 1433,
                InstanceName = "dbName",
                Username = "******",
                Password = "******",
                ProviderType = "AzureSql"
            });

            var configJson = config.ToJson();
            var readBack = configJson.FromJsonToObject<HostConfig>();
            Assert.IsNotNull(readBack);
        }