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 TestPreprocessingPmml() { // Arrange Reset(); SetupQuerier(); var dataset = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName); dataset.Dimensions = BusinessLayerTestHelper.CreateDimensions(dataset); dataset.Measures = BusinessLayerTestHelper.CreateMeasures(dataset); var task = BusinessLayerTestHelper.GetTask(dataset); var rowcount = 9; var discretizations = _discretizator.GetDiscretizations(dataset, rowcount); // Act var pmml = _generateTestee.GetPreprocessingPmml(task, discretizations, rowcount); // Assert var header = pmml.SelectNodes("//*[local-name()='Header']").Cast <XmlNode>().Single(); var miningBuildTask = pmml.SelectNodes("//*[local-name()='MiningBuildTask']").Cast <XmlNode>().Single(); var dataDictionary = pmml.SelectNodes("//*[local-name()='DataDictionary']").Cast <XmlNode>().Single(); var transformationDictionary = pmml.SelectNodes("//*[local-name()='TransformationDictionary']").Cast <XmlNode>().Single(); var derivedFields = pmml.SelectNodes("//*[local-name()='DerivedField']").Cast <XmlNode>().ToList(); var columns = pmml.SelectNodes("//*[local-name()='Column']").Cast <XmlNode>().ToList(); var discretizeBins = pmml.SelectNodes("//*[local-name()='DiscretizeBin']").Cast <XmlNode>().ToList(); dataDictionary.Attributes["numberOfFields"].InnerText.ShouldBeEquivalentTo("6"); // Product, Category, Place, Region, Id, Units derivedFields.Count.ShouldBeEquivalentTo(6); columns.Count.ShouldBeEquivalentTo(7); discretizeBins.Count.ShouldBeEquivalentTo(5); discretizeBins[0].Attributes["binValue"].InnerText.ShouldBeEquivalentTo("[5;10]"); discretizeBins[1].Attributes["binValue"].InnerText.ShouldBeEquivalentTo("[10;10]"); discretizeBins[2].Attributes["binValue"].InnerText.ShouldBeEquivalentTo("[10;20]"); discretizeBins[3].Attributes["binValue"].InnerText.ShouldBeEquivalentTo("[20;20]"); discretizeBins[4].Attributes["binValue"].InnerText.ShouldBeEquivalentTo("[20;80]"); }
public void TestTaskPmml() { // Arrange Reset(); SetupQuerier(); var dataset = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName); dataset.Dimensions = BusinessLayerTestHelper.CreateDimensions(dataset); dataset.Measures = BusinessLayerTestHelper.CreateMeasures(dataset); var task = BusinessLayerTestHelper.GetTask(dataset); var rowcount = 9; var tree = _treeBuilder.ConvertToTree(dataset.Dimensions); var eqClasses = _discretizator.GetEquivalencyClasses(tree); // Act var pmml = _generateTestee.GetTaskPmml(task, eqClasses, rowcount); // Assert var header = pmml.SelectNodes("//*[local-name()='Header']").Cast <XmlNode>().Single(); var associationModel = pmml.SelectNodes("//*[local-name()='AssociationModel']").Cast <XmlNode>().Single(); var thresholds = pmml.SelectNodes("//*[local-name()='InterestMeasureThreshold']").Cast <XmlNode>().ToList(); thresholds[0].ChildNodes.Item(0).InnerText.ShouldBeEquivalentTo("BASE"); thresholds[0].ChildNodes.Item(1).InnerText.ShouldBeEquivalentTo("Greater than or equal"); thresholds[0].ChildNodes.Item(2).InnerText.ShouldBeEquivalentTo("1"); thresholds[1].ChildNodes.Item(0).InnerText.ShouldBeEquivalentTo("AAD"); thresholds[1].ChildNodes.Item(1).InnerText.ShouldBeEquivalentTo("Greater than or equal"); thresholds[1].ChildNodes.Item(2).InnerText.ShouldBeEquivalentTo("2"); }
public void TestMiningTaskMapTask() { // Arrange var task = BusinessLayerTestHelper.GetTask( BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName)); // Act var model = _mtvmm.Map(task); // Assert model.Aad.ShouldBeEquivalentTo(2); model.Base.ShouldBeEquivalentTo(15); model.Name.ShouldBeEquivalentTo("TestTask"); }
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: "); }