public void Login_ValidUser_ShouldTriggerLoginEvents(FakeMembershipUser user, [Frozen] IAccountTrackerService accountTrackerService, AuthenticationProvider authenticationProvider, AccountRepository repo) { authenticationProvider.Login(@"somedomain\John", Arg.Any <string>(), Arg.Any <bool>()).Returns(true); var context = new FakeSiteContext(new StringDictionary { { "domain", "somedomain" } }); using (new Switcher <Domain, Domain>(new Domain("somedomain"))) { using (new AuthenticationSwitcher(authenticationProvider)) { var loginResult = repo.Login("John", "somepassword"); accountTrackerService.Received(1).TrackLogin("somedomain\\John"); } } }
public void Register_ValidUser_ShouldTrackRegistraionEvents(FakeMembershipUser user, [Substitute] MembershipProvider membershipProvider, [Substitute] AuthenticationProvider authenticationProvider, RegistrationInfo registrationInfo, [Frozen] IAccountTrackerService accountTrackerService, AccountRepository repository, string profileId) { user.UserName.Returns("name"); MembershipCreateStatus status; membershipProvider.CreateUser(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <bool>(), Arg.Any <object>(), out status).Returns(user); membershipProvider.GetUser(Arg.Any <string>(), Arg.Any <bool>()).Returns(user); using (new Switcher <Domain, Domain>(new Domain("somedomain"))) { using (new MembershipSwitcher(membershipProvider)) { using (new AuthenticationSwitcher(authenticationProvider)) { repository.RegisterUser(registrationInfo.Email, registrationInfo.Password, profileId); accountTrackerService.Received(1).TrackRegistration(); } } } }