public async Task TestRestoreStateDuringPendingRequest()
        {
            //Interactor will return after a delay. We will cancel before this request returns
            _mockInteractor.Setup(interactor => interactor.Login(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Task.Run(() =>
            {
                Task.Delay(100).Wait();
                return(new Result <bool>(true));
            }));

            _presenter.UpdateUsername("User");
            _presenter.UpdatePassword("Pass");

            Task task = _presenter.Login();

            //null out view reference so that view will not be updated by this presenter
            IList <string> state = _presenter.SaveState();

            _presenter.View = null;
            await task;

            //Old presenter is destroyed. create new presenter and reattach to view
            _presenter = new LoginPresenter(_view, _mockInteractor.Object);

            Assert.False(_view.NavigatingToNextScreen);

            await _presenter.RestoreState(state);

            Assert.True(_view.NavigatingToNextScreen);

            //Login should have been called twice total. Once in the old presenter and once after restoring
            _mockInteractor.Verify(interactor => interactor.Login(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(2));
        }
        public async Task TestRestorePresenterInputState()
        {
            Assert.False(_view.NavigatingToNextScreen);

            _presenter.UpdateUsername("User");
            _presenter.UpdatePassword("Pass");

            IList <string> state = _presenter.SaveState();

            //Old presenter is destroyed. create new presenter and reattach to view
            _presenter = new LoginPresenter(_view, _mockInteractor.Object);

            await _presenter.Login();

            //Login is not called. We have not restored state so the presenter does not have the input credentials
            _mockInteractor.Verify(interactor => interactor.Login(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
            Assert.False(_view.NavigatingToNextScreen);

            await _presenter.RestoreState(state);

            await _presenter.Login();

            //Now that we have restored state, Login should have been requested successfully
            _mockInteractor.Verify(interactor => interactor.Login(It.IsAny <string>(), It.IsAny <string>()), Times.Once);

            Assert.True(_view.NavigatingToNextScreen);
        }