Exemplo 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void Given_TwoRandom_Cubes_GetIntersectionVolumeFromTwoCubesMethod_ShoulBe_Commutative_Operation()
        {
            var cubeA = CubeBuilder.Create().CenteredAt(0, 0, 0).WithEdgeLength(3).Build();
            var cubeB = CubeBuilder.Create().CenteredAt(2, 2, 2).WithEdgeLength(2).Build();

            _service.AreCubesColliding(cubeA, cubeB).Should().BeTrue();
            _service.GetIntersectionVolumeFromTwoCubes(cubeA, cubeB).Should().Be(_service.GetIntersectionVolumeFromTwoCubes(cubeB, cubeA));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void Given_Two_Cubes_Overlapped_With_Similar_Edge_Side_Should_Collide()
        {
            var cubeA = CubeBuilder.Create().CenteredAt(2, 2, 2).WithEdgeLength(2).Build();
            var cubeB = CubeBuilder.Create().CenteredAt(3, 2, 2).WithEdgeLength(2).Build();

            _service.AreEdgesColliding(cubeA.Width, cubeB.Width).Should().BeTrue();
            _service.AreEdgesColliding(cubeA.Height, cubeB.Height).Should().BeTrue();
            _service.AreEdgesColliding(cubeA.Height, cubeB.Depth).Should().BeTrue();
        }
Exemplo n.º 7
0
        public void SetNameConfig_Test()
        {
            CubeBuilder builder = new CubeBuilder();

            builder.SetName("hello");

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

            Assert.AreEqual("hello", cube.Name);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public static Model3DGroup CreateSelection()
        {
            var cubeBuilder = new CubeBuilder(MovementConstants.ScaleFactor + 0.01D);
            var cube        = cubeBuilder.Create(System.Windows.Media.Colors.Red, 0, 0, 0);

            var group = new Model3DGroup();

            @group.Children.Add(cube);

            return(@group);
        }
        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);
        }
Exemplo n.º 12
0
        public void Given_Cubes_That_Don_Not_Intersect_IntersectionVolume_Should_Be_Zero()
        {
            var cubeA = CubeBuilder.Create()
                        .CenteredAt(0, 0, 0)
                        .WithEdgeLength(1)
                        .Build();

            var cubeB = CubeBuilder.Create()
                        .CenteredAt(10, 10, 10)
                        .WithEdgeLength(1)
                        .Build();

            _service.GetIntersectionVolumeFromTwoCubes(cubeA, cubeB).Should().Be(0);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        public void Given_Two_Cubes_That_Are_Touching_IntersectionVolume_Should_Be_Zero()
        {
            var cubeA = CubeBuilder.Create()
                        .CenteredAt(2, 2, 2)
                        .WithEdgeLength(2)
                        .Build();

            var cubeB = CubeBuilder.Create()
                        .CenteredAt(4, 2, 2)
                        .WithEdgeLength(2)
                        .Build();

            _service.AreCubesColliding(cubeA, cubeB).Should().BeTrue();
            _service.GetIntersectionVolumeFromTwoCubes(cubeA, cubeB).Should().Be(0);
        }
Exemplo n.º 15
0
        public void Given_Two_Cubes_With_Same_Height_And_Depth__IntersectionVolume_Should_Be_Four()
        {
            var cubeA = CubeBuilder.Create()
                        .CenteredAt(1, 1, 1)
                        .WithEdgeLength(2)
                        .Build();

            var cubeB = CubeBuilder.Create()
                        .CenteredAt(2, 1, 1)
                        .WithEdgeLength(2)
                        .Build();

            _service.AreCubesColliding(cubeA, cubeB).Should().BeTrue();
            _service.GetIntersectionVolumeFromTwoCubes(cubeA, cubeB).Should().Be(4);
        }
Exemplo n.º 16
0
        public void Given_One_CubeA_Contained_Inside_One_CubeB_IntersectionVolume_Should_Be_One()
        {
            var expected = 1;
            var cubeA    = CubeBuilder.Create()
                           .CenteredAt(2, 2, 2)
                           .WithEdgeLength(2)
                           .Build();
            var cubeB = CubeBuilder.Create()
                        .CenteredAt(2, 2, 2)
                        .WithEdgeLength(1)
                        .Build();

            _service.AreCubesColliding(cubeA, cubeB).Should().BeTrue();
            _service.GetIntersectionVolumeFromTwoCubes(cubeA, cubeB).Should().Be(expected);
        }
Exemplo n.º 17
0
        public void Given_Two_Cubes_Totally_Overrlaped_IntersectionVolume_Should_Be_Equal_To_Them_Proper_Volume()
        {
            var cubeA = CubeBuilder.Create()
                        .CenteredAt(2, 2, 2)
                        .WithEdgeLength(2)
                        .Build();

            var cubeB = CubeBuilder.Create()
                        .CenteredAt(2, 2, 2)
                        .WithEdgeLength(2)
                        .Build();

            _service.AreCubesColliding(cubeA, cubeB).Should().BeTrue();
            _service.GetIntersectionVolumeFromTwoCubes(cubeA, cubeB).Should().Be(cubeA.Volume);
            _service.GetIntersectionVolumeFromTwoCubes(cubeA, cubeB).Should().Be(cubeB.Volume);
        }
Exemplo n.º 18
0
        public void Given_Two_Cubes_Touched_Height_And_Depth_Should_Collide()
        {
            var cubeA = CubeBuilder.Create()
                        .CenteredAt(2, 2, 2)
                        .WithEdgeLength(1)
                        .Build();

            var cubeB = CubeBuilder.Create()
                        .CenteredAt(4, 2, 2)
                        .WithEdgeLength(1)
                        .Build();

            _service.AreEdgesColliding(cubeA.Width, cubeB.Width).Should().BeFalse();
            _service.AreEdgesColliding(cubeA.Height, cubeB.Height).Should().BeTrue();
            _service.AreEdgesColliding(cubeA.Depth, cubeB.Depth).Should().BeTrue();
        }
Exemplo n.º 19
0
        public void Given_Two_Cubes_With_Same_Length_And_Any_Equal_Property_Should_Not_Collide()
        {
            var cubeA = CubeBuilder.Create()
                        .CenteredAt(2, 2, 2)
                        .WithEdgeLength(1)
                        .Build();

            var cubeB = CubeBuilder.Create()
                        .CenteredAt(10, 10, 10)
                        .WithEdgeLength(1)
                        .Build();

            _service.AreEdgesColliding(cubeA.Width, cubeB.Width).Should().BeFalse();
            _service.AreEdgesColliding(cubeA.Height, cubeB.Height).Should().BeFalse();
            _service.AreEdgesColliding(cubeA.Depth, cubeB.Depth).Should().BeFalse();
        }
Exemplo n.º 20
0
        public void Given_Two_Cubes_With_Same_Width_And_Heigth__IntersectionVolume_Should_Be_Four()
        {
            double expected = 4;
            var    cubeA    = CubeBuilder.Create()
                              .CenteredAt(2, 2, 2)
                              .WithEdgeLength(2)
                              .Build();

            var cubeB = CubeBuilder.Create()
                        .CenteredAt(2, 2, 3)
                        .WithEdgeLength(2)
                        .Build();

            _service.AreCubesColliding(cubeA, cubeB).Should().BeTrue();
            _service.GetIntersectionVolumeFromTwoCubes(cubeA, cubeB).Should().Be(expected);
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
        public void Start()
        {
            ConfigureOpenGl();

            _camera = new Camera(Size)
            {
                Position = new Vector3(0, 0, -1), Target = new Vector3(0, 0, 0), Transformation = Vector3.UnitY
            };
            _inputController = new InputController();
            _fpsCounter      = new FpsCounter();
            _particles       = ParticleSystemBuilder.Create().WithCount(200).Object();
            _cube            = CubeBuilder.Create().WithSize(1).Object();

            _objectManager.AddObject(_cube);
            _objectManager.AddObject(_particles);
            _objectManager.AddObject(_fpsCounter);

            Run(60);
        }
        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>());
        }
Exemplo n.º 24
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.");
        }