public void PassesTheCredentialsToLoginViewModelIfUserTriedToSignUpWithExistingEmail() { var request = Substitute.For <IRequest>(); request.Endpoint.Returns(new Uri("http://any.url.com")); var exception = new EmailIsAlreadyUsedException( new BadRequestException( request, Substitute.For <IResponse>() ) ); UserAccessManager .SignUp(Arg.Any <Email>(), Arg.Any <Password>(), true, Arg.Any <int>(), Arg.Any <string>()) .Returns( Observable.Throw <ITogglDataSource>(exception) ); NavigationService.Navigate <TermsOfServiceViewModel, bool>(); ViewModel.SetEmail(ValidEmail); ViewModel.SetPassword(ValidPassword); ViewModel.Signup.Execute(); TestScheduler.Start(); TestScheduler.Stop(); ViewModel.Login.Execute(); TestScheduler.Start(); NavigationService .Received() .Navigate <LoginViewModel, CredentialsParameter>( Arg.Is <CredentialsParameter>( parameter => parameter.Email.Equals(ValidEmail) && parameter.Password.Equals(ValidPassword) ) ); }
public void PassesTheCredentialsToLoginViewModelIfUserTriedToSignUpWithExistingEmail() { var exception = new EmailIsAlreadyUsedException( new BadRequestException( Substitute.For <IRequest>(), Substitute.For <IResponse>() ) ); LoginManager .SignUp(Arg.Any <Email>(), Arg.Any <Password>(), true, Arg.Any <int>()) .Returns( Observable.Throw <ITogglDataSource>(exception) ); NavigationService.Navigate <bool>(typeof(TermsOfServiceViewModel)).Returns(true); ViewModel.Email = ValidEmail; ViewModel.Password = ValidPassword; ViewModel.SignupCommand.Execute(); ViewModel.LoginCommand.Execute(); NavigationService .Received() .Navigate <NewLoginViewModel, CredentialsParameter>( Arg.Is <CredentialsParameter>( parameter => parameter.Email.Equals(ViewModel.Email) && parameter.Password.Equals(ViewModel.Password) ) ); }