I have installed the latest version of aspose tasks and have run across a problem with part of our existing working code. We have a unit test that checks for zero resources and yet when instantiating a new project it now seems to have an empty collection of 1 resource where as previously we could check for is null or empty.
Aspose.Tasks version 22.5.0
The line of code that is adding the resource is the creation of the object
Aspose.Tasks.Project mSProject = new Aspose.Tasks.Project();
The unit test now fails
Assert.That(mSPlan.Resources, Is.Null.Or.Empty);
Please could you tell me if this by design or a bug ?
Thanks
@chamberlas,
this behavior is not a bug. This is a “Root” or “Unassigned” resource.
In this way we mimic the MS Project behavior.
If you create an empty project and save it to XML using MS Project, you can observe a resource with Id = 0:
<Resources>
<Resource>
<UID>0</UID>
<GUID>A0CB8B7E-2A8C-436D-0000-0000000000FF</GUID>
<ID>0</ID>
<Type>1</Type>
<IsNull>0</IsNull>
...
Thanks,
Is the resource ID 0 always the root resource even if you do have genuine resources ?
Im trying to think of what my unit test should now be when the user selects an option not to export resources.
Will it always be the case that resource ID 0 is root and my check should be to fail if there are any other resources other than ID 0 ?
@chamberlas,
Is the resource ID 0 always the root resource even if you do have genuine resources ?
Yes, the root resource is always present.
Will it always be the case that resource ID 0 is root and my check should be to fail if there are any other resources other than ID 0 ?
Yes, it looks like a correct solution.
To make checking of the root resource more convenient we will add
IsRoot { get; }
property in version 22.6.