Ejemplo n.º 1
0
        public void TestBrowseCubeShowRule()
        {
            // Arrange
            Reset();
            var dataset    = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName);
            var dimensions = BusinessLayerTestHelper.CreateDimensions(dataset);
            var measures   = BusinessLayerTestHelper.CreateMeasures(dataset);
            var task       = BusinessLayerTestHelper.GetTask(dataset);
            var rule       = BusinessLayerTestHelper.GetAssociationRule(dimensions, measures, task);

            _data.Setup(d => d.GetRule(It.IsAny <int>())).Returns(rule);
            _arMapper.Setup(ar => ar.GetXAndLegendDimensionsId(It.IsAny <AssociationRule>(), It.IsAny <DimensionTree>()))
            .Returns(Tuple.Create(1, 1));
            var tree = BusinessLayerTestHelper.CreateDimensionTree(BusinessLayerTestHelper.DatasetName);

            _treeBuilder.Setup(tb => tb.ConvertToTree(It.IsAny <int>(), It.IsAny <bool>())).Returns(tree);
            // Act
            var result = _bc.ShowChart(1);

            // Assert
            _data.Verify(d => d.GetRule(1), Times.Once);
            _treeBuilder.Verify(tb => tb.ConvertToTree(It.IsAny <int>(), It.IsAny <bool>()));
            _arMapper.Verify(ar => ar.GetXAndLegendDimensionsId(It.IsAny <AssociationRule>(), It.IsAny <DimensionTree>()));
            _arMapper.Verify(ar => ar.GetFilterValues(It.IsAny <AssociationRule>()));
            _arMapper.Verify(ar => ar.GetChartText(It.IsAny <AssociationRule>()));
            ShowChartCalled();
        }
Ejemplo n.º 2
0
        public void TestShowChartDefinedManually()
        {
            // Arrange
            Reset();
            var filters = BusinessLayerTestHelper.GetBreadMilkEuropeFiltersAsFilterViewModel();
            var tree    = BusinessLayerTestHelper.CreateDimensionTree("TestDataset");

            SetupDataLayer(tree);
            // Act
            _testee.ShowChart(1, 1, 1, 2, true, filters);
            // Assert
            _dataMock.Verify(dm => dm.GetDataset(1));
            _dataMock.Verify(dm => dm.GetMeasure(1));
            // Filter predicates
            Predicate <List <FlatDimensionDto> > hasTwoMembers       = l => l.Count == 2;
            Predicate <FlatDimensionDto>         breadMilkFilterIsOk =
                bmf => (bmf.Id == 3 && bmf.DimensionValues.Count == 2 &&
                        bmf.DimensionValues[0].Id == 1 && bmf.DimensionValues[1].Id == 3);
            Predicate <FlatDimensionDto> europeFilterIsOk =
                ef => (ef.Id == 2 && ef.DimensionValues.Count == 1 && ef.DimensionValues[0].Id == 1);

            _graphServiceMock.Verify(gs => gs.GetGroupedGraph(tree,
                                                              It.Is <TreeDimensionDto>(td => td.Id == 1), It.Is <TreeDimensionDto>(d => d.Id == 2),
                                                              It.Is <Measure>(m => m.Id == 1),
                                                              It.Is <List <FlatDimensionDto> >(f => hasTwoMembers(f) && breadMilkFilterIsOk(f[0]) && europeFilterIsOk(f[1])), It.Is <bool>(b => b)));

            _graphServiceMock.Verify(gs => gs.GetDrilldownGraph(tree,
                                                                It.Is <TreeDimensionDto>(td => td.Id == 1),
                                                                It.Is <Measure>(m => m.Id == 1),
                                                                It.Is <List <FlatDimensionDto> >(f => hasTwoMembers(f) && breadMilkFilterIsOk(f[0]) && europeFilterIsOk(f[1])), It.Is <bool>(b => b == false)));

            _browseCubeMock.Verify(bcm => bcm.Map(It.IsAny <GroupedGraphDto>()));
            _browseCubeMock.Verify(bcm => bcm.Map(It.IsAny <DrilldownGraphDto>()));
        }
Ejemplo n.º 3
0
        public void TestGetDrilldownGraphWithTwoFilters()
        {
            // Arrange
            Reset();
            SetupConnection();
            var tree       = BusinessLayerTestHelper.CreateDimensionTree(DatasetName);
            var xDimension = tree.GetDimensionDto(4); // xDimension = category
            var measure    = new Measure {
                Name = "Units"
            };
            // Show only bakery
            // Show only bread and milk in Europe
            var filters = BusinessLayerTestHelper.GetBreadMilkEuropeFilter(tree);
            // Act
            var graph = _graphService.GetDrilldownGraph(tree, xDimension, measure, filters, true);

            // Assert
            graph.Name.Should().Contain(xDimension.Name);
            graph.Name.Should().Contain(measure.Name);
            graph.Roots.Count.ShouldBeEquivalentTo(2);
            graph.Roots[0].Name.ShouldBeEquivalentTo("Bakery");
            graph.Roots[1].Name.ShouldBeEquivalentTo("Dairy");
            graph.Roots[0].XAxisLeaves.Count.ShouldBeEquivalentTo(1);
            var breadLeaf = (DrilldownGraphXAxisLeafDto)graph.Roots[0].XAxisLeaves[0];
            var milkLeaf  = (DrilldownGraphXAxisLeafDto)graph.Roots[1].XAxisLeaves[0];

            breadLeaf.Name.ShouldBeEquivalentTo("Bread");
            breadLeaf.Value.ShouldBeEquivalentTo(30);
            milkLeaf.Name.ShouldBeEquivalentTo("Milk");
            milkLeaf.Value.ShouldBeEquivalentTo(15);
        }
Ejemplo n.º 4
0
        public void TestGetGroupedGraphWithTwoFiltersWithoutGrouping()
        {
            // Arrange
            Reset();
            SetupConnection();
            var tree            = BusinessLayerTestHelper.CreateDimensionTree(DatasetName);
            var xDimension      = tree.GetDimensionDto(4); // xDimension = category
            var legendDimension = tree.GetDimensionDto(1); // legendDimension = place
            var measure         = new Measure {
                Name = "Units"
            };
            // Show only bakery
            // Show only bread and milk in Europe
            var filters = BusinessLayerTestHelper.GetBreadMilkEuropeFilter(tree);
            // Act
            var graph        = _graphService.GetGroupedGraph(tree, xDimension, legendDimension, measure, filters, false);
            var legendValues = graph.GetLegendValues().ToList();

            // Assert
            graph.Name.Should().Contain(xDimension.Name);
            graph.Name.Should().Contain(legendDimension.Name);
            graph.Name.Should().Contain(measure.Name);

            graph.Roots.Count.ShouldBeEquivalentTo(1);
            graph.Roots[0].XAxisLeaves.Count.ShouldBeEquivalentTo(2);
            graph.Roots[0].XAxisLeaves[0].Name.ShouldBeEquivalentTo("Bakery");
            graph.Roots[0].XAxisLeaves[1].Name.ShouldBeEquivalentTo("Dairy");
            legendValues.Count.ShouldBeEquivalentTo(4);
            // Bread
            legendValues[0].Value.ShouldBeEquivalentTo(20);
            legendValues[1].Value.ShouldBeEquivalentTo(10);
            // Milk
            legendValues[2].Value.ShouldBeEquivalentTo(10);
            legendValues[3].Value.ShouldBeEquivalentTo(5);
        }
Ejemplo n.º 5
0
        public void TestBrowseCubeMapTree()
        {
            // Arrange
            var tree = BusinessLayerTestHelper.CreateDimensionTree(BusinessLayerTestHelper.DatasetName);
            // Act
            var model = _bcvmm.Map(tree);

            // Assert
            model.Dimensions.Count.ShouldBeEquivalentTo(4);
            model.Dimensions[0].DimensionName.ShouldBeEquivalentTo("Place");
            model.Dimensions[0].Values[0].Value.ShouldBeEquivalentTo("Czech republic");
            model.Dimensions[0].Values[0].Checked.ShouldBeEquivalentTo(true);
        }
Ejemplo n.º 6
0
        public void TestGetGroupedGraphWithOneFilter()
        {
            // Arrange
            Reset();
            SetupConnection();
            var tree            = BusinessLayerTestHelper.CreateDimensionTree(DatasetName);
            var xDimension      = tree.GetDimensionDto(4); // xDimension = category
            var legendDimension = tree.GetDimensionDto(1); // legendDimension = place
            var measure         = new Measure {
                Name = "Units"
            };
            // Show only bakery
            var filters = new List <FlatDimensionDto>
            {
                new FlatDimensionDto
                {
                    Id              = 4,
                    Name            = "Category",
                    DatasetName     = DatasetName,
                    DimensionValues = new[] { new DimensionValueDto {
                                                  Id = 1, Value = "Bakery"
                                              } }.ToList()
                }
            };
            // Act
            var graph        = _graphService.GetGroupedGraph(tree, xDimension, legendDimension, measure, filters, true);
            var legendValues = graph.GetLegendValues().ToList();

            // Assert
            graph.Name.Should().Contain(xDimension.Name);
            graph.Name.Should().Contain(legendDimension.Name);
            graph.Name.Should().Contain(measure.Name);

            graph.Roots.Count.ShouldBeEquivalentTo(1); // Bakery
            graph.Roots[0].Name.ShouldBeEquivalentTo("Bakery");
            graph.Roots[0].XAxisLeaves.Count.ShouldBeEquivalentTo(2);
            graph.Roots[0].XAxisLeaves[0].Name.ShouldBeEquivalentTo("Bread");
            graph.Roots[0].XAxisLeaves[1].Name.ShouldBeEquivalentTo("Bun");

            legendValues.Count.ShouldBeEquivalentTo(6);
            // Bread
            legendValues[0].Value.ShouldBeEquivalentTo(20);
            legendValues[1].Value.ShouldBeEquivalentTo(10);
            legendValues[2].Value.ShouldBeEquivalentTo(50);
            // Bun
            legendValues[3].Value.ShouldBeEquivalentTo(50);
            legendValues[4].Value.ShouldBeEquivalentTo(20);
            legendValues[5].Value.ShouldBeEquivalentTo(80);
        }
Ejemplo n.º 7
0
        public void TestBrowseCube()
        {
            // Arrange
            Reset();
            var tree = BusinessLayerTestHelper.CreateDimensionTree("TestDataset");

            _treeBuilderMock.Setup(c => c.ConvertToTree(It.IsAny <int>(), It.IsAny <bool>())).Returns(tree);
            _starSchemaQuerierMock.Setup(c => c.GetValuesOfDimension(It.IsAny <DimensionDto>(), It.IsAny <Column>()))
            .Returns((DimensionDto dim, Column c) => tree.GetDimensionDto(dim.Id).DimensionValues);
            // Act
            _testee.BrowseCube(1);
            // Assert
            _dataMock.Verify(dm => dm.GetDataset(1));
            _browseCubeMock.Verify(bcm => bcm.Map(It.IsAny <Dataset>(), It.IsAny <FilterViewModel>()));
            _browseCubeMock.Verify(bcm => bcm.Map(It.IsAny <DimensionTree>()));
        }
Ejemplo n.º 8
0
        public void TestMiningTaskMapDatasetAndCommensurabilities()
        {
            // Arrange
            var dataset =
                BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName);
            var tree = BusinessLayerTestHelper.CreateDimensionTree(BusinessLayerTestHelper.DatasetName);
            // Act
            var commensurabilities = _mtvmm.GetCommensurableDimensions(tree);
            var model = _mtvmm.Map(dataset, commensurabilities);

            // Assert
            model.CommensurabilityList.Single(c => c.Dimension.Name == "Place").Checked.ShouldBeEquivalentTo(false);
            model.CommensurabilityList.Single(c => c.Dimension.Name == "Region").Checked.ShouldBeEquivalentTo(true);
            model.CommensurabilityList.Single(c => c.Dimension.Name == "Product").Checked.ShouldBeEquivalentTo(false);
            model.CommensurabilityList.Single(c => c.Dimension.Name == "Category").Checked.ShouldBeEquivalentTo(true);
            model.BaseQ.ShouldBeEquivalentTo(1);
            model.Lift.ShouldBeEquivalentTo(2);
        }
Ejemplo n.º 9
0
        public void TestGetGroupedGraphWithNoFilters()
        {
            // Arrange
            Reset();
            SetupConnection();
            var tree            = BusinessLayerTestHelper.CreateDimensionTree(DatasetName);
            var xDimension      = tree.GetDimensionDto(4); // xDimension = category
            var legendDimension = tree.GetDimensionDto(1); // legendDimension = place
            var measure         = new Measure {
                Name = "Units"
            };
            // Act
            var graph        = _graphService.GetGroupedGraph(tree, xDimension, legendDimension, measure, new List <FlatDimensionDto>(), true);
            var legendValues = graph.GetLegendValues().ToList();

            // Assert
            graph.Name.Should().Contain(xDimension.Name);
            graph.Name.Should().Contain(legendDimension.Name);
            graph.Name.Should().Contain(measure.Name);

            graph.Roots.Count.ShouldBeEquivalentTo(2); // Bakery, Diary
            graph.Roots[0].Name.ShouldBeEquivalentTo("Bakery");
            graph.Roots[0].XAxisLeaves.Count.ShouldBeEquivalentTo(2);
            graph.Roots[0].XAxisLeaves[0].Name.ShouldBeEquivalentTo("Bread");
            graph.Roots[0].XAxisLeaves[1].Name.ShouldBeEquivalentTo("Bun");
            graph.Roots[1].Name.ShouldBeEquivalentTo("Dairy");
            graph.Roots[1].XAxisLeaves.Count.ShouldBeEquivalentTo(1);
            graph.Roots[1].XAxisLeaves[0].Name.ShouldBeEquivalentTo("Milk");

            legendValues.Count.ShouldBeEquivalentTo(9);
            // Bread
            legendValues[0].Value.ShouldBeEquivalentTo(20);
            legendValues[1].Value.ShouldBeEquivalentTo(10);
            legendValues[2].Value.ShouldBeEquivalentTo(50);
            // Bun
            legendValues[3].Value.ShouldBeEquivalentTo(50);
            legendValues[4].Value.ShouldBeEquivalentTo(20);
            legendValues[5].Value.ShouldBeEquivalentTo(80);
            // Milk
            legendValues[6].Value.ShouldBeEquivalentTo(10);
            legendValues[7].Value.ShouldBeEquivalentTo(5);
            legendValues[8].Value.ShouldBeEquivalentTo(35);
        }
        public void TestMapRuleToView()
        {
            // Arrange
            var dataset    = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName);
            var dimensions = BusinessLayerTestHelper.CreateDimensions(dataset);
            var measures   = BusinessLayerTestHelper.CreateMeasures(dataset);
            var tree       = BusinessLayerTestHelper.CreateDimensionTree(BusinessLayerTestHelper.DatasetName);
            var task       = BusinessLayerTestHelper.GetTask(dataset);
            var rule       = BusinessLayerTestHelper.GetAssociationRule(dimensions, measures, task);

            Setup(dimensions, tree);
            // Act
            var ids     = _mapper.GetXAndLegendDimensionsId(rule, tree);
            var filters = _mapper.GetFilterValues(rule).ToList();
            var text    = _mapper.GetChartText(rule);

            // Assert
            ids.Item1.ShouldBeEquivalentTo(1);
            ids.Item2.ShouldBeEquivalentTo(4);
            filters.Count.ShouldBeEquivalentTo(1);
            filters[0].Name.ShouldBeEquivalentTo("Category");
            filters[0].DimensionValues[0].Value.ShouldBeEquivalentTo("Bakery");
            text.ShouldBeEquivalentTo("Association rule: ");
        }