public void ShapeSheet_Query_TestDuplicates() { // Ensure that duplicate cells are caught var cell_query_1 = new VA.ShapeSheet.Query.CellQuery(); cell_query_1.Columns.Add(SrcConstants.XFormPinX, nameof(SrcConstants.XFormPinX)); bool caught_exc1 = false; try { cell_query_1.Columns.Add(SrcConstants.XFormPinX, nameof(SrcConstants.XFormPinX)); } catch (System.ArgumentException) { caught_exc1 = true; } Assert.IsTrue(caught_exc1); // Ensure that duplicate sections are caught var sec_query_2 = new VA.ShapeSheet.Query.SectionQuery(); sec_query_2.Add(IVisio.VisSectionIndices.visSectionObject); bool caught_exc2 = false; try { sec_query_2.Add(IVisio.VisSectionIndices.visSectionObject); } catch (System.ArgumentException) { caught_exc2 = true; } Assert.IsTrue(caught_exc2); // Ensure that Duplicates in Section Queries Are caught - var sec_query_3 = new VA.ShapeSheet.Query.SectionQuery(); var sec_cols = sec_query_3.Add(IVisio.VisSectionIndices.visSectionObject); sec_cols.Add(SrcConstants.XFormPinX, nameof(SrcConstants.XFormPinX)); bool caught_exc3 = false; try { sec_cols.Add(SrcConstants.XFormPinX, nameof(SrcConstants.XFormPinX)); } catch (System.ArgumentException) { caught_exc3 = true; } Assert.IsTrue(caught_exc3); }
public void ShapeSheet_Query_SectionRowHandling() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); var s2 = page1.DrawRectangle(2, 1, 3, 3); var s3 = page1.DrawRectangle(3, 1, 4, 2); var s4 = page1.DrawRectangle(4, -1, 5, 1); int cp_type = 0; // 0 for string VA.Shapes.CustomPropertyHelper.Set(s1, "S1P1", "\"1\"", cp_type); VA.Shapes.CustomPropertyHelper.Set(s2, "S2P1", "\"2\"", cp_type); VA.Shapes.CustomPropertyHelper.Set(s2, "S2P2", "\"3\"", cp_type); //set nothing for s3 VA.Shapes.CustomPropertyHelper.Set(s4, "S3P1", "\"4\"", cp_type); VA.Shapes.CustomPropertyHelper.Set(s4, "S3P2", "\"5\"", cp_type); VA.Shapes.CustomPropertyHelper.Set(s4, "S3P3", "\"6\"", cp_type); var sec_query = new VA.ShapeSheet.Query.SectionQuery(); var sec_cols = sec_query.Add(IVisio.VisSectionIndices.visSectionProp); var value_col = sec_cols.Add(SrcConstants.CustomPropValue, nameof(SrcConstants.CustomPropValue)); var shapeidpairs = VA.ShapeIDPairs.FromShapes(s1, s2, s3, s4); var data = sec_query.GetFormulas(page1, shapeidpairs); var data2 = sec_query.GetResults <string>(page1, shapeidpairs); int shape0_index = 0; int shape1_index = 1; int shape2_index = 2; int shape3_index = 3; int section0_index = 0; Assert.AreEqual(4, data.Count); Assert.AreEqual(1, data[shape0_index][section0_index].Count); Assert.AreEqual(2, data[shape1_index][section0_index].Count); Assert.AreEqual(0, data[shape2_index][section0_index].Count); Assert.AreEqual(3, data[3][0].Count); Assert.AreEqual("\"1\"", data[shape0_index][section0_index][0][0]); Assert.AreEqual("\"2\"", data[shape1_index][section0_index][0][0]); Assert.AreEqual("\"3\"", data[shape1_index][section0_index][1][0]); Assert.AreEqual("\"4\"", data[shape3_index][section0_index][0][0]); Assert.AreEqual("\"5\"", data[shape3_index][section0_index][1][0]); Assert.AreEqual("\"6\"", data[shape3_index][section0_index][2][0]); Assert.AreEqual("1", data2[shape0_index][section0_index][0][0]); Assert.AreEqual("2", data2[shape1_index][section0_index][0][0]); Assert.AreEqual("3", data2[shape1_index][section0_index][1][0]); Assert.AreEqual("4", data2[shape3_index][section0_index][0][0]); Assert.AreEqual("5", data2[shape3_index][section0_index][1][0]); Assert.AreEqual("6", data2[shape3_index][section0_index][2][0]); page1.Delete(0); }
public void UserDefinedCells_GetFromMultipleShapes_WithAdditionalProps() { var page1 = this.GetNewPage(); var shape0 = page1.DrawRectangle(0, 0, 1, 1); var shape1 = page1.DrawRectangle(1, 1, 2, 2); var shapes = new[] { shape0, shape1 }; // add a udcell to shape0, leave shape1 alone SetCP(shape0, "foo", "bar", null); // build query var sec_query = new VASS.Query.SectionQuery(); var sec_cols = sec_query.Add(IVisio.VisSectionIndices.visSectionUser); var Value = sec_cols.Add(VASS.SrcConstants.UserDefCellValue, "Value"); var Prompt = sec_cols.Add(VASS.SrcConstants.UserDefCellPrompt, "Prompt"); // run query on the two shapes var shapeidpairs = VA.ShapeIDPairs.FromShapes(shapes); var formulas = sec_query.GetFormulas(page1, shapeidpairs); Assert.AreEqual(2, formulas.Count); // 2 because two shapes var shape0_formulas = formulas[0]; var shape1_formulas = formulas[1]; // handle first shape Assert.AreEqual(1, shape0_formulas.Count); // 1 because there is only one section being queries var shape0_section0 = shape0_formulas[0]; var shape0_section0_row0 = shape0_section0[0]; Assert.AreEqual("\"bar\"", shape0_section0_row0[0]); Assert.AreEqual("\"\"", shape0_section0_row0[1]); // handle second shape Assert.AreEqual(1, shape1_formulas.Count); // 1 because there is only one section being queries var shape1_section0 = shape1_formulas[0]; Assert.AreEqual(0, shape1_section0.Count); // 0 because this shape has no user defined cells page1.Delete(0); }