Ejemplo n.º 1
0
        public void DataSourceFieldsSetupConfig_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("xpto"))
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("xpto")
                .SetSourceType(DataSourceType.CSV)
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("xpto.csv");
                })
                .AddField("xval", 0, typeof(int))
                .AddField("yval", 1, typeof(int));
            });

            Cube <int> cube = builder.Create <int>();

            Assert.AreEqual("xval", cube.Config.DataSources["xpto"].Fields["xval"].Name);
            Assert.AreEqual(0, cube.Config.DataSources["xpto"].Fields["xval"].Index);
            Assert.AreEqual(typeof(int), cube.Config.DataSources["xpto"].Fields["xval"].FieldType);
            Assert.AreEqual("yval", cube.Config.DataSources["xpto"].Fields["yval"].Name);
            Assert.AreEqual(1, cube.Config.DataSources["xpto"].Fields["yval"].Index);
            Assert.AreEqual(typeof(int), cube.Config.DataSources["xpto"].Fields["yval"].FieldType);
        }
Ejemplo n.º 2
0
        public void AddMoreThanOneDataSourceConfig_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("xpto"))
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("xpto")
                .SetSourceType(DataSourceType.CSV)
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("xpto.csv");
                });
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("xtable")
                .SetSourceType(DataSourceType.CSV)
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("xtable.csv");
                });
            });

            Cube <int> cube = builder.Create <int>();

            Assert.AreEqual("xpto", cube.Config.DataSources["xpto"].Name);
            Assert.AreEqual("xtable", cube.Config.DataSources["xtable"].Name);
        }
Ejemplo n.º 3
0
        public void AddMoreThanOneDimensionConfig_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("xpto"))
            .MetaData(mbuild =>
            {
                mbuild.AddDimension("x", (dimbuild) =>
                {
                    dimbuild.Source("xtable")
                    .ValueField("xkey")
                    .DescField("xdesc");
                })
                .AddDimension("y", (dimbuild) =>
                {
                    dimbuild.Source("ytable")
                    .ValueField("ykey")
                    .DescField("ydesc");
                });
            });

            Cube <int> cube = builder.Create <int>();

            Assert.AreEqual("x", cube.Config.MetaData.Dimensions[0].Name);
            Assert.AreEqual("x", cube.Config.MetaData.Dimensions["x"].Name);
            Assert.AreEqual("y", cube.Config.MetaData.Dimensions[1].Name);
            Assert.AreEqual("y", cube.Config.MetaData.Dimensions["y"].Name);
        }
Ejemplo n.º 4
0
        public void MolapAddDateDimensionInit_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello2")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("sales"))
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("sales")
                .SetSourceType(DataSourceType.CSV)
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("TestData//tableWithDate.csv")
                    .SetHasHeader();
                })
                .AddField("category", 0, typeof(int))
                .AddField("sex", 1, typeof(int))
                .AddField("place", 2, typeof(int))
                .AddDateField("date", 3, "yyyy-MM-dd")
                .AddField("expenses", 4, typeof(double))
                .AddField("items", 5, typeof(int));
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("categories")
                .SetSourceType(DataSourceType.CSV)
                .AddField("id", 0, typeof(int))
                .AddField("description", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("TestData//dimension1.csv")
                    .SetHasHeader();
                });
            })
            .MetaData(mbuild =>
            {
                mbuild.AddDimension("category", (dimbuild) =>
                {
                    dimbuild.Source("categories")
                    .ValueField("id")
                    .DescField("description");
                })
                .AddDimension("date", dimbuild =>
                {
                    dimbuild
                    .SetToDateSource(DateTimeLevels.YEAR, DateTimeLevels.MONTH_WITH_YEAR, DateTimeLevels.MONTH, DateTimeLevels.DAY)
                    .SetLevelDimensions("Year", "Year Month", "Month", "Day");
                });
            });

            Cube <int> cube = builder.Create <int>();

            cube.Initialize();

            Assert.AreEqual("Year", cube.Schema.Dimensions["Year"].Name);
            Assert.AreEqual(ItemType.Dimension, cube.Schema.Dimensions["Year"].ItemType);
            Assert.Greater(cube.Schema.Dimensions["Year"].ID, 1);
        }
Ejemplo n.º 5
0
        internal static CubeConfig GetConfig()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("New_Cube")
            .Storage(store => { store.SetStoreType(StorageType.Molap); });

            return(builder.CreateConfig());
        }
Ejemplo n.º 6
0
        public void SetNameConfig_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello");

            Cube <int> cube = builder.Create <int>();

            Assert.AreEqual("hello", cube.Name);
        }
Ejemplo n.º 7
0
        public void SetSourceConfig_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("xpto"));

            Cube <int> cube = builder.Create <int>();

            Assert.AreEqual("xpto", cube.Source);
        }
        public void MolapAddDimensionInit_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("sales"))
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("sales")
                .SetSourceType(DataSourceType.CSV)
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("TestData//table.csv")
                    .SetHasHeader();
                })
                .AddField("category", 0, typeof(int))
                .AddField("sex", 1, typeof(int))
                .AddField("place", 2, typeof(int))
                .AddField("expenses", 3, typeof(double))
                .AddField("items", 4, typeof(int));
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("categories")
                .SetSourceType(DataSourceType.CSV)
                .AddField("id", 0, typeof(int))
                .AddField("description", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("TestData//dimension1.csv")
                    .SetHasHeader();
                });
            })
            .MetaData(mbuild =>
            {
                mbuild.AddDimension("category", (dimbuild) =>
                {
                    dimbuild.Source("categories")
                    .ValueField("id")
                    .DescField("description");
                });
            });

            Cube <int> cube = builder.Create <int>();

            cube.Initialize();

            Assert.AreEqual("category", cube.Schema.Dimensions["category"].Name);
            Assert.AreEqual("categories", cube.Schema.Dimensions["category"].DataSource.Name);
            Assert.AreEqual(ItemType.Dimension, cube.Schema.Dimensions["category"].ItemType);
            Assert.Greater(cube.Schema.Dimensions["category"].ID, 0);
        }
        public void MolapAddMeasureInit_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("xpto"))
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("xpto")
                .SetSourceType(DataSourceType.CSV)
                .AddField("x", 0, typeof(int))
                .AddField("varx1", 2, typeof(int))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("xpto.csv");
                });
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("xtable")
                .SetSourceType(DataSourceType.CSV)
                .AddField("xkey", 0, typeof(int))
                .AddField("xdesc", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("xtable.csv");
                });
            })
            .MetaData(mbuild =>
            {
                mbuild.AddDimension("x", (dimbuild) =>
                {
                    dimbuild.Source("xtable")
                    .ValueField("xkey")
                    .DescField("xdesc");
                })
                .AddMeasure("var1", mesbuild =>
                {
                    mesbuild.ValueField("varx1")
                    .SetType(typeof(int));
                });
            });

            Cube <int> cube = builder.Create <int>();

            cube.Initialize();

            Assert.AreEqual("var1", cube.Schema.Measures["var1"].Name);
            Assert.AreEqual(ItemType.Measure, cube.Schema.Measures["var1"].ItemType);
            Assert.AreEqual(typeof(int), cube.Schema.Measures["var1"].DataType);
        }
Ejemplo n.º 10
0
        public void SetStorageConfig_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("xpto"))
            .Storage(storebuild =>
            {
                storebuild.SetStoreType(StorageType.Molap);
            });

            Cube <int> cube = builder.Create <int>();

            Assert.AreEqual(StorageType.Molap, cube.Config.Storage.StoreType);
        }
Ejemplo n.º 11
0
        public void AddMeasureConfig_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) => sourcebuild.SetSource("xpto"))
            .MetaData(mbuild =>
            {
                mbuild.AddMeasure("var1", mesbuild =>
                {
                    mesbuild.ValueField("varx1");
                });
            });

            Cube <int> cube = builder.Create <int>();

            Assert.AreEqual("var1", cube.Config.MetaData.Measures["var1"].Name);
            Assert.AreEqual("varx1", cube.Config.MetaData.Measures["var1"].ValueFieldName);
        }
        public static Cube <int> GetBasicCubeThreeDimensionsTwoMeasures()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello")
            .SetSourceMappings((sourcebuild) =>
            {
                sourcebuild.SetSource("sales")
                .AddMapping("category", "category")
                .AddMapping("sex", "sex")
                .AddMapping("place", "place");
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("sales")
                .SetSourceType(DataSourceType.CSV)
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("TestData//table.csv")
                    .SetHasHeader();
                })
                .AddField("category", 0, typeof(int))
                .AddField("sex", 1, typeof(int))
                .AddField("place", 2, typeof(int))
                .AddField("expenses", 3, typeof(double))
                .AddField("items", 4, typeof(int));
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("categories")
                .SetSourceType(DataSourceType.CSV)
                .AddField("id", 0, typeof(int))
                .AddField("description", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("TestData//dimension1.csv")
                    .SetHasHeader();
                });
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("sexes")
                .SetSourceType(DataSourceType.CSV)
                .AddField("id", 0, typeof(int))
                .AddField("description", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("TestData//dimension2.csv")
                    .SetHasHeader();
                });
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("places")
                .SetSourceType(DataSourceType.CSV)
                .AddField("id", 0, typeof(int))
                .AddField("description", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("TestData//dimension3.csv")
                    .SetHasHeader();
                });
            })
            .MetaData(mbuild =>
            {
                mbuild.AddDimension("category", (dimbuild) =>
                {
                    dimbuild.Source("categories")
                    .ValueField("id")
                    .DescField("description");
                })
                .AddDimension("sex", (dimbuild) =>
                {
                    dimbuild.Source("sexes")
                    .ValueField("id")
                    .DescField("description");
                })
                .AddDimension("place", (dimbuild) =>
                {
                    dimbuild.Source("places")
                    .ValueField("id")
                    .DescField("description");
                })
                .AddMeasure("spent", mesbuild =>
                {
                    mesbuild.ValueField("expenses")
                    .SetType(typeof(double));
                })
                .AddMeasure("quantity", mesbuild =>
                {
                    mesbuild.ValueField("items")
                    .SetType(typeof(int));
                });
            });

            return(builder.Create <int>());
        }
Ejemplo n.º 13
0
        public void Initialize()
        {
            var builder = new CubeBuilder();

            builder.SetName("CUBE")
            .SetSourceMappings((sourcebuild) =>
            {
                sourcebuild.SetSource("sales")
                .AddMapping("category", "category")
                .AddMapping("gender", "gender")
                .AddMapping("place", "place")
                .AddMapping("date", "Year", "Month", "Day");
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("sales")
                .SetSourceType(DataSourceType.CSV)
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("Data//facts.csv")
                    .SetHasHeader();
                })
                .AddField("category", 0, typeof(int))
                .AddField("gender", 1, typeof(int))
                .AddField("place", 2, typeof(int))
                .AddDateField("date", 3, "yyyy-MM-dd")
                .AddField("expenses", 4, typeof(double))
                .AddField("items", 5, typeof(int));
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("categories")
                .SetSourceType(DataSourceType.CSV)
                .AddField("id", 0, typeof(int))
                .AddField("description", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("Data//dimension1.csv")
                    .SetHasHeader();
                });
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("allgenders")
                .SetSourceType(DataSourceType.CSV)
                .AddField("id", 0, typeof(int))
                .AddField("description", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("Data//dimension2.csv")
                    .SetHasHeader();
                });
            })
            .AddDataSource(dsbuild =>
            {
                dsbuild.SetName("places")
                .SetSourceType(DataSourceType.CSV)
                .AddField("id", 0, typeof(int))
                .AddField("description", 1, typeof(string))
                .SetCSVConfig(csvbuild =>
                {
                    csvbuild.SetFilePath("Data//dimension3.csv")
                    .SetHasHeader();
                });
            })
            .MetaData(mbuild =>
            {
                mbuild.AddDimension("category", (dimbuild) =>
                {
                    dimbuild.Source("categories")
                    .ValueField("id")
                    .DescField("description");
                })
                .AddDimension("gender", (dimbuild) =>
                {
                    dimbuild.Source("allgenders")
                    .ValueField("id")
                    .DescField("description");
                })
                .AddDimension("place", (dimbuild) =>
                {
                    dimbuild.Source("places")
                    .ValueField("id")
                    .DescField("description");
                })
                .AddDimension("date", dimbuild =>
                {
                    dimbuild
                    .SetToDateSource(DateTimeLevels.YEAR, DateTimeLevels.MONTH, DateTimeLevels.DAY)
                    .SetLevelDimensions("Year", "Month", "Day");
                })
                .AddMeasure("spent", mesbuild =>
                {
                    mesbuild.ValueField("expenses")
                    .SetType(typeof(double));
                })
                .AddMeasure("quantity", mesbuild =>
                {
                    mesbuild.ValueField("items")
                    .SetType(typeof(int));
                });
            });

            _cube = builder.Create <int>();

            Console.WriteLine("Cube Configured.");

            _cube.Initialize();

            Console.WriteLine("Cube Initialized.");
        }