mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Using StackTrace to discover content files in SpecFlow tests
--HG-- branch : 1.4.x
This commit is contained in:
@@ -215,7 +215,26 @@ namespace Orchard.Specs.Hosting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void CopyFile(string source, string destination) {
|
public void CopyFile(string source, string destination) {
|
||||||
var origin = Path.Get(typeof(IOrchardServices).Assembly.Location).Parent.Parent.Combine(source);
|
|
||||||
|
StackTrace st = new StackTrace(true);
|
||||||
|
Path origin = null;
|
||||||
|
foreach(var sf in st.GetFrames()) {
|
||||||
|
var sourceFile = sf.GetFileName();
|
||||||
|
if(String.IsNullOrEmpty(sourceFile)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var testOrigin = Path.Get(sourceFile).Parent.Combine(source);
|
||||||
|
if(testOrigin.Exists) {
|
||||||
|
origin = testOrigin;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(origin == null) {
|
||||||
|
throw new FileNotFoundException("File not found: " + source);
|
||||||
|
}
|
||||||
|
|
||||||
var target = _tempSite.Combine(destination);
|
var target = _tempSite.Combine(destination);
|
||||||
|
|
||||||
Directory.CreateDirectory(target.DirectoryName);
|
Directory.CreateDirectory(target.DirectoryName);
|
||||||
|
Reference in New Issue
Block a user