Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
0
        public void UserDefinedCells_SetAdditionalProperties()
        {
            var page1 = this.GetNewPage();
            var s1    = page1.DrawRectangle(0, 0, 2, 2);

            Assert.AreEqual(0, UserDefinedCellHelper.GetCount(s1));

            var prop = new UserDefinedCellCells("foo");

            prop.Prompt = "Some Prompt";
            UserDefinedCellHelper.Set(s1, "foo", null, "Some prompt");
            Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1));
            page1.Delete(0);
        }
Beispiel #4
0
        public void UserDefinedCells_GetNames()
        {
            var page1 = this.GetNewPage();
            var s1    = page1.DrawRectangle(0, 0, 2, 2);

            Assert.AreEqual(0, UserDefinedCellHelper.GetCount(s1));
            UserDefinedCellHelper.Set(s1, "FOO1", "BAR1", null);
            Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1));
            UserDefinedCellHelper.Set(s1, "FOO1", "BAR2", null);
            Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1));
            UserDefinedCellHelper.Set(s1, "FOO2", "BAR3", null);

            var names1 = UserDefinedCellHelper.GetNames(s1);

            Assert.AreEqual(2, names1.Count);
            Assert.IsTrue(names1.Contains("FOO1"));
            Assert.IsTrue(names1.Contains("FOO2"));

            Assert.AreEqual(2, UserDefinedCellHelper.GetCount(s1));
            UserDefinedCellHelper.Delete(s1, "FOO1");

            var names2 = UserDefinedCellHelper.GetNames(s1);

            Assert.AreEqual(1, names2.Count);
            Assert.IsTrue(names2.Contains("FOO2"));

            UserDefinedCellHelper.Set(s1, "FOO3", "BAR1", null);
            var names3 = UserDefinedCellHelper.GetNames(s1);

            Assert.AreEqual(2, names3.Count);
            Assert.IsTrue(names3.Contains("FOO2"));
            Assert.IsTrue(names3.Contains("FOO3"));

            UserDefinedCellHelper.Delete(s1, "FOO3");

            Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1));
            UserDefinedCellHelper.Delete(s1, "FOO2");

            Assert.AreEqual(0, UserDefinedCellHelper.GetCount(s1));

            page1.Delete(0);
        }
Beispiel #5
0
        public void UserDefinedCells_CheckInvalidNamesNotAllowed()
        {
            bool caught = false;
            var  page1  = this.GetNewPage();
            var  s1     = page1.DrawRectangle(0, 0, 2, 2);

            Assert.AreEqual(0, UserDefinedCellHelper.GetCount(s1));
            try
            {
                UserDefinedCellHelper.Set(s1, "FOO 1", "BAR1", null);
            }
            catch (System.ArgumentException)
            {
                // this was expected
                page1.Delete(0);
                caught = true;
            }
            if (caught == false)
            {
                Assert.Fail("Did not catch expected exception");
            }
        }