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 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 TestResultsPmml() { // Arrange Reset(); var dataset = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName); dataset.Dimensions = BusinessLayerTestHelper.CreateDimensions(dataset); dataset.Measures = BusinessLayerTestHelper.CreateMeasures(dataset); var dimensionValues = new List <DimensionValue>(); foreach (var dimension in dataset.Dimensions) { dimensionValues.AddRange(dimension.DimensionValues); } // Act var rules = _parseTestee.GetRules(dimensionValues, dataset.Measures.ToList()); // Assert rules.Count.ShouldBeEquivalentTo(1); rules[0].AntecedentValues.ToList()[0].Dimension.Name.ShouldBeEquivalentTo("Product"); rules[0].AntecedentValues.ToList()[0].Value.ShouldBeEquivalentTo("Bread"); rules[0].Succedents.ToList()[0].Measure.Name.ShouldBeEquivalentTo("Units"); rules[0].ConditionValues.ToList()[0].Dimension.Name.ShouldBeEquivalentTo("Category"); rules[0].ConditionValues.ToList()[0].Value.ShouldBeEquivalentTo("Bakery"); }
public void TestCreateAndFillFactTableAndCreateView() { // Arrange Reset(); SetupConnection(); var dataset = BusinessLayerTestHelper.CreateDataset(DatasetName); var dimensions = BusinessLayerTestHelper.CreateDimensions(dataset); var values = BusinessLayerTestHelper.GetValuesDataTable(); var measures = BusinessLayerTestHelper.CreateMeasures(dataset); var measure = measures[0]; SetupDataMock(dimensions); // Act _testee.CreateAndFillDimensionTables(DatasetName, dimensions, values); _testee.CreateFactTable(dataset, dimensions, measures); _testee.FillFactTable(DatasetName, dimensions, measures, values); _testee.CreateView(dataset, dimensions, measures); var czechRepRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Place", "Czech republic")), measure); var slovakiaRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Place", "Slovakia")), measure); var russiaRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Place", "Russia")), measure); var breadRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Product", "Bread")), measure); var bunRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Product", "Bun")), measure); var milkRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Product", "Milk")), measure); var europeRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Region", "Europe")), measure); var asiaRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Region", "Asia")), measure); var bakeryRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Category", "Bakery")), measure); var dairyRows = GetViewValues(_queryBuilder.Select($"{DatasetName}View", GetSelector(dimensions, "Category", "Dairy")), measure); // Assert czechRepRows.Count.ShouldBeEquivalentTo(3); czechRepRows.Sum().ShouldBeEquivalentTo(80); slovakiaRows.Count.ShouldBeEquivalentTo(3); slovakiaRows.Sum().ShouldBeEquivalentTo(35); russiaRows.Count.ShouldBeEquivalentTo(3); russiaRows.Sum().ShouldBeEquivalentTo(165); breadRows.Count.ShouldBeEquivalentTo(3); breadRows.Sum().ShouldBeEquivalentTo(80); bunRows.Count.ShouldBeEquivalentTo(3); bunRows.Sum().ShouldBeEquivalentTo(150); milkRows.Count.ShouldBeEquivalentTo(3); milkRows.Sum().ShouldBeEquivalentTo(50); europeRows.Count.ShouldBeEquivalentTo(6); europeRows.Sum().ShouldBeEquivalentTo(115); asiaRows.Count.ShouldBeEquivalentTo(3); asiaRows.Sum().ShouldBeEquivalentTo(165); bakeryRows.Count.ShouldBeEquivalentTo(6); bakeryRows.Sum().ShouldBeEquivalentTo(230); dairyRows.Count.ShouldBeEquivalentTo(3); dairyRows.Sum().ShouldBeEquivalentTo(50); }
public void TestMinedResultsMineRules() { // Arrange Reset(); var dataset = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName); _data.Setup(d => d.GetDataset(It.IsAny <int>())).Returns(dataset); // Act var result = _mr.MineRules(new MiningViewModel { CommensurabilityList = new List <CommensurabilityViewModel>() }); // Assert }
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 TestDatasetMapDatasets() { // Arrange var dataset1 = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName + "1"); var dataset2 = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName + "2"); // Act var model = _dvmm.Map(new List <Dataset> { dataset1, dataset2 }); // Assert model.Datasets.Count.ShouldBeEquivalentTo(2); model.Datasets[0].Name.ShouldBeEquivalentTo(BusinessLayerTestHelper.DatasetName + "1"); model.Datasets[1].Name.ShouldBeEquivalentTo(BusinessLayerTestHelper.DatasetName + "2"); }
public void TestMiningTaskMapModelDatasetAndCommensurableDimensions() { // Arrange var dataset = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName); var model = new MiningViewModel { BaseQ = 10, Lift = 2, ConditionRequired = true }; // Act var viewModel = _mtvmm.Map(model, dataset, BusinessLayerTestHelper.CreateDimensions(dataset)); // Assert viewModel.Aad.ShouldBeEquivalentTo(1); viewModel.Base.ShouldBeEquivalentTo(10); viewModel.ConditionDimensions.Count.ShouldBeEquivalentTo(4); viewModel.ConditionRequired.ShouldBeEquivalentTo(true); }
public void TestUploadCreateDatasetManually() { // Arrange Reset(); var dataset = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName); dataset.Dimensions = BusinessLayerTestHelper.CreateDimensions(dataset); dataset.Measures = BusinessLayerTestHelper.CreateMeasures(dataset); _data.Setup(d => d.GetDataset(It.IsAny <int>())).Returns(dataset); _validations.Setup( v => v.DatatypesAreValid(It.IsAny <AttributeViewModel[]>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new List <string>()); // Act var result = _uc.CreateDatasetManually(1, new AttributeViewModel[] {}, ";", "dd.MM.yyyy"); // Assert }
public void TestBrowseCubeMapDataset() { // Arrange var dataset = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName); dataset.Dimensions = BusinessLayerTestHelper.CreateDimensions(dataset); dataset.Measures = BusinessLayerTestHelper.CreateMeasures(dataset); var filter = new FilterViewModel(); // Act var model = _bcvmm.Map(dataset, filter); // Assert model.Dataset.Dimensions.Count.ShouldBeEquivalentTo(4); model.Dataset.Measures.Count.ShouldBeEquivalentTo(1); model.GroupedChart.ShouldBeEquivalentTo(null); model.DrilldownChart.ShouldBeEquivalentTo(null); }
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); }
public void TestCreateAndFillDimensionTables() { // Arrange Reset(); SetupConnection(); var dataset = BusinessLayerTestHelper.CreateDataset(DatasetName); var dimensions = BusinessLayerTestHelper.CreateDimensions(dataset); var values = BusinessLayerTestHelper.GetValuesDataTable(); SetupDataMock(dimensions); // Act _testee.CreateAndFillDimensionTables(DatasetName, dimensions, values); var products = GetDimensionsValues(_queryBuilder.Select($"{DatasetName}Product", new List <Column>())); var categories = GetDimensionsValues(_queryBuilder.Select($"{DatasetName}Category", new List <Column>())); var places = GetDimensionsValues(_queryBuilder.Select($"{DatasetName}Place", new List <Column>())); var regions = GetDimensionsValues(_queryBuilder.Select($"{DatasetName}Region", new List <Column>())); // Assert products.Count.ShouldBeEquivalentTo(3); categories.Count.ShouldBeEquivalentTo(2); places.Count.ShouldBeEquivalentTo(3); regions.Count.ShouldBeEquivalentTo(2); products[0].Item1.ShouldBeEquivalentTo(1); products[0].Item2.ShouldBeEquivalentTo("Bread"); products[1].Item1.ShouldBeEquivalentTo(2); products[1].Item2.ShouldBeEquivalentTo("Bun"); products[2].Item1.ShouldBeEquivalentTo(3); products[2].Item2.ShouldBeEquivalentTo("Milk"); categories[0].Item1.ShouldBeEquivalentTo(1); categories[0].Item2.ShouldBeEquivalentTo("Bakery"); categories[1].Item1.ShouldBeEquivalentTo(2); categories[1].Item2.ShouldBeEquivalentTo("Dairy"); places[0].Item1.ShouldBeEquivalentTo(1); places[0].Item2.ShouldBeEquivalentTo("Czech republic"); places[1].Item1.ShouldBeEquivalentTo(2); places[1].Item2.ShouldBeEquivalentTo("Slovakia"); places[2].Item1.ShouldBeEquivalentTo(3); places[2].Item2.ShouldBeEquivalentTo("Russia"); regions[0].Item1.ShouldBeEquivalentTo(1); regions[0].Item2.ShouldBeEquivalentTo("Europe"); regions[1].Item1.ShouldBeEquivalentTo(2); regions[1].Item2.ShouldBeEquivalentTo("Asia"); }
public void TestUploadCreateDataset() { // Arrange Reset(); var dataset = BusinessLayerTestHelper.CreateDataset(BusinessLayerTestHelper.DatasetName); dataset.Dimensions = BusinessLayerTestHelper.CreateDimensions(dataset); dataset.Measures = BusinessLayerTestHelper.CreateMeasures(dataset); _data.Setup(d => d.GetDataset(It.IsAny <int>())).Returns(dataset); _validations.Setup( v => v.DatatypesAreValid(It.IsAny <AttributeViewModel[]>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new List <string>()); _handler.Setup(h => h.SaveFile(It.IsAny <HttpPostedFileBase>(), It.IsAny <string>())) .Returns(new RecommenderFile()); _datasetMapper.Setup(dm => dm.Map(It.IsAny <Dataset>(), It.IsAny <FilterViewModel>())).Returns(new SingleDatasetViewModel()); // Act var result = _uc.CreateDataset(1, ";"); // Assert }
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: "); }