public GetChildren ( IMappedObject parent ) : List |
||
parent | IMappedObject | /// Parent of the children. /// |
return | List |
public List<IMappedObject> GetChildren(IMappedObject parent) {
string parentId = this.GetId(parent);
List<IMappedObject> results = new List<IMappedObject>();
bool parentExists = false;
using(var tran = this.engine.GetTransaction()) {
foreach (var row in tran.SelectForward<string, DbCustomSerializer<MappedObject>>(MappedObjectsTable)) {
var data = row.Value.Get;
if (data == null) {
continue;
}
if (parentId == data.ParentId) {
results.Add(new MappedObject(data));
} else if(data.RemoteObjectId == parentId) {
parentExists = true;
}
}
}
if (!parentExists) {
throw new EntryNotFoundException();
}
return results;
}
public void GetChildrenReturnsEmptyListIfNoChildrenAreAvailable([Values(true, false)]bool withValidation) { var storage = new MetaDataStorage(this.engine, this.matcher, withValidation); var folder = new MappedObject("name", "id", MappedObjectType.Folder, null, null); storage.SaveMappedObject(folder); Assert.That(storage.GetChildren(folder).Count == 0); }