private IObservable <IThreadSafeClient> pickClient() { return(currentWorkspace.FirstAsync() .SelectMany(currentWorkspace => currentClient.FirstAsync() .SelectMany(currentClient => clientFromViewModel(currentClient, currentWorkspace)))); IObservable <IThreadSafeClient> clientFromViewModel(IThreadSafeClient currentClient, IThreadSafeWorkspace currentWorkspace) => Navigate <SelectClientViewModel, SelectClientParameters, long?>( SelectClientParameters.WithIds(currentWorkspace.Id, currentClient?.Id)) .ToObservable() .SelectMany(clientFromId); IObservable <IThreadSafeClient> clientFromId(long?selectedClientId) { if (selectedClientId == null) { return(Observable.Empty <IThreadSafeClient>()); } if (selectedClientId.Value == 0) { return(Observable.Return <IThreadSafeClient>(null)); } return(interactorFactory.GetClientById(selectedClientId.Value).Execute()); } }
private async Task pickClient() { var parameter = SelectClientParameters.WithIds(workspaceId, clientId); var selectedClientId = await navigationService.Navigate <SelectClientViewModel, SelectClientParameters, long?>(parameter); if (selectedClientId == null) { return; } if (selectedClientId.Value == 0) { clientId = null; ClientName = ""; updateIsNameAlreadyTaken(); return; } var client = await interactorFactory.GetClientById(selectedClientId.Value).Execute(); clientId = client.Id; ClientName = client.Name; updateIsNameAlreadyTaken(); }
public async Task SetsTheAppropriateClientAsTheCurrentlySelectedOne(int id) { var parameter = SelectClientParameters.WithIds(10, id); var clients = GenerateClientList(); DataSource.Clients.GetAllInWorkspace(Arg.Any <long>()) .Returns(Observable.Return(clients)); ViewModel.Prepare(parameter); await ViewModel.Initialize(); ViewModel.Suggestions.Single(c => c.Selected).Name.Should().Be(id.ToString()); }
public async Task SetsTheAppropriateClientAsTheCurrentlySelectedOne(int id) { var parameter = SelectClientParameters.WithIds(10, id); var clients = GenerateClientList(); InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>()) .Execute() .Returns(Observable.Return(clients)); await ViewModel.Initialize(parameter); var observer = CreateClientsObserver(); TestScheduler.Start(); observer.LastEmittedValue().Single(c => c.Selected).Name.Should().Be(id.ToString()); }
private async Task pickClient() { var parameter = SelectClientParameters.WithIds(workspaceId, clientId); var selectedClientId = await navigationService.Navigate <SelectClientViewModel, SelectClientParameters, long?>(parameter); if (selectedClientId == null) { return; } if (selectedClientId.Value == 0) { selectedClientId = null; ClientName = ""; return; } var client = await dataSource.Clients.GetById(selectedClientId.Value); clientId = client.Id; ClientName = client.Name; }