Exemple #1
0
        public void ToolStripItemCheckboxGroupManager_Test()
        {
            var toolStripStatusLabel = new ToolStripStatusLabel();
            var toolStripMenuItemOne = new ToolStripMenuItem();
            var toolStripButtonOne   = new ToolStripButton();
            var toolStripMenuItemTwo = new ToolStripMenuItem();
            var toolStripButtonTwo   = new ToolStripButton();
            var obj              = new object();
            var bitmap           = ToolStripItemGroup.ResourceToImage("TNT.ToolStripItemManager.Tests.Images.shape_align_bottom.png");
            var itemGroupManager = new ProtectedAccess(toolStripStatusLabel);
            var one              = itemGroupManager.Create <One>(new ToolStripItem[] { toolStripMenuItemOne, toolStripButtonOne }, bitmap, obj);
            var two              = itemGroupManager.Create <Two>(new ToolStripItem[] { toolStripMenuItemTwo, toolStripButtonTwo }, bitmap, obj);

            one.Checked = true;

            Assert.AreEqual(one.Text, toolStripMenuItemOne.Text);
            Assert.AreEqual(one.ToolTipText, toolStripMenuItemOne.ToolTipText);
            Assert.IsTrue(toolStripMenuItemOne.Checked);
            Assert.IsTrue(toolStripButtonOne.Checked);
            Assert.AreEqual(two.Text, toolStripMenuItemTwo.Text);
            Assert.AreEqual(two.ToolTipText, toolStripMenuItemTwo.ToolTipText);
            Assert.IsFalse(toolStripMenuItemTwo.Checked);
            Assert.IsFalse(toolStripButtonTwo.Checked);

            toolStripMenuItemOne.PerformClick();

            toolStripMenuItemTwo.PerformClick();

            Assert.IsFalse(toolStripMenuItemOne.Checked);
            Assert.IsFalse(toolStripButtonOne.Checked);
            Assert.IsTrue(toolStripMenuItemTwo.Checked);
            Assert.IsTrue(toolStripButtonTwo.Checked);
        }
Exemple #2
0
 /// <summary>
 /// The protected access method .
 /// </summary>
 private static void ProtectedAccess()
 {
     // We call the protectedAccess class
     // Nothing can be accessed because it is in a private access modifier
     Encapsulation.ProtectedAccess r = new ProtectedAccess();
     Console.WriteLine(@"Protected Modifier Example");
     Console.WriteLine(@"Nothing Can Be Accessed Because its set to a Protected Modifier");
     Console.ReadLine();
 }
        public void ToolStripItemGroupManager_Test()
        {
            var toolStripStatusLabel = new ToolStripStatusLabel();
            var toolStripMenuItem    = new ToolStripMenuItem();
            var obj              = new object();
            var bitmap           = ToolStripItemGroup.ResourceToImage("TNT.ToolStripItemManager.Tests.Images.shape_align_bottom.png");
            var itemGroupManager = new ProtectedAccess(toolStripStatusLabel);
            var one              = itemGroupManager.Create <One>(new ToolStripItem[] { toolStripMenuItem }, bitmap, obj);

            Assert.AreEqual(one.Text, toolStripMenuItem.Text);
            Assert.AreEqual(one.ToolTipText, toolStripMenuItem.ToolTipText);

            toolStripMenuItem.PerformClick();
        }
Exemple #4
0
        public void ToolStripItemGroupManager_CreateHome()
        {
            var toolStripStatusLabel = new ToolStripStatusLabel();
            var toolStripMenuItemOne = new ToolStripMenuItem();
            var toolStripButtonOne   = new ToolStripButton();
            var toolStripMenuItemTwo = new ToolStripMenuItem();
            var toolStripButtonTwo   = new ToolStripButton();
            var obj              = new object();
            var bitmap           = ToolStripItemGroup.ResourceToImage("TNT.ToolStripItemManager.Tests.Images.shape_align_bottom.png");
            var itemGroupManager = new ProtectedAccess(toolStripStatusLabel);
            var nonHomeGroup     = itemGroupManager.Create <One>(new ToolStripItem[] { toolStripMenuItemOne, toolStripButtonOne }, bitmap, obj);

            Assert.IsFalse(nonHomeGroup.Checked);
            Assert.IsNull(itemGroupManager.HomeGroup);

            itemGroupManager.Toggle();
            Assert.IsFalse(nonHomeGroup.Checked);

            var homeGroup = itemGroupManager.CreateHome <Two>(new ToolStripItem[] { toolStripMenuItemTwo, toolStripButtonTwo }, bitmap, obj);

            Assert.AreEqual(homeGroup, itemGroupManager.HomeGroup);

            Assert.IsNull(itemGroupManager.PreviouslyCheckedGroup);
            toolStripMenuItemTwo.PerformClick();
            Assert.IsNull(itemGroupManager.PreviouslyCheckedGroup);

            toolStripMenuItemOne.PerformClick();
            Assert.AreEqual(nonHomeGroup, itemGroupManager.PreviouslyCheckedGroup);
            Assert.IsTrue(nonHomeGroup.Checked);

            itemGroupManager.Toggle();
            Assert.IsFalse(nonHomeGroup.Checked);
            Assert.IsTrue(homeGroup.Checked);

            itemGroupManager.Toggle();
            Assert.IsTrue(nonHomeGroup.Checked);
            Assert.IsFalse(homeGroup.Checked);
        }