@@ -30,7 +30,8 @@ public async Task LoadsRepositories()
3030 repositoryHost ,
3131 cloneService ,
3232 Substitute . For < IOperatingSystem > ( ) ,
33- Substitute . For < INotificationService > ( ) ) ;
33+ Substitute . For < INotificationService > ( ) ,
34+ Substitute . For < IUsageTracker > ( ) ) ;
3435
3536 await vm . LoadRepositoriesCommand . ExecuteAsync ( ) ;
3637
@@ -51,7 +52,8 @@ public void StartsTrueBecomesFalseWhenCompleted()
5152 repositoryHost ,
5253 cloneService ,
5354 Substitute . For < IOperatingSystem > ( ) ,
54- Substitute . For < INotificationService > ( ) ) ;
55+ Substitute . For < INotificationService > ( ) ,
56+ Substitute . For < IUsageTracker > ( ) ) ;
5557
5658 Assert . False ( vm . IsLoading ) ;
5759
@@ -80,7 +82,8 @@ public void IsFalseWhenLoadingReposFailsImmediately()
8082 repositoryHost ,
8183 cloneService ,
8284 Substitute . For < IOperatingSystem > ( ) ,
83- Substitute . For < INotificationService > ( ) ) ;
85+ Substitute . For < INotificationService > ( ) ,
86+ Substitute . For < IUsageTracker > ( ) ) ;
8487
8588 vm . LoadRepositoriesCommand . ExecuteAsync ( ) . Subscribe ( ) ;
8689
@@ -103,7 +106,8 @@ public void IsTrueInitially()
103106 repositoryHost ,
104107 cloneService ,
105108 Substitute . For < IOperatingSystem > ( ) ,
106- Substitute . For < INotificationService > ( ) ) ;
109+ Substitute . For < INotificationService > ( ) ,
110+ Substitute . For < IUsageTracker > ( ) ) ;
107111
108112 Assert . True ( vm . NoRepositoriesFound ) ;
109113 }
@@ -119,7 +123,8 @@ public void IsFalseWhenLoadingAndCompletedWithRepository()
119123 repositoryHost ,
120124 cloneService ,
121125 Substitute . For < IOperatingSystem > ( ) ,
122- Substitute . For < INotificationService > ( ) ) ;
126+ Substitute . For < INotificationService > ( ) ,
127+ Substitute . For < IUsageTracker > ( ) ) ;
123128 vm . LoadRepositoriesCommand . ExecuteAsync ( ) . Subscribe ( ) ;
124129
125130 repoSubject . OnNext ( new [ ] { Substitute . For < IRepositoryModel > ( ) } ) ;
@@ -143,7 +148,8 @@ public void IsFalseWhenFailed()
143148 repositoryHost ,
144149 cloneService ,
145150 Substitute . For < IOperatingSystem > ( ) ,
146- Substitute . For < INotificationService > ( ) ) ;
151+ Substitute . For < INotificationService > ( ) ,
152+ Substitute . For < IUsageTracker > ( ) ) ;
147153 vm . LoadRepositoriesCommand . ExecuteAsync ( ) . Subscribe ( ) ;
148154
149155 repoSubject . OnError ( new InvalidOperationException ( ) ) ;
@@ -162,7 +168,8 @@ public void IsTrueWhenLoadingCompleteNotFailedAndNoRepositories()
162168 repositoryHost ,
163169 cloneService ,
164170 Substitute . For < IOperatingSystem > ( ) ,
165- Substitute . For < INotificationService > ( ) ) ;
171+ Substitute . For < INotificationService > ( ) ,
172+ Substitute . For < IUsageTracker > ( ) ) ;
166173 vm . LoadRepositoriesCommand . ExecuteAsync ( ) . Subscribe ( ) ;
167174
168175 repoSubject . OnCompleted ( ) ;
@@ -184,7 +191,8 @@ public void IsTrueIfLoadingReposFails()
184191 repositoryHost ,
185192 cloneService ,
186193 Substitute . For < IOperatingSystem > ( ) ,
187- Substitute . For < INotificationService > ( ) ) ;
194+ Substitute . For < INotificationService > ( ) ,
195+ Substitute . For < IUsageTracker > ( ) ) ;
188196 vm . LoadRepositoriesCommand . ExecuteAsync ( ) . Subscribe ( ) ;
189197
190198 Assert . False ( vm . LoadingFailed ) ;
@@ -207,7 +215,8 @@ public void IsEnabledWhenRepositorySelectedAndPathValid()
207215 repositoryHost ,
208216 cloneService ,
209217 Substitute . For < IOperatingSystem > ( ) ,
210- Substitute . For < INotificationService > ( ) ) ;
218+ Substitute . For < INotificationService > ( ) ,
219+ Substitute . For < IUsageTracker > ( ) ) ;
211220 Assert . False ( vm . CloneCommand . CanExecute ( null ) ) ;
212221
213222 vm . BaseRepositoryPath = @"c:\fake\path" ;
@@ -225,7 +234,8 @@ public void IsNotEnabledWhenPathIsNotValid()
225234 repositoryHost ,
226235 cloneService ,
227236 Substitute . For < IOperatingSystem > ( ) ,
228- Substitute . For < INotificationService > ( ) ) ;
237+ Substitute . For < INotificationService > ( ) ,
238+ Substitute . For < IUsageTracker > ( ) ) ;
229239 vm . BaseRepositoryPath = @"c:|fake\path" ;
230240 Assert . False ( vm . CloneCommand . CanExecute ( null ) ) ;
231241
@@ -246,7 +256,8 @@ public async Task DisplaysErrorMessageWhenExceptionOccurs()
246256 repositoryHost ,
247257 cloneService ,
248258 Substitute . For < IOperatingSystem > ( ) ,
249- notificationService ) ;
259+ notificationService ,
260+ Substitute . For < IUsageTracker > ( ) ) ;
250261 vm . BaseRepositoryPath = @"c:\fake" ;
251262 var repository = Substitute . For < IRepositoryModel > ( ) ;
252263 repository . Name . Returns ( "octokit" ) ;
@@ -257,5 +268,24 @@ public async Task DisplaysErrorMessageWhenExceptionOccurs()
257268 notificationService . Received ( ) . ShowError ( @"Failed to clone the repository 'octokit'
258269Email [email protected] if you continue to have problems." ) ; 259270 }
271+
272+ [ Fact ]
273+ public async Task UpdatesMetricsWhenRepositoryCloned ( )
274+ {
275+ var repositoryHost = Substitute . For < IRepositoryHost > ( ) ;
276+ var cloneService = Substitute . For < IRepositoryCloneService > ( ) ;
277+ var usageTracker = Substitute . For < IUsageTracker > ( ) ;
278+ var vm = new RepositoryCloneViewModel (
279+ repositoryHost ,
280+ cloneService ,
281+ Substitute . For < IOperatingSystem > ( ) ,
282+ Substitute . For < INotificationService > ( ) ,
283+ usageTracker ) ;
284+
285+ vm . SelectedRepository = Substitute . For < IRepositoryModel > ( ) ;
286+ await vm . CloneCommand . ExecuteAsync ( ) ;
287+
288+ usageTracker . Received ( ) . IncrementCloneCount ( ) ;
289+ }
260290 }
261291}
0 commit comments