[TestMethod] FocusingSmartPartFiresActivated, Not?

Topics: CAB & Smart Client Software Factory
Jan 11, 2006 at 7:56 PM
originally posted by: RayHeath

Perhaps I have misunderstood the desired functionality; but you may consider the following two methods:

// from ZoneWorkspaceFixture
TestMethod
public void FocusingSmartPartFiresActivated()
{
ZoneWorkspaceForm form = CreateFormAddWorkspace();
Control zone = new Control();
bool activated = false;

workspace.Controls.Add(zone);
workspace.SetZoneName(zone, "Main");
workspace.SmartPartActivated += delegate { activated = true; };
form.Show();

workspace.Show(control, new ZoneSmartPartInfo("Main"));
workspace.Zones"Main".Focus();

Assert.IsTrue(activated);
}

// A slightly modified version
public void FocusingSmartPartDoesNotFireActivated()
{
ZoneWorkspaceForm form = CreateFormAddWorkspace();
Control zone = new Control();
bool activated = false;

workspace.Controls.Add(zone);
workspace.SetZoneName(zone, "Main");
workspace.SmartPartActivated += delegate { activated = true; };
form.Show();
// expected false, got false
MessageBox.Show(activated.ToString());

workspace.Show(control, new ZoneSmartPartInfo("Main"));
// didn't know what to expect, got true
MessageBox.Show(activated.ToString());
activated = false; // or: activated = workspace.Zones"Main".Focused;
workspace.Zones"Main".Focus();
// expected true, got false
MessageBox.Show(activated.ToString());
}
Jan 12, 2006 at 12:59 PM
originally posted by: DLorenz

Well, I think this test makes sure that when a SmartPart gets focus that it automatically activates the WorkItem it is attached to. I wish we had a way to turn this feature on and off, tho. :(