@@ -80,5 +80,72 @@ public void DisableAnalytics()
80
80
dynamoCLI ? . Kill ( ) ;
81
81
}
82
82
}
83
+
84
+ [ Test ]
85
+ [ Platform ( "win" ) ] //nunit attribute for now only run on windows until we know it's useful on linux.
86
+ public void DisableAnalyticsViaNoNetWorkMode ( )
87
+ {
88
+ var versions = new List < Version > ( ) {
89
+
90
+ new Version ( 230 , 0 , 0 ) ,
91
+ } ;
92
+
93
+ var directory = new DirectoryInfo ( Assembly . GetExecutingAssembly ( ) . Location ) ;
94
+ var testDirectory = Path . Combine ( directory . Parent . Parent . Parent . FullName , "test" ) ;
95
+ string openPath = Path . Combine ( testDirectory , @"core\Angle.dyn" ) ;
96
+ //go get a valid asm path.
97
+ var locatedPath = string . Empty ;
98
+ var coreDirectory = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
99
+ Process dynamoCLI = null ;
100
+ //TODO an approach we could take to get this running on linux.
101
+ //unclear if this needs to be compiled with an ifdef or runtime is ok.
102
+ //related to https://jira.autodesk.com/browse/DYN-5705
103
+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
104
+ {
105
+ DynamoShapeManager . Utilities . SearchForASMInLibGFallback ( versions , ref locatedPath , coreDirectory , out _ ) ;
106
+ }
107
+ else
108
+ {
109
+ DynamoShapeManager . Utilities . GetInstalledAsmVersion2 ( versions , ref locatedPath , coreDirectory ) ;
110
+ }
111
+ try
112
+ {
113
+ Assert . DoesNotThrow ( ( ) =>
114
+ {
115
+
116
+ dynamoCLI = Process . Start ( new ProcessStartInfo ( Path . Combine ( coreDirectory , "DynamoCLI.exe" ) , $ "--GeometryPath \" { locatedPath } \" -k --NoNetworkMode -o \" { openPath } \" ") { UseShellExecute = true } ) ;
117
+
118
+ Thread . Sleep ( 5000 ) ; // Wait 5 seconds to open the dyn
119
+ Assert . IsFalse ( dynamoCLI . HasExited ) ;
120
+ var dt = DataTarget . AttachToProcess ( dynamoCLI . Id , false ) ;
121
+ var assemblies = dt
122
+ . ClrVersions
123
+ . Select ( dtClrVersion => dtClrVersion . CreateRuntime ( ) )
124
+ . SelectMany ( runtime => runtime . AppDomains . SelectMany ( runtimeAppDomain => runtimeAppDomain . Modules ) )
125
+ . Select ( clrModule => clrModule . AssemblyName )
126
+ . Distinct ( )
127
+ . Where ( x => x != null )
128
+ . ToList ( ) ;
129
+
130
+ var firstASMmodulePath = string . Empty ;
131
+ foreach ( string module in assemblies )
132
+ {
133
+ if ( module . IndexOf ( "Analytics" , StringComparison . OrdinalIgnoreCase ) != - 1 )
134
+ {
135
+ Assert . Fail ( "Analytics module was loaded" ) ;
136
+ }
137
+ if ( module . IndexOf ( "AdpSDKCSharpWrapper" , StringComparison . OrdinalIgnoreCase ) != - 1 )
138
+ {
139
+ Assert . Fail ( "ADP module was loaded" ) ;
140
+ }
141
+ }
142
+ } ) ;
143
+ }
144
+ finally
145
+ {
146
+
147
+ dynamoCLI ? . Kill ( ) ;
148
+ }
149
+ }
83
150
}
84
151
}
0 commit comments