public GetLocalPath ( IMappedObject mappedObject ) : string | ||
mappedObject | IMappedObject | /// Mapped object. Must not be null. /// |
return | string |
public string GetLocalPath(IMappedObject mappedObject) {
string id = this.GetId(mappedObject);
using(var tran = this.engine.GetTransaction()) {
string[] segments = this.GetRelativePathSegments(tran, id);
if (segments == null) {
return null;
}
if (segments.Length > 0 && segments[0].Equals("/")) {
string[] temp = new string[segments.Length - 1];
for (int i = 1; i < segments.Length; i++) {
temp[i - 1] = segments[i];
}
segments = temp;
}
return Path.Combine(this.matcher.LocalTargetRootPath, Path.Combine(segments));
}
}
public void GetLocalPathOfNonExistingEntryReturnsNull([Values(true, false)]bool withValidation) { var matcher = new Mock<IPathMatcher>(); matcher.Setup(m => m.LocalTargetRootPath).Returns(Path.GetTempPath()); var storage = new MetaDataStorage(this.engine, matcher.Object, withValidation); string id = "nonExistingId"; var rootFolder = new MappedObject("name", "otherId", MappedObjectType.Folder, null, null); var otherFolder = new MappedObject("name", id, MappedObjectType.Folder, "otherId", null); storage.SaveMappedObject(rootFolder); Assert.That(storage.GetLocalPath(otherFolder), Is.Null); }