Example #1
0
            public void ClearsTheCurrentClientIfZeroIsReturned()
            {
                var          clientObserver = TestScheduler.CreateObserver <string>();
                const string expectedName   = "Some client";
                long?        expectedId     = 10;
                var          client         = Substitute.For <IThreadSafeClient>();

                client.Id.Returns(expectedId.Value);
                client.Name.Returns(expectedName);
                NavigationService
                .Navigate <SelectClientViewModel, SelectClientParameters, long?>(Arg.Any <SelectClientParameters>())
                .Returns(Task.FromResult(expectedId), Task.FromResult <long?>(0));
                InteractorFactory.GetDefaultWorkspace().Execute().Returns(Observable.Return(Workspace));
                InteractorFactory.GetClientById(expectedId.Value).Execute().Returns(Observable.Return(client));
                Workspace.Id.Returns(DefaultWorkspaceId);
                ViewModel.Prepare("Some name");
                ViewModel.PickClient.Execute();
                TestScheduler.Start();
                ViewModel.ClientName.Subscribe(clientObserver);

                ViewModel.PickClient.Execute();
                TestScheduler.Start();

                clientObserver.LastEmittedValue().Should().BeNullOrEmpty();
            }
Example #2
0
            public async Task ClearsTheCurrentClientIfZeroIsReturned()
            {
                const string expectedName = "Some client";
                long?        expectedId   = 10;
                var          client       = Substitute.For <IThreadSafeClient>();

                client.Id.Returns(expectedId.Value);
                client.Name.Returns(expectedName);
                NavigationService
                .Navigate <SelectClientViewModel, SelectClientParameters, long?>(Arg.Any <SelectClientParameters>())
                .Returns(Task.FromResult(expectedId));
                InteractorFactory
                .GetDefaultWorkspace()
                .Execute()
                .Returns(Observable.Return(Workspace));
                InteractorFactory.GetClientById(expectedId.Value)
                .Execute()
                .Returns(Observable.Return(client));
                Workspace.Id.Returns(DefaultWorkspaceId);
                ViewModel.Prepare("Some name");
                await ViewModel.Initialize();

                await ViewModel.PickClientCommand.ExecuteAsync();

                NavigationService
                .Navigate <SelectClientViewModel, SelectClientParameters, long?>(Arg.Any <SelectClientParameters>())
                .Returns(Task.FromResult <long?>(0));

                await ViewModel.PickClientCommand.ExecuteAsync();

                ViewModel.ClientName.Should().BeNullOrEmpty();
            }