1- #region -- License Terms --
1+ #region -- License Terms --
22//
33// MessagePack for CLI
44//
@@ -139,12 +139,17 @@ public void TestToString_EmptyString()
139139 Assert . AreEqual ( String . Empty , target . ToString ( ) ) ;
140140 }
141141
142- #if ! UNITY && ! SILVERLIGHT && ! AOT && ! NETFX_CORE && ! NETSTANDARD1_3
143142 [ Test ]
144143 public void TestEqualsFullTrust ( )
145144 {
146145 var result = TestEqualsCore ( ) ;
146+ #if ! UNITY && ! WINDOWS_PHONE && ! NETFX_CORE
147+ #if SILVERLIGHT && ! SILVERLIGHT_PRIVILEGED
148+ Assert . That ( MessagePackString . IsFastEqualsDisabled , Is . True ) ;
149+ #else // SILVERLIGHT && !SILVERLIGHT_PRIVILEGED
147150 Assert . That ( MessagePackString . IsFastEqualsDisabled , Is . False ) ;
151+ #endif // SILVERLIGHT && !SILVERLIGHT_PRIVILEGED
152+ #endif // !UNITY && !WINDOWS_PHONE && !NETFX_CORE
148153 Debug . WriteLine ( "TestEqualsFullTrust" ) ;
149154 ShowResult ( result ) ;
150155 }
@@ -157,8 +162,6 @@ private void ShowResult( Tuple<double, double, double, double> result )
157162 Debug . WriteLine ( "Large(100,000 chars) : {0:#,0.0} usec" , result . Item4 ) ;
158163 }
159164
160- #endif // !UNITY && !SILVERLIGHT && !AOT && !NETFX_CORE && !NETSTANDARD1_3
161-
162165#if ! SILVERLIGHT && ! AOT && ! NETSTANDARD1_1 && ! NETSTANDARD1_3 && ! NETFX_CORE && ! NETSTANDARD2_0
163166 private static StrongName GetStrongName ( Type type )
164167 {
@@ -243,6 +246,8 @@ public static void TestEqualsWorker()
243246 AppDomain . CurrentDomain . SetData ( "MessagePackString.IsFastEqualsDisabled" , MessagePackString . IsFastEqualsDisabled ) ;
244247 }
245248
249+ #endif // !SILVERLIGHT && !AOT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE && !NETSTANDARD2_0
250+
246251 private static Tuple < double , double , double , double > TestEqualsCore ( )
247252 {
248253 Assert . IsTrue (
@@ -320,7 +325,8 @@ private static Tuple<double, double, double, double> TestEqualsCore()
320325 var sw = new Stopwatch ( ) ;
321326 for ( int i = 0 ; i < iteration ; i ++ )
322327 {
323- sw . Restart ( ) ;
328+ sw . Reset ( ) ;
329+ sw . Start ( ) ;
324330 for ( int x = 0 ; x < values . Length ; x ++ )
325331 {
326332 Assert . That ( values [ x ] . Equals ( null ) , Is . False ) ;
@@ -331,44 +337,62 @@ private static Tuple<double, double, double, double> TestEqualsCore()
331337 }
332338 }
333339 sw . Stop ( ) ;
334- tinyAvg = Math . Min ( tinyAvg , sw . Elapsed . Ticks * 10.0 / ( values . Length * values . Length ) ) ;
340+ #if SILVERLIGHT && ! WINDOWS_PHONE
341+ tinyAvg = Math . Min ( tinyAvg , sw . ElapsedMilliseconds * 1000.0 / ( values . Length * values . Length ) ) ;
342+ #else
343+ tinyAvg = Math . Min ( tinyAvg , sw . Elapsed . Ticks / 10.0 / ( values . Length * values . Length ) ) ;
344+ #endif
335345 }
336346
337347 var smallX = new MessagePackString ( new String ( 'A' , 16 ) ) ;
338348 var smallY = new MessagePackString ( MessagePackConvert . EncodeString ( new String ( 'A' , 16 ) ) , false ) ;
339349
340350 for ( int i = 0 ; i < iteration ; i ++ )
341351 {
342- sw . Restart ( ) ;
352+ sw . Reset ( ) ;
353+ sw . Start ( ) ;
343354 Assert . That ( smallX . Equals ( smallY ) , Is . True ) ;
344355 sw . Stop ( ) ;
345- smallAvg = Math . Min ( smallAvg , sw . Elapsed . Ticks * 10.0 ) ;
356+ #if SILVERLIGHT && ! WINDOWS_PHONE
357+ smallAvg = Math . Min ( smallAvg , sw . ElapsedMilliseconds * 1000.0 ) ;
358+ #else
359+ smallAvg = Math . Min ( smallAvg , sw . Elapsed . Ticks / 10.0 ) ;
360+ #endif
346361 }
347362
348363 var mediumX = new MessagePackString ( new String ( 'A' , 1000 ) ) ;
349364 var mediumY = new MessagePackString ( MessagePackConvert . EncodeString ( new String ( 'A' , 1000 ) ) , false ) ;
350365
351366 for ( int i = 0 ; i < iteration ; i ++ )
352367 {
353- sw . Restart ( ) ;
368+ sw . Reset ( ) ;
369+ sw . Start ( ) ;
354370 Assert . That ( mediumX . Equals ( mediumY ) , Is . True ) ;
355371 sw . Stop ( ) ;
356- mediumAvg = Math . Min ( mediumAvg , sw . Elapsed . Ticks * 10.0 ) ;
372+ #if SILVERLIGHT && ! WINDOWS_PHONE
373+ mediumAvg = Math . Min ( mediumAvg , sw . ElapsedMilliseconds * 1000.0 ) ;
374+ #else
375+ mediumAvg = Math . Min ( mediumAvg , sw . Elapsed . Ticks / 10.0 ) ;
376+ #endif
357377 }
358378
359379 var largeX = new MessagePackString ( new String ( 'A' , 100000 ) ) ;
360380 var largeY = new MessagePackString ( MessagePackConvert . EncodeString ( new String ( 'A' , 100000 ) ) , false ) ;
361381
362382 for ( int i = 0 ; i < iteration ; i ++ )
363383 {
364- sw . Restart ( ) ;
384+ sw . Reset ( ) ;
385+ sw . Start ( ) ;
365386 Assert . That ( largeX . Equals ( largeY ) , Is . True ) ;
366387 sw . Stop ( ) ;
367- largeAvg = Math . Min ( largeAvg , sw . Elapsed . Ticks * 10.0 ) ;
388+ #if SILVERLIGHT && ! WINDOWS_PHONE
389+ largeAvg = Math . Min ( largeAvg , sw . ElapsedMilliseconds * 1000.0 ) ;
390+ #else
391+ largeAvg = Math . Min ( largeAvg , sw . Elapsed . Ticks / 10.0 ) ;
392+ #endif
368393 }
369394
370395 return Tuple . Create ( tinyAvg , smallAvg , mediumAvg , largeAvg ) ;
371396 }
372- #endif // !SILVERLIGHT && !AOT && !NETSTANDARD1_1 && !NETSTANDARD1_3 && !NETFX_CORE && !NETSTANDRD2_0
373397 }
374398}
0 commit comments