public TheSelectClientAction()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
            }
            public TheSelectClientCommand()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                ViewModel.Prepare(Parameters);
            }
            public TheSuggestCreationProperty()
            {
                var client = Substitute.For <IThreadSafeClient>();

                client.Name.Returns(name);
                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(new List <IThreadSafeClient> {
                    client
                }));
                ViewModel.Prepare(Parameters);
            }
            public async Task AddsANoClientSuggestion()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                ViewModel.Prepare(Parameters);

                await ViewModel.Initialize();

                ViewModel.Suggestions.First().Name.Should().Be(Resources.NoClient);
            }
            public async Task SetsNoClientAsSelectedIfTheParameterDoesNotSpecifyTheCurrentClient()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                ViewModel.Prepare(Parameters);

                await ViewModel.Initialize();

                ViewModel.Clients.First().Single(c => c.Selected).Name.Should().Be(Resources.NoClient);
            }
            public async Task AddsAllClientsToTheListOfSuggestions()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                ViewModel.Prepare(Parameters);

                await ViewModel.Initialize();

                ViewModel.Clients.Count().Should().Equals(clients.Count);
            }
            public async Task UpdateWhenFilterTextChanges()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize();

                ViewModel.FilterText.OnNext("0");

                ViewModel.Clients.Count().Should().Equals(1);
            }
            public async Task DoesNotSuggestCreationWhenTextMatchesAExistingClientName()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize();

                ViewModel.FilterText.OnNext(clients.First().Name);

                ViewModel.Clients.First().First().Should().NotBeOfType <SelectableClientCreationViewModel>();
            }
            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));
                ViewModel.Prepare(parameter);

                await ViewModel.Initialize();

                ViewModel.Clients.First().Single(c => c.Selected).Name.Should().Be(id.ToString());
            }
            public async Task FiltersTheSuggestionsWhenItChanges()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                ViewModel.Prepare(Parameters);
                await ViewModel.Initialize();

                ViewModel.Text = "0";

                ViewModel.Suggestions.Should().HaveCount(1);
            }
            public async Task SetsNoClientAsSelectedIfTheParameterDoesNotSpecifyTheCurrentClient()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize(Parameters);

                var observer = CreateClientsObserver();

                TestScheduler.Start();

                observer.LastEmittedValue().Single(c => c.Selected).Name.Should().Be(Resources.NoClient);
            }
            public async Task AddsAllClientsToTheListOfSuggestions()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize(Parameters);

                var observer = CreateClientsObserver();

                TestScheduler.Start();

                observer.LastEmittedValue().Count().Should().Equals(clients.Count);
            }
Exemplo n.º 13
0
            public async Task UpdateWhenFilterTextChanges()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize();

                var observer = CreateClientsObserver();

                ViewModel.FilterText.OnNext("0");
                TestScheduler.Start();

                observer.LastEmittedValue().Count().Should().Equals(1);
            }
Exemplo n.º 14
0
            public async Task AddCreationCellWhenNoMatchingSuggestion()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize();

                var nonExistingClientName = "Some none existing name";

                ViewModel.FilterText.OnNext(nonExistingClientName);

                ViewModel.Clients.First().First().Name.Should().Equals(nonExistingClientName);
                ViewModel.Clients.First().First().Should().BeOfType <SelectableClientCreationViewModel>();
            }
            public async Task AddsANoClientSuggestion()
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize(Parameters);

                var observer = CreateClientsObserver();

                TestScheduler.Start();

                observer.LastEmittedValue().First().Name.Should().Be(Resources.NoClient);
                observer.LastEmittedValue().First().Should().BeOfType <SelectableClientViewModel>();
            }
            public async Task DoesNotSuggestCreatingClientsWhenTheDescriptionConsistsOfOnlyWhiteCharacters(string name)
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize(Parameters);

                var observer = CreateClientsObserver();

                ViewModel.FilterText.OnNext(name);
                TestScheduler.Start();

                observer.LastEmittedValue().First().Should().NotBeOfType <SelectableClientCreationViewModel>();
            }
Exemplo n.º 17
0
            public async Task DoesNotSuggestCreatingClientsWhenTheDescriptionConsistsOfOnlyWhiteCharacters(string name)
            {
                var clients = GenerateClientList();

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                ViewModel.Prepare(Parameters);

                await ViewModel.Initialize();

                ViewModel.FilterText.OnNext(name);

                var receivedClients = await ViewModel.Clients.FirstAsync();

                receivedClients.First().Should().NotBeOfType <SelectableClientCreationViewModel>();
            }
            public async Task ClientListIsSorted()
            {
                var clientNames = new[] { "Microsoft", "Amazon", "Google", "Steam", "Facebook" };
                var clients     = GenerateClientList(clientNames);

                InteractorFactory.GetAllClientsInWorkspace(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(clients));
                await ViewModel.Initialize(Parameters);

                var observer = CreateClientsObserver();

                TestScheduler.Start();

                var resultClientsNames = observer.LastEmittedValue().Select(vm => vm.Name);

                // First item is skipped because when the filter is empty,
                // the collection contains 'No client' item which is always shown at the beginning
                resultClientsNames.Skip(1).Should().BeInAscendingOrder();
            }