public void GivenColumnWithMultiExpressionInSamePath_WhenResolveDefinitionNode_ResolveDefinitionNodesShouldBeReturn()
        {
            Dictionary <string, PropertiesGroup> propertiesGroups = new Dictionary <string, PropertiesGroup>();

            var properties = new List <Property>();

            properties.Add(new Property()
            {
                Name           = "TestName1",
                Path           = "",
                FhirExpression = "testExpression1"
            });
            properties.Add(new Property()
            {
                Name           = "TestName2",
                Path           = "",
                FhirExpression = "testExpression2"
            });
            TabularTable table = new TabularTable();

            table.Properties = properties;

            TabularMappingDefinition defination = BaseMappingDefinitionLoader.BuildMappingDefinition(table, propertiesGroups, 5);

            Assert.AreEqual("TestName1", defination.Root.ColumnDefinitions[0].Name);
            Assert.AreEqual("testExpression1", defination.Root.ColumnDefinitions[0].FhirExpression);
            Assert.AreEqual("TestName2", defination.Root.ColumnDefinitions[1].Name);
            Assert.AreEqual("testExpression2", defination.Root.ColumnDefinitions[1].FhirExpression);
        }
        public void GivenColumnWithLongPathGroup_WhenResolveDefinitionNode_ResolveDefinitionNodesShouldBeReturn()
        {
            Dictionary <string, PropertiesGroup> propertiesGroups = new Dictionary <string, PropertiesGroup>();

            propertiesGroups["test"] = new PropertiesGroup()
            {
                PropertiesGroupName = "test",
                Properties          = new List <Property>()
                {
                    new Property()
                    {
                        Name = "p1", Type = "string", Path = "abc"
                    }
                }
            };
            var properties = new List <Property>();

            properties.Add(new Property()
            {
                Name            = "TestName",
                Path            = "test1.test2",
                PropertiesGroup = "test"
            });
            TabularTable table = new TabularTable();

            table.Properties = properties;

            TabularMappingDefinition defination = BaseMappingDefinitionLoader.BuildMappingDefinition(table, propertiesGroups, 5);

            Assert.AreEqual("Test1Test2p1", defination.Root.Children["test1"].Children["test2"].Children["abc"].ColumnDefinitions[0].Name);
        }
        public void Given2ColumnWithSamePath_WhenResolveDefinitionNode_2ResolveDefinitionNodesShouldBeReturn()
        {
            var properties = new List <Property>();

            properties.Add(new Property()
            {
                Name = "TestName1",
                Path = "test1.test2",
                Type = "string"
            });

            properties.Add(new Property()
            {
                Name = "TestName2",
                Path = "test1.test2",
                Type = "string"
            });
            TabularTable table = new TabularTable();

            table.Properties = properties;

            TabularMappingDefinition defination = BaseMappingDefinitionLoader.BuildMappingDefinition(table, new Dictionary <string, PropertiesGroup>(), 5);

            Assert.AreEqual(2, defination.Root.Children["test1"].Children["test2"].ColumnDefinitions.Count());
            Assert.AreEqual("Test1TestName1", defination.Root.Children["test1"].Children["test2"].ColumnDefinitions[0].Name);
            Assert.AreEqual("Test1TestName2", defination.Root.Children["test1"].Children["test2"].ColumnDefinitions[1].Name);
        }
        public void GivenColumnWith2LongPath_WhenResolveDefinitionNode_MergedResolveDefinitionNodesShouldBeReturn()
        {
            Dictionary <string, PropertiesGroup> propertiesGroups = new Dictionary <string, PropertiesGroup>();

            var properties = new List <Property>();

            properties.Add(new Property()
            {
                Name = "TestName1",
                Path = "test1.test2"
            });
            properties.Add(new Property()
            {
                Name = "TestName2",
                Path = "test1.test3"
            });
            TabularTable table = new TabularTable();

            table.Properties = properties;

            TabularMappingDefinition defination = BaseMappingDefinitionLoader.BuildMappingDefinition(table, propertiesGroups, 5);

            Assert.AreEqual("Test1TestName1", defination.Root.Children["test1"].Children["test2"].ColumnDefinitions[0].Name);
            Assert.AreEqual("Test1TestName2", defination.Root.Children["test1"].Children["test3"].ColumnDefinitions[0].Name);
        }
        public void GivenDefinitionMoreThanMaxLevel_WhenResolveDefinitionNode_ResolveDefinitionNodesShouldBeReturn()
        {
            Dictionary <string, PropertiesGroup> propertiesGroups = new Dictionary <string, PropertiesGroup>();

            propertiesGroups["test1"] = new PropertiesGroup()
            {
                PropertiesGroupName = "test1",
                Properties          = new List <Property>()
                {
                    new Property()
                    {
                        Name = "p11", Type = "string", Path = "abc1"
                    },
                    new Property()
                    {
                        PropertiesGroup = "test1", Path = "abc2"
                    }
                }
            };

            var properties = new List <Property>();

            properties.Add(new Property()
            {
                Name            = "TestName",
                Path            = "test1",
                PropertiesGroup = "test1"
            });
            properties.Add(new Property()
            {
                Name = "p1",
                Path = "test",
                Type = "string"
            });
            TabularTable table = new TabularTable();

            table.Properties = properties;

            TabularMappingDefinition defination = BaseMappingDefinitionLoader.BuildMappingDefinition(table, propertiesGroups, 2);

            Assert.AreEqual(3, defination.Columns.Count());
        }