public void Basic_Multiple_Metric_Expressions_Execution_Test()
        {
            using (var cube = CubeSourcesFixture.GetBasicCubeThreeDimensionsTwoMeasures2())
            {
                cube.Initialize();

                cube.BuildMetrics()
                .Add("testeAverage",
                     exb => exb.Expression(e => e.Set("quantity").Average()))
                .Add("testeMax",
                     exb => exb.Expression(e => e.Set("quantity").Max()))
                .Add("testeMin",
                     exb => exb.Expression(e => e.Set("quantity").Min()))
                .Create();

                Assert.IsNotNull(cube.Schema.Metrics["testeAverage"]);
                Assert.IsNotNull(cube.Schema.Metrics["testeMax"]);
                Assert.IsNotNull(cube.Schema.Metrics["testeMin"]);

                cube.Process();

                var cell = cube.Cells.Take(1).FirstOrDefault();


                var valueMeasure = (int)cell.Values[cube.Schema.Measures["quantity"].ID];
                var valueAverage = cell.Values[cube.Schema.Metrics["testeAverage"].ID];
                var valueMax     = cell.Values[cube.Schema.Metrics["testeMax"].ID];
                var valueMin     = cell.Values[cube.Schema.Metrics["testeMin"].ID];

                Assert.AreEqual(valueMeasure / 24, valueAverage);
                Assert.AreEqual(101, valueMax);
                Assert.AreEqual(1, valueMin);
            }
        }
        public void Basic_Multiple_Metric_Expressions_Execution_With_Query_On_Metric_Test()
        {
            using (var cube = CubeSourcesFixture.GetBasicCubeThreeDimensionsTwoMeasures2())
            {
                cube.Initialize();

                cube.BuildMetrics()
                .Add("testeAverage",
                     exb => exb.Expression(e => e.Set("quantity").Average()))
                .Add("testeMax",
                     exb => exb.Expression(e => e.Set("quantity").Max()))
                .Add("testeMin",
                     exb => exb.Expression(e => e.Set("quantity").Min()))
                .Create();

                Assert.IsNotNull(cube.Schema.Metrics["testeAverage"]);
                Assert.IsNotNull(cube.Schema.Metrics["testeMax"]);
                Assert.IsNotNull(cube.Schema.Metrics["testeMin"]);

                cube.Process();

                var queryBuilder = cube.BuildQuery()
                                   .OnColumns("sex.All")
                                   .AddMeasuresOrMetrics("testeAverage");

                var query  = queryBuilder.Create();
                var result = query.StreamRows().ToList();

                Assert.IsTrue(result.Count == 2);
            }
        }
        public void Init()
        {
            cube = CubeSourcesFixture.GetBasicCubeThreeDimensionsTwoMeasures2();
            cube.Initialize();
            cube.Process();

            _resolver = new NamespaceResolver <int>(cube);
        }
        public void Basic_Metric_Expression_Execution_Test()
        {
            using (var cube = CubeSourcesFixture.GetBasicCubeThreeDimensionsTwoMeasures2())
            {
                cube.Initialize();

                cube.BuildMetrics()
                .Add("teste1", exb => exb.Expression(e => e.Set("quantity").Sum(10)))
                .Create();

                Assert.IsNotNull(cube.Schema.Metrics["teste1"]);

                cube.Process();

                var cell = cube.Cells.Take(1).FirstOrDefault();


                var valueMeasure = (int)cell.Values[cube.Schema.Measures["quantity"].ID];
                var value        = (int)cell.Values[cube.Schema.Metrics["teste1"].ID];

                Assert.AreEqual(valueMeasure + 10, value);
            }
        }
        public void Composite_Metric_Division_Expression_Execution_Test()
        {
            using (var cube = CubeSourcesFixture.GetBasicCubeThreeDimensionsTwoMeasures2())
            {
                cube.Initialize();

                cube.BuildMetrics()
                .Add("testeDivide2", exb => exb.Expression(e => e.Set("spent").Divide(ex => ex.Set("quantity").Value())))
                .Create();

                Assert.IsNotNull(cube.Schema.Metrics["testeDivide2"]);

                cube.Process();

                var cell = cube.Cells.Take(1).FirstOrDefault();


                var valueMeasure  = (int)cell.Values[cube.Schema.Measures["quantity"].ID];
                var valueMeasure2 = (double)cell.Values[cube.Schema.Measures["spent"].ID];
                var value         = (double)cell.Values[cube.Schema.Metrics["testeDivide2"].ID];

                Assert.AreEqual(valueMeasure2 / valueMeasure, value);
            }
        }
 public void Init()
 {
     cube = CubeSourcesFixture.GetBasicCubeThreeDimensionsTwoMeasures2();
     cube.Initialize();
     cube.Process();
 }