@@ -12,7 +12,6 @@ namespace IntegrationTests
12
12
[ TestFixture ]
13
13
class MetricsTests : BaseIntegrationTest
14
14
{
15
-
16
15
[ TestCase ( nameof ( Measures . AssetExplorerContextMenuLfsLock ) ) ]
17
16
[ TestCase ( nameof ( Measures . AssetExplorerContextMenuLfsUnlock ) ) ]
18
17
[ TestCase ( nameof ( Measures . AuthenticationViewButtonAuthentication ) ) ]
@@ -29,7 +28,6 @@ class MetricsTests : BaseIntegrationTest
29
28
[ TestCase ( nameof ( Measures . SettingsViewUnlockButtonLfsUnlock ) ) ]
30
29
public void IncrementMetricsWorks ( string measureName )
31
30
{
32
- InitializeEnvironment ( TestBasePath , null , false , false ) ;
33
31
var userId = Guid . NewGuid ( ) . ToString ( ) ;
34
32
var appVersion = ApplicationConfiguration . AssemblyName . Version . ToString ( ) ;
35
33
var unityVersion = "2017.3f1" ;
@@ -50,5 +48,25 @@ public void IncrementMetricsWorks(string measureName)
50
48
currentUsage = usageStore . GetCurrentMeasures ( appVersion , unityVersion , instanceId ) ;
51
49
Assert . AreEqual ( 1 , prop . GetValue ( currentUsage , null ) ) ;
52
50
}
51
+
52
+ [ Test ]
53
+ public void LoadingWorks ( )
54
+ {
55
+ InitializeEnvironment ( TestBasePath , TestBasePath , false , false ) ;
56
+ var userId = Guid . NewGuid ( ) . ToString ( ) ;
57
+ var appVersion = ApplicationConfiguration . AssemblyName . Version . ToString ( ) ;
58
+ var unityVersion = "2017.3f1" ;
59
+ var instanceId = Guid . NewGuid ( ) . ToString ( ) ;
60
+ var usageStore = new UsageStore ( ) ;
61
+ usageStore . Model . Guid = userId ;
62
+ var usageTracker = new UsageTracker ( Substitute . For < IMetricsService > ( ) , Substitute . For < ISettings > ( ) ,
63
+ Environment , userId , unityVersion , instanceId ) ;
64
+ usageTracker . IncrementNumberOfStartups ( ) ;
65
+ var storePath = Environment . UserCachePath . Combine ( Constants . UsageFile ) ;
66
+ Assert . IsTrue ( storePath . FileExists ( ) ) ;
67
+ var json = storePath . ReadAllText ( Encoding . UTF8 ) ;
68
+ var savedStore = json . FromJson < UsageStore > ( lowerCase : true ) ;
69
+ Assert . AreEqual ( 1 , savedStore . GetCurrentMeasures ( appVersion , unityVersion , instanceId ) . NumberOfStartups ) ;
70
+ }
53
71
}
54
72
}
0 commit comments