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 async Task UserExists_UserDoesNotExist_ReturnsFalse(int id, int numAccounts, string namePrefix, int startingId, int idIncrementFactor) { // Arrange // Setting up each dependency of ValidationService as a Mock Mock <IUserProfileService> mockProfileService = new Mock <IUserProfileService>(); Mock <IUserAccountService> mockAccountService = new Mock <IUserAccountService>(); List <WebUserAccountModel> userAccounts = new List <WebUserAccountModel>(); // Test helper to assist in instantiating a list of WebUserAccountModels var testHelper = new BusinessLayerTestHelper(); /* Parameters: * numAccounts: How many would you like to generate? * namePrefix: What would you like to be the common prefix before every attribute? * startingId: What number would you like id to start from? * idIncrementFactor: How many numbers would you like each subsequent id to skip by? */ userAccounts = testHelper.PopulateListOfAccountModels(numAccounts, namePrefix, startingId, idIncrementFactor); // This function reads as: If GetAllUserAccounts is called, then return a list of userAccounts mockAccountService.Setup(x => x.GetAllUserAccounts()).Returns(Task.FromResult(userAccounts)); // Finally, instantiate the actual class being tested and pass in the mock objects IValidationService validationService = new ValidationService(mockAccountService.Object, mockProfileService.Object); // Act // Call the function that is being tested var actualResult = await validationService.UserExists(id); // Assert // This unit test will pass if it returns false Assert.IsFalse(actualResult); }
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 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); }
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); }
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>())); }
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 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 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 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); }
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 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); }
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 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>())); }
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 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 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 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 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 TestGetValues() { // Arrange SetupCsvFile(); // Act var values = _testee.GetValues(_uploadedFile.Object.FileName, BusinessLayerTestHelper.GetDimensionOrMeasureDtos(), ";", "dd.MM.yyyy"); // Assert values.Rows.Count.ShouldBeEquivalentTo(9); values.Columns.Count.ShouldBeEquivalentTo(5); values.Rows[0]["Place"].ShouldBeEquivalentTo("Czech_republic"); values.Rows[0]["Region"].ShouldBeEquivalentTo("Europe"); values.Rows[0]["Product"].ShouldBeEquivalentTo("Bread"); values.Rows[0]["Category"].ShouldBeEquivalentTo("Bakery"); values.Rows[0]["Units"].ShouldBeEquivalentTo("20"); values.Rows[8]["Place"].ShouldBeEquivalentTo("Russia"); values.Rows[8]["Region"].ShouldBeEquivalentTo("Asia"); values.Rows[8]["Product"].ShouldBeEquivalentTo("Milk"); values.Rows[8]["Category"].ShouldBeEquivalentTo("Dairy"); values.Rows[8]["Units"].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: "); }
private void Setup() { _data = new Mock <IDataAccessLayer>(); _dbConnection = new Mock <IDbConnection>(); BusinessLayerTestHelper.PrepareDatabase(DatasetName); }
private void Reset() { _dbConnection.Reset(); BusinessLayerTestHelper.ResetDatabase(); }