public AccountController(
     ApplicationUserManager userManager,
     IUserRegisterer userRegisterer,
     IFirstTimeAuthenticator firstTimeAuthenticator,
     IAuthenticationManager authenticationManager,
     IGamingGroupInviteConsumer gamingGroupInvitationConsumer,
     IGamingGroupRetriever gamingGroupRetriever,
     IBoardGameGeekUserSaver boardGameGeekUserSaver,
     IBoardGameGeekApiClient boardGameGeekApiClient,
     IUserRetriever userRetriever,
     ITransformer transformer,
     IGamingGroupContextSwitcher gamingGroupContextSwitcher)
 {
     _userManager                   = userManager;
     _userRegisterer                = userRegisterer;
     _firstTimeAuthenticator        = firstTimeAuthenticator;
     _authenticationManager         = authenticationManager;
     _gamingGroupInvitationConsumer = gamingGroupInvitationConsumer;
     _gamingGroupRetriever          = gamingGroupRetriever;
     _boardGameGeekUserSaver        = boardGameGeekUserSaver;
     _boardGameGeekApiClient        = boardGameGeekApiClient;
     _userRetriever                 = userRetriever;
     _transformer                   = transformer;
     _gamingGroupContextSwitcher    = gamingGroupContextSwitcher;
 }
Exemplo n.º 2
0
        public virtual void SetUp()
        {
            userStoreMock = MockRepository.GenerateMock <IUserStore <ApplicationUser> >();
            gamingGroupInviteConsumerMock   = MockRepository.GenerateMock <IGamingGroupInviteConsumer>();
            userRegistererMock              = MockRepository.GenerateMock <IUserRegisterer>();
            this.firstTimeAuthenticatorMock = MockRepository.GenerateMock <IFirstTimeAuthenticator>();
            this.authenticationManagerMock  = MockRepository.GenerateMock <IAuthenticationManager>();
            var dataProtector = MockRepository.GenerateMock <IDataProtector>();

            dataProtectionProviderMock = MockRepository.GenerateMock <IDataProtectionProvider>();
            gamingGroupRetrieverMock   = MockRepository.GenerateMock <IGamingGroupRetriever>();
            dataProtectionProviderMock.Expect(mock => mock.Create(Arg <string> .Is.Anything)).Return(dataProtector);

            userManager = new ApplicationUserManager(userStoreMock, dataProtectionProviderMock);
            accountControllerPartialMock = MockRepository.GeneratePartialMock <AccountController>(
                userManager,
                userRegistererMock,
                this.firstTimeAuthenticatorMock,
                this.authenticationManagerMock,
                gamingGroupInviteConsumerMock,
                gamingGroupRetrieverMock);
            currentUser = new ApplicationUser()
            {
                Id = "new application user",
                CurrentGamingGroupId = 1
            };
            registerViewModel = new RegisterViewModel()
            {
                ConfirmPassword = "******",
                Password        = "******",
                UserName        = "******",
                EmailAddress    = "*****@*****.**"
            };
        }
Exemplo n.º 3
0
 public UserRegisterer(
     ApplicationUserManager applicationUserManager, 
     IFirstTimeAuthenticator firstTimeUserAuthenticator, 
     IDataContext dataContext, 
     ApplicationSignInManager signInManager,
     INemeStatsEventTracker eventTracker, 
     IGamingGroupInviteConsumer gamingGroupInviteConsumer)
 {
     this.applicationUserManager = applicationUserManager;
     this.firstTimeUserAuthenticator = firstTimeUserAuthenticator;
     this.dataContext = dataContext;
     this.signInManager = signInManager;
     this.eventTracker = eventTracker;
     this.gamingGroupInviteConsumer = gamingGroupInviteConsumer;
 }
Exemplo n.º 4
0
 public UserRegisterer(
     ApplicationUserManager applicationUserManager,
     IFirstTimeAuthenticator firstTimeUserAuthenticator,
     IDataContext dataContext,
     ApplicationSignInManager signInManager,
     INemeStatsEventTracker eventTracker,
     IGamingGroupInviteConsumer gamingGroupInviteConsumer)
 {
     this.applicationUserManager     = applicationUserManager;
     this.firstTimeUserAuthenticator = firstTimeUserAuthenticator;
     this.dataContext               = dataContext;
     this.signInManager             = signInManager;
     this.eventTracker              = eventTracker;
     this.gamingGroupInviteConsumer = gamingGroupInviteConsumer;
 }
Exemplo n.º 5
0
 public AccountController(
     ApplicationUserManager userManager,
     IUserRegisterer userRegisterer,
     IFirstTimeAuthenticator firstTimeAuthenticator,
     IAuthenticationManager authenticationManager,
     IGamingGroupInviteConsumer gamingGroupInvitationConsumer,
     IGamingGroupRetriever gamingGroupRetriever)
 {
     this.userManager                   = userManager;
     this.userRegisterer                = userRegisterer;
     this.firstTimeAuthenticator        = firstTimeAuthenticator;
     this.authenticationManager         = authenticationManager;
     this.gamingGroupInvitationConsumer = gamingGroupInvitationConsumer;
     _gamingGroupRetriever              = gamingGroupRetriever;
 }
        public virtual void SetUp()
        {
            userStoreMock = MockRepository.GenerateMock<IUserStore<ApplicationUser>>();
            gamingGroupInviteConsumerMock = MockRepository.GenerateMock<IGamingGroupInviteConsumer>();
            userRegistererMock = MockRepository.GenerateMock<IUserRegisterer>();
            this.firstTimeAuthenticatorMock = MockRepository.GenerateMock<IFirstTimeAuthenticator>();
            this.authenticationManagerMock = MockRepository.GenerateMock<IAuthenticationManager>();
            var dataProtector = MockRepository.GenerateMock<IDataProtector>();
            dataProtectionProviderMock = MockRepository.GenerateMock<IDataProtectionProvider>();
            gamingGroupRetrieverMock = MockRepository.GenerateMock<IGamingGroupRetriever>();
            
            boardGameGeekUserSaver = MockRepository.GenerateMock<IBoardGameGeekUserSaver>();
            boardGameGeekApiClient = MockRepository.GenerateMock<IBoardGameGeekApiClient>();
            userRetriever = MockRepository.GenerateMock<IUserRetriever>();

            dataProtectionProviderMock.Expect(mock => mock.Create(Arg<string>.Is.Anything)).Return(dataProtector);

            userManager = new ApplicationUserManager(userStoreMock, dataProtectionProviderMock);
            accountControllerPartialMock = MockRepository.GeneratePartialMock<AccountController>(
                userManager,
                userRegistererMock,
                this.firstTimeAuthenticatorMock,
                this.authenticationManagerMock,
                gamingGroupInviteConsumerMock, 
                gamingGroupRetrieverMock,
                boardGameGeekUserSaver,
                boardGameGeekApiClient,
                userRetriever);
            currentUser = new ApplicationUser()
            {
                Id = "new application user",
                CurrentGamingGroupId = 1
            };
            registerViewModel = new RegisterViewModel()
            {
                ConfirmPassword = "******",
                Password = "******",
                UserName = "******",
                EmailAddress = "*****@*****.**"
            };
        }
Exemplo n.º 7
0
 public AccountController(
     ApplicationUserManager userManager,
     IUserRegisterer userRegisterer,
     IFirstTimeAuthenticator firstTimeAuthenticator,
     IAuthenticationManager authenticationManager,
     IGamingGroupInviteConsumer gamingGroupInvitationConsumer,
     IGamingGroupRetriever gamingGroupRetriever,
     IBoardGameGeekUserSaver boardGameGeekUserSaver,
     IBoardGameGeekApiClient boardGameGeekApiClient,
     IUserRetriever userRetriever)
 {
     this.userManager                   = userManager;
     this.userRegisterer                = userRegisterer;
     this.firstTimeAuthenticator        = firstTimeAuthenticator;
     this.authenticationManager         = authenticationManager;
     this.gamingGroupInvitationConsumer = gamingGroupInvitationConsumer;
     _gamingGroupRetriever              = gamingGroupRetriever;
     _boardGameGeekUserSaver            = boardGameGeekUserSaver;
     _boardGameGeekApiClient            = boardGameGeekApiClient;
     _userRetriever = userRetriever;
 }
Exemplo n.º 8
0
 public AccountController(
     ApplicationUserManager userManager,
     IUserRegisterer userRegisterer,
     IFirstTimeAuthenticator firstTimeAuthenticator,
     IAuthenticationManager authenticationManager,
     IGamingGroupInviteConsumer gamingGroupInvitationConsumer,
     IGamingGroupRetriever gamingGroupRetriever,
     IBoardGameGeekUserSaver boardGameGeekUserSaver,
     IBoardGameGeekApiClient boardGameGeekApiClient,
     IUserRetriever userRetriever)
 {
     this.userManager = userManager;
     this.userRegisterer = userRegisterer;
     this.firstTimeAuthenticator = firstTimeAuthenticator;
     this.authenticationManager = authenticationManager;
     this.gamingGroupInvitationConsumer = gamingGroupInvitationConsumer;
     _gamingGroupRetriever = gamingGroupRetriever;
     _boardGameGeekUserSaver = boardGameGeekUserSaver;
     _boardGameGeekApiClient = boardGameGeekApiClient;
     _userRetriever = userRetriever;
 }
Exemplo n.º 9
0
        public void SetUp()
        {
            firstTimeUserAuthenticatorMock = MockRepository.GenerateMock <IFirstTimeAuthenticator>();
            userStoreMock = MockRepository.GenerateMock <IUserStore <ApplicationUser> >();
            var dataProtector = MockRepository.GenerateMock <IDataProtector>();

            dataProtectionProviderMock = MockRepository.GenerateMock <IDataProtectionProvider>();
            dataProtectionProviderMock.Expect(mock => mock.Create(Arg <string> .Is.Anything)).Return(dataProtector);
            applicationUserManagerMock    = MockRepository.GenerateMock <ApplicationUserManager>(userStoreMock, dataProtectionProviderMock);
            authenticationManagerMock     = MockRepository.GenerateMock <IAuthenticationManager>();
            signInManagerMock             = MockRepository.GenerateMock <ApplicationSignInManager>(applicationUserManagerMock, authenticationManagerMock);
            dataContextMock               = MockRepository.GenerateMock <IDataContext>();
            eventTrackerMock              = MockRepository.GenerateMock <INemeStatsEventTracker>();
            gamingGroupInviteConsumerMock = MockRepository.GenerateMock <IGamingGroupInviteConsumer>();

            userRegisterer = new UserRegisterer(
                applicationUserManagerMock,
                firstTimeUserAuthenticatorMock,
                dataContextMock,
                signInManagerMock,
                eventTrackerMock,
                gamingGroupInviteConsumerMock);

            Guid                  invitationId = Guid.NewGuid();
            const int             PLAYER_ID    = 1938;
            GamingGroupInvitation invitation   = new GamingGroupInvitation
            {
                Id            = invitationId,
                PlayerId      = PLAYER_ID,
                GamingGroupId = 10
            };

            newUser = new NewUser()
            {
                UserName                = "******",
                EmailAddress            = "the email",
                GamingGroupInvitationId = invitationId,
                Source = TransactionSource.WebApplication
            };
            expectedNewlyRegisteredUser = new NewlyRegisteredUser
            {
                GamingGroupId   = invitation.GamingGroupId,
                GamingGroupName = "some awesome gaming group name",
                PlayerId        = PLAYER_ID,
                PlayerName      = "some awesome player name",
                UserId          = applicationUserIdAfterSaving
            };
            IdentityResult result = IdentityResult.Success;

            dataContextMock.Expect(mock => mock.FindById <GamingGroupInvitation>(invitationId))
            .Return(invitation);
            applicationUserManagerMock.Expect(mock => mock.CreateAsync(Arg <ApplicationUser> .Is.Anything, Arg <string> .Is.Anything))
            .Return(Task.FromResult(result))
            .WhenCalled(invocation => ((ApplicationUser)invocation.Arguments[0]).Id = applicationUserIdAfterSaving);

            signInManagerMock.Expect(mock => mock.SignInAsync(
                                         Arg <ApplicationUser> .Is.Anything,
                                         Arg <bool> .Is.Anything,
                                         Arg <bool> .Is.Anything))

            .Return(Task.FromResult(-1));
            gamingGroupInviteConsumerMock.Expect(mock => mock.AddNewUserToGamingGroup(Arg <string> .Is.Anything, Arg <Guid> .Is.Anything))
            .Return(expectedNewlyRegisteredUser);
            firstTimeUserAuthenticatorMock.Expect(mock => mock.CreateGamingGroupAndSendEmailConfirmation(
                                                      Arg <ApplicationUser> .Is.Anything,
                                                      Arg <TransactionSource> .Is.Anything))
            .Return(Task.FromResult(expectedNewlyRegisteredUser));
        }
Exemplo n.º 10
0
        public void SetUp()
        {
            firstTimeUserAuthenticatorMock = MockRepository.GenerateMock<IFirstTimeAuthenticator>();
            userStoreMock = MockRepository.GenerateMock<IUserStore<ApplicationUser>>();
            var dataProtector = MockRepository.GenerateMock<IDataProtector>();
            dataProtectionProviderMock = MockRepository.GenerateMock<IDataProtectionProvider>();
            dataProtectionProviderMock.Expect(mock => mock.Create(Arg<string>.Is.Anything)).Return(dataProtector);
            applicationUserManagerMock = MockRepository.GenerateMock<ApplicationUserManager>(userStoreMock, dataProtectionProviderMock);
            authenticationManagerMock = MockRepository.GenerateMock<IAuthenticationManager>();
            signInManagerMock = MockRepository.GenerateMock<ApplicationSignInManager>(applicationUserManagerMock, authenticationManagerMock);
            dataContextMock = MockRepository.GenerateMock<IDataContext>();
            eventTrackerMock = MockRepository.GenerateMock<INemeStatsEventTracker>();
            gamingGroupInviteConsumerMock = MockRepository.GenerateMock<IGamingGroupInviteConsumer>();

            userRegisterer = new UserRegisterer(
                applicationUserManagerMock, 
                firstTimeUserAuthenticatorMock, 
                dataContextMock, 
                signInManagerMock,
                eventTrackerMock,
                gamingGroupInviteConsumerMock);

            Guid invitationId = Guid.NewGuid();
            const int PLAYER_ID = 1938;
            GamingGroupInvitation invitation = new GamingGroupInvitation
            {
                Id = invitationId,
                PlayerId = PLAYER_ID,
                GamingGroupId = 10
            };
            newUser = new NewUser()
            {
                UserName = "******",
                EmailAddress = "the email",
                GamingGroupInvitationId = invitationId,
                Source = TransactionSource.WebApplication
            };
            expectedNewlyRegisteredUser = new NewlyRegisteredUser
            {
                GamingGroupId = invitation.GamingGroupId,
                GamingGroupName = "some awesome gaming group name",
                PlayerId = PLAYER_ID,
                PlayerName = "some awesome player name",
                UserId = applicationUserIdAfterSaving
            };
            IdentityResult result = IdentityResult.Success;

            dataContextMock.Expect(mock => mock.FindById<GamingGroupInvitation>(invitationId))
                           .Return(invitation);
            applicationUserManagerMock.Expect(mock => mock.CreateAsync(Arg<ApplicationUser>.Is.Anything, Arg<string>.Is.Anything))
                                      .Return(Task.FromResult(result))
                                      .WhenCalled(invocation => ((ApplicationUser)invocation.Arguments[0]).Id = applicationUserIdAfterSaving);
                                      
            signInManagerMock.Expect(mock => mock.SignInAsync(
                                                                          Arg<ApplicationUser>.Is.Anything,
                                                                          Arg<bool>.Is.Anything,
                                                                          Arg<bool>.Is.Anything))
                                         
                                         .Return(Task.FromResult(-1));
            gamingGroupInviteConsumerMock.Expect(mock => mock.AddNewUserToGamingGroup(Arg<string>.Is.Anything, Arg<Guid>.Is.Anything))
                                         .Return(expectedNewlyRegisteredUser);
            firstTimeUserAuthenticatorMock.Expect(mock => mock.CreateGamingGroupAndSendEmailConfirmation(
                Arg<ApplicationUser>.Is.Anything,
                Arg<TransactionSource>.Is.Anything))
                .Return(Task.FromResult(expectedNewlyRegisteredUser));
        }