public async Task WhenConnectionMadePositionsRequested() { // Arrange var builder = new MainViewModelBuilder(); ConnectionTest(builder, 0, 0); var accountManager = Substitute.For <IAccountManager>(); var vm = builder .WithAccountManager(accountManager) .Build(); // Act await vm.ConnectCommand.ExecuteAsync(); // Assert await accountManager.Received().RequestPositionsAsync(); }
private void ConnectionTest(MainViewModelBuilder builder, double netLiquidationValue, double exchangeRate) { var connectionService = Substitute.For <IConnectionService>(); connectionService.When(x => x.ConnectAsync()) .Do(x => { builder.ConnectionService.IsConnected.Returns(true); Messenger.Default.Send(new ConnectionChangedMessage(true)); }); builder.WithConnectionService(connectionService); var accountManager = Substitute.For <IAccountManager>(); accountManager.RequestAccountSummaryAsync().Returns(Task.FromResult(new AccountSummary { NetLiquidation = netLiquidationValue })); builder.WithAccountManager(accountManager); }