99
1010namespace RevitSystemTests
1111{
12- /// <summary>
13- /// Smoke tests for OOTB D4R sample scripts. Resolves .dyn files from
14- /// DynamoForRevit\samples\{locale}\Revit\ via <see cref="ResolveSamplePath"/>.
15- /// </summary>
1612 [ TestFixture ]
1713 class OOTB_D4R_SampleTests : RevitSystemTestBase
1814 {
1915 private static string ResolveSamplePath ( string scriptFileName )
2016 {
2117 string assemblyDir = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
22- // Deployed layout: {parentDir}\samples\{locale}\Revit\ (not doc/distrib/Samples)
2318 string parentDir = Path . GetDirectoryName ( assemblyDir ) ;
24- string samplesFolder = Path . Combine ( parentDir , "samples" ) ;
25-
26- if ( Directory . Exists ( samplesFolder ) )
27- {
28- foreach ( var locale in new [ ] { System . Globalization . CultureInfo . CurrentUICulture . Name , "en-US" } . Distinct ( ) )
29- {
30- string localePath = Path . Combine ( samplesFolder , locale , "Revit" ) ;
31- if ( Directory . Exists ( localePath ) )
32- {
33- var resolved = Path . Combine ( localePath , scriptFileName ) ;
34- if ( File . Exists ( resolved ) )
35- return resolved ;
36- }
37- }
38- }
39-
40- var hint = Directory . Exists ( samplesFolder )
41- ? $ "Contents:{ string . Concat ( Directory . EnumerateFileSystemEntries ( samplesFolder ) . OrderBy ( e => e ) . Select ( e => $ "\n { e } ") ) } "
42- : Directory . Exists ( parentDir )
43- ? $ "Parent dir contents:{ string . Concat ( Directory . EnumerateDirectories ( parentDir ) . OrderBy ( e => e ) . Select ( e => $ "\n { e } ") ) } "
44- : string . Empty ;
19+ string resolved = Path . Combine ( parentDir , "samples" , "en-US" , "Revit" , scriptFileName ) ;
20+ if ( File . Exists ( resolved ) )
21+ return resolved ;
4522
4623 throw new FileNotFoundException (
47- $ "Cannot locate OOTB D4R sample script '{ scriptFileName } '.\n " +
48- $ "Samples folder: { samplesFolder } \n { hint } ") ;
24+ $ "Cannot locate OOTB D4R sample script '{ scriptFileName } ' under { Path . Combine ( parentDir , "samples" ) } .") ;
4925 }
5026
5127 private void OpenAndRunSample ( string scriptFileName )
@@ -72,11 +48,9 @@ private void OpenAndRunSample(string scriptFileName)
7248 if ( errorNodes . Any ( ) )
7349 {
7450 var first = errorNodes [ 0 ] ;
75- var msg = first . NodeInfos
76- . FirstOrDefault ( i => i . State == ElementState . Error ) ? . Message ;
7751 Assert . Fail (
7852 $ "After RunCurrentModel(), { errorNodes . Count } node(s) in error in '{ scriptFileName } '. " +
79- $ "First: [{ first . State } ] { first . Name } " + ( msg != null ? $ ": { msg } " : string . Empty ) ) ;
53+ $ "First: [{ first . State } ] { first . Name } ") ;
8054 }
8155 }
8256
0 commit comments