@@ -6,7 +6,8 @@ namespace CodeBreaker.ViewModels.Tests;
66
77public class GamePageViewModelTests
88{
9- private readonly GamePageViewModel _viewModel ;
9+ private readonly Mock < IGamesClient > _gamesClientMock ;
10+ private readonly Mock < IInfoBarService > _infoBarServiceMock ;
1011
1112 public GamePageViewModelTests ( )
1213 {
@@ -16,39 +17,39 @@ public GamePageViewModelTests()
1617 { "colors" , new string [ ] { "Black" , "White" , "Red" , "Green" , "Blue" , "Yellow" } }
1718 } ) ;
1819
19- Mock < IGamesClient > gameClient = new ( ) ;
20- gameClient . Setup ( client => client . StartGameAsync ( GameType . Game6x4 , "Test" , CancellationToken . None ) ) . ReturnsAsync ( returnValue ) ;
20+ _gamesClientMock = new ( ) ;
21+ _gamesClientMock . Setup ( client => client . StartGameAsync ( GameType . Game6x4 , "Test" , CancellationToken . None ) ) . ReturnsAsync ( returnValue ) ;
2122
22- Mock < IInfoBarService > infoBarService = new ( ) ;
23-
24- _viewModel = new GamePageViewModel ( gameClient . Object , infoBarService . Object ) ;
23+ _infoBarServiceMock = new ( ) ;
2524 }
2625
2726 [ Fact ]
2827 public async Task TestGameModeStartedAfterStart ( )
2928 {
30- _viewModel . Name = "Test" ;
31- await _viewModel . StartGameCommand . ExecuteAsync ( null ) ;
29+ var viewModel = new GamePageViewModel ( _gamesClientMock . Object , _infoBarServiceMock . Object ) ;
30+ viewModel . Name = "Test" ;
31+ await viewModel . StartGameCommand . ExecuteAsync ( null ) ;
3232
3333 Assert . Equal ( GameMode . Started , _viewModel . GameStatus ) ;
3434 }
3535
3636 [ Fact ]
3737 public async Task TestInProgressNotificationAfterStart ( )
3838 {
39+ var viewModel = new GamePageViewModel ( _gamesClientMock . Object , _infoBarServiceMock . Object ) ;
3940 List < bool > expected = new ( ) { true , false } ;
40- _viewModel . Name = "Test" ;
41+ viewModel . Name = "Test" ;
4142 List < bool > inProgressValues = new ( ) ;
4243
43- _viewModel . PropertyChanged += ( sender , e ) =>
44+ viewModel . PropertyChanged += ( sender , e ) =>
4445 {
4546 if ( e . PropertyName is "InProgress" )
4647 {
4748 inProgressValues . Add ( _viewModel . InProgress ) ;
4849 }
4950 } ;
5051
51- await _viewModel . StartGameCommand . ExecuteAsync ( null ) ;
52+ await viewModel . StartGameCommand . ExecuteAsync ( null ) ;
5253
5354 Assert . Equal ( expected , inProgressValues ) ;
5455 }
0 commit comments