public void CustomProps_SetSamePropMultipleTimes() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); // By default a shape has ZERO custom Properties Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); int cp_type = 0; // string type // Add the same one multiple times Custom Property CustomPropertyHelper.Set(s1, "FOO1", "\"BAR1\"", cp_type); // Asset that now we have ONE CustomProperty Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, CustomPropertyHelper.Contains(s1, "FOO1")); // Try to SET the same property again many times CustomPropertyHelper.Set(s1, "FOO1", "\"BAR2\"", cp_type); CustomPropertyHelper.Set(s1, "FOO1", "\"BAR3\"", cp_type); CustomPropertyHelper.Set(s1, "FOO1", "\"BAR4\"", cp_type); // Asset that now we have ONE CustomProperty Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, CustomPropertyHelper.Contains(s1, "FOO1")); page1.Delete(0); }
public void CustomProps_SetCustomProps1() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); // By default a shape has ZERO custom Properties Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); // Add a Custom Property var cp = new CustomPropertyCells(); cp.Value = "\"BAR1\""; CustomPropertyHelper.Set(s1, "FOO1", cp); // Asset that now we have ONE CustomProperty Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, CustomPropertyHelper.Contains(s1, "FOO1")); // Check that non-existent properties can't be found Assert.AreEqual(false, CustomPropertyHelper.Contains(s1, "FOOX")); // Delete that custom property CustomPropertyHelper.Delete(s1, "FOO1"); // Verify that we have zero Custom Properties Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); page1.Delete(0); }
public static void Counting_properties(IVisio.Document doc) { // Set Custom Property_on_a_shape var page = doc.Pages.Add(); var s1 = page.DrawRectangle(0, 0, 1, 1); var cp1 = new CustomPropertyCells(); cp1.Value = "Hello"; CustomPropertyHelper.Set(s1, "Propname", cp1); int num_custom_props = CustomPropertyHelper.GetCount(s1); var custom_prop_names = CustomPropertyHelper.GetNames(s1); //cleanup page.Delete(0); }
public void CustomProps_PropertyNames() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); int cp_type = 0; // 0 for string Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Set(s1, "FOO1", "\"BAR1\"", cp_type); Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Set(s1, "FOO1", "\"BAR2\"", cp_type); Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Set(s1, "FOO2", "\"BAR3\"", cp_type); var names1 = CustomPropertyHelper.GetNames(s1); Assert.AreEqual(2, names1.Count); Assert.IsTrue(names1.Contains("FOO1")); Assert.IsTrue(names1.Contains("FOO2")); Assert.AreEqual(2, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Delete(s1, "FOO1"); var names2 = CustomPropertyHelper.GetNames(s1); Assert.AreEqual(1, names2.Count); Assert.IsTrue(names2.Contains("FOO2")); CustomPropertyHelper.Set(s1, "FOO3", "\"BAR1\"", cp_type); var names3 = CustomPropertyHelper.GetNames(s1); Assert.AreEqual(2, names3.Count); Assert.IsTrue(names3.Contains("FOO3")); Assert.IsTrue(names3.Contains("FOO2")); CustomPropertyHelper.Delete(s1, "FOO3"); Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Delete(s1, "FOO2"); Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); page1.Delete(0); }