Beispiel #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();
        }
        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: ");
        }