File tree Expand file tree Collapse file tree
tests/SecureFolderFS.Tests/FileSystemTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
12using System . Text ;
3+ using System . Threading ;
24using FluentAssertions ;
35using NUnit . Framework ;
46using OwlCore . Storage ;
@@ -38,12 +40,12 @@ public async Task Write_SmallStreamedFile_Then_WriteAgain_Ensure_CacheHit_NoThro
3840
3941 var cacheHits = 0 ;
4042 var cacheMisses = 0 ;
41- _storageRoot . Options . FileSystemStatistics . ChunkCache = new Progress < CacheAccessType > ( x =>
43+ _storageRoot . Options . FileSystemStatistics . ChunkCache = new InlineProgress < CacheAccessType > ( x =>
4244 {
4345 if ( x == CacheAccessType . CacheHit )
44- cacheHits ++ ;
46+ Interlocked . Increment ( ref cacheHits ) ;
4547 else if ( x == CacheAccessType . CacheMiss )
46- cacheMisses ++ ;
48+ Interlocked . Increment ( ref cacheMisses ) ;
4749 } ) ;
4850
4951 // Act
@@ -66,5 +68,17 @@ public async Task Write_SmallStreamedFile_Then_WriteAgain_Ensure_CacheHit_NoThro
6668 Encoding . UTF8 . GetString ( buffer ) . Should ( ) . BeEquivalentTo ( dataString + dataString ) ;
6769 cacheMisses . Should ( ) . Be ( 1 ) ;
6870 }
71+
72+ private sealed class InlineProgress < T > : IProgress < T >
73+ {
74+ private readonly Action < T > _handler ;
75+
76+ public InlineProgress ( Action < T > handler )
77+ {
78+ _handler = handler ?? throw new ArgumentNullException ( nameof ( handler ) ) ;
79+ }
80+
81+ public void Report ( T value ) => _handler ( value ) ;
82+ }
6983 }
70- }
84+ }
You can’t perform that action at this time.
0 commit comments