This project has moved. For the latest updates, please go here.

Testing and XtraNavBarWorkspace.Close() bug

Coordinator
Jan 19, 2008 at 8:48 AM
Edited Jan 19, 2008 at 11:08 PM
The tests are turning out to be quite useful.
I was testing the XtraNavBarWorkspace.Close() method today and it didn't work.
Most of us probably don't need this method anyway, but there was a bug in it. The TODO explains the problem (see code snippet below):

The solution was to check for > -1 not > 0. Now it works.
 // TODO : Check why group not removeable
if (Groups.IndexOf(group) > 0)
{
    // get rid of the navbar group
    Groups.Remove(group);
    group.Dispose();
}

I think this came about because of some confusion about catering for design time and not removing the 'first' control, but I can't see any reason why the test below shouldn't pass.

I'm not a slave to the one-assert-per-test theory, as you can see.
[Fact]
public void CanShowAndCloseAndHideXtraNavBarWorkspace()
{
	XtraNavBarWorkspace navbarWorkspace= new XtraNavBarWorkspace();
	XtraNavBarGroupSmartPartInfo smartPartInfo = new XtraNavBarGroupSmartPartInfo();
	smartPartInfo.Title = "Test Title";
	Assert.Equal(0, navbarWorkspace.Groups.Count);
 
	// show the workspace
	navbarWorkspace.Show(_smartPart, smartPartInfo);
	Assert.Equal(1, navbarWorkspace.Groups.Count);
	Assert.Equal(NavBarGroupStyle.ControlContainer, navbarWorkspace.Groups[0].GroupStyle);
 
	// hide and the group still exists, but not visible
	navbarWorkspace.Hide(_smartPart);
	Assert.Equal(1, navbarWorkspace.Groups.Count);
	Assert.False(navbarWorkspace.Groups[0].Visible);
 
	// close removes
	navbarWorkspace.Close(_smartPart);
	Assert.Equal(0, navbarWorkspace.Groups.Count);
}