Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created March 24, 2012 08:59
Show Gist options
  • Select an option

  • Save anaisbetts/2180404 to your computer and use it in GitHub Desktop.

Select an option

Save anaisbetts/2180404 to your computer and use it in GitHub Desktop.
[Fact]
public void LoginScenarioRoutingTest()
{
var mock = new MoqMockingKernel();
mock.Bind<ILoginViewModel>().To<LoginViewModel>();
// Fake out the actual login code that makes sure the password is right
mock.Bind<Func<IObservable<Unit>>>()
.ToConstant<Func<IObservable<Unit>>>(() => Observable.Return(Unit.Default))
.Named("confirmUserPass");
var fixture = new AppViewModel(mock);
// Our app starts on the Login page by default
this.Log().Info("Current Route: {0}", fixture.Router.GetUrlForCurrentRoute());
var loginModel = fixture.Router.CurrentViewModel.First() as ILoginViewModel;
loginModel.Should().NotBeNull();
// Put in a fake user/pass and hit the Ok button
loginModel.User = "foo";
loginModel.Password = "bar";
loginModel.Confirm.Execute(null);
// Make sure we're now showing the repo page
this.Log().Info("Current Route: {0}", fixture.Router.GetUrlForCurrentRoute());
(fixture.Router.CurrentViewModel.First() is IRepoViewModel).Should().BeTrue();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment