예제 #1
0
        public void UserDefinedCells_SetMultipleTimes()
        {
            var page1 = this.GetNewPage();

            var s1 = page1.DrawRectangle(0, 0, 2, 2);

            // By default a shape has ZERO custom Properties
            Assert.AreEqual(0, CustomPropertyHelper.Get(s1).Count);

            // Add the same one multiple times Custom Property
            UserDefinedCellHelper.Set(s1, "FOO1", "BAR1", null);
            // Asset that now we have ONE CustomProperty
            Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1));
            // Check that it is called FOO1
            Assert.AreEqual(true, UserDefinedCellHelper.Contains(s1, "FOO1"));

            // Try to SET the same property again many times
            UserDefinedCellHelper.Set(s1, "FOO1", "BAR2", null);
            UserDefinedCellHelper.Set(s1, "FOO1", "BAR3", null);
            UserDefinedCellHelper.Set(s1, "FOO1", "BAR4", null);

            // Asset that now we have ONE CustomProperty
            Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1));
            // Check that it is called FOO1
            Assert.AreEqual(true, UserDefinedCellHelper.Contains(s1, "FOO1"));
            page1.Delete(0);
        }
예제 #2
0
        public void UserDefinedCells_GetSet()
        {
            var page1 = this.GetNewPage();

            var s1 = page1.DrawRectangle(0, 0, 2, 2);

            // By default a shape has ZERO custom Properties
            Assert.AreEqual(0, UserDefinedCellHelper.GetCount(s1));

            // Add a Custom Property
            UserDefinedCellHelper.Set(s1, "FOO1", "BAR", null);
            Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1));
            // Check that it is called FOO1
            Assert.AreEqual(true, UserDefinedCellHelper.Contains(s1, "FOO1"));

            // Check that non-existent properties can't be found
            Assert.AreEqual(false, CustomPropertyHelper.Contains(s1, "FOOX"));

            var udcs = UserDefinedCellHelper.Get(s1);

            Assert.AreEqual(1, udcs.Count);
            Assert.AreEqual("FOO1", udcs[0].Name);
            Assert.AreEqual("\"BAR\"", udcs[0].Value.Formula);
            Assert.AreEqual("\"\"", udcs[0].Prompt.Formula);

            // Verify that we can set the value without affecting the prompt
            UserDefinedCellHelper.Set(s1, "FOO1", "BEER", null);
            udcs = UserDefinedCellHelper.Get(s1);
            Assert.AreEqual(1, udcs.Count);
            Assert.AreEqual("FOO1", udcs[0].Name);
            Assert.AreEqual("\"BEER\"", udcs[0].Value.Formula);
            Assert.AreEqual("\"\"", udcs[0].Prompt.Formula);

            // Verify that we can set passing in nulls changes nothing
            UserDefinedCellHelper.Set(s1, "FOO1", null, null);
            udcs = UserDefinedCellHelper.Get(s1);
            Assert.AreEqual(1, udcs.Count);
            Assert.AreEqual("FOO1", udcs[0].Name);
            Assert.AreEqual("\"BEER\"", udcs[0].Value.Formula);
            Assert.AreEqual("\"\"", udcs[0].Prompt.Formula);

            // Verify that we can set the prompt without affecting the value
            UserDefinedCellHelper.Set(s1, "FOO1", null, "Prompt1");
            udcs = UserDefinedCellHelper.Get(s1);
            Assert.AreEqual(1, udcs.Count);
            Assert.AreEqual("FOO1", udcs[0].Name);
            Assert.AreEqual("\"BEER\"", udcs[0].Value.Formula);
            Assert.AreEqual("\"Prompt1\"", udcs[0].Prompt.Formula);

            // Delete that custom property
            UserDefinedCellHelper.Delete(s1, "FOO1");
            // Verify that we have zero Custom Properties
            Assert.AreEqual(0, UserDefinedCellHelper.GetCount(s1));

            page1.Delete(0);
        }
        public List <bool> Contains(VisioScripting.Models.TargetShapes targets, string name)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            if (name == null)
            {
                throw new System.ArgumentNullException(nameof(name));
            }

            targets = targets.ResolveShapes(this._client);

            if (targets.Shapes.Count < 1)
            {
                return(new List <bool>());
            }

            var all_shapes = this._client.Selection.GetShapes();
            var results    = all_shapes.Select(s => UserDefinedCellHelper.Contains(s, name)).ToList();

            return(results);
        }