Exemplo n.º 1
0
        public void TestDescriptor()
        {
            var componentConfig = new ComponentConfig();

            Assert.Null(componentConfig.Descriptor);

            var descriptor = new Descriptor("group", "type", "id", "default", "version");

            componentConfig.Descriptor = descriptor;
            Assert.Equal(componentConfig.Descriptor, descriptor);
        }
Exemplo n.º 2
0
        public void TestType()
        {
            var componentConfig = new ComponentConfig();

            Assert.Null(componentConfig.Type);

            var type = new TypeDescriptor("new name", null);

            componentConfig.Type = type;
            Assert.Equal(componentConfig.Type, type);
        }
Exemplo n.º 3
0
        public void TestConfigParams()
        {
            var componentConfig = new ComponentConfig();

            Assert.Null(componentConfig.Config);

            var config = ConfigParams.FromTuples(
                "config.key", "key",
                "config.key2", "key2"
                );

            componentConfig.Config = config;
            Assert.Equal(componentConfig.Config, config);
        }
Exemplo n.º 4
0
        public void TestFromConfig()
        {
            var             config = ConfigParams.FromTuples();
            ComponentConfig componentConfig;

            try
            {
                componentConfig = ComponentConfig.FromConfig(config);
            }
            catch (ConfigException e)
            {
                Assert.Equal(e.Message, "Component configuration must have descriptor or type");
            }

            config = ConfigParams.FromTuples(
                "descriptor", "descriptor_name",
                "type", "type",
                "config.key", "key",
                "config.key2", "key2"
                );

            try
            {
                componentConfig = ComponentConfig.FromConfig(config);
            }
            catch (ConfigException e)
            {
                Assert.Equal(e.Message, "Descriptor descriptor_name is in wrong format");
            }

            var descriptor = new Descriptor("group", "type", "id", "name", "version");
            var type       = new TypeDescriptor("type", null);

            config = ConfigParams.FromTuples(
                "descriptor", "group:type:id:name:version",
                "type", "type",
                "config.key", "key",
                "config.key2", "key2"
                );
            componentConfig = ComponentConfig.FromConfig(config);

            Assert.Equal(componentConfig.Descriptor, descriptor);
            Assert.Equal(componentConfig.Type, type);
        }