Example #1
0
 public PlayerSaver(IDataContext dataContext, INemeStatsEventTracker eventTracker, INemesisRecalculator nemesisRecalculator,
                    IPlayerInviter playerInviter, IChampionRecalculator championRecalculator)
 {
     _dataContext          = dataContext;
     _eventTracker         = eventTracker;
     _nemesisRecalculator  = nemesisRecalculator;
     _playerInviter        = playerInviter;
     _championRecalculator = championRecalculator;
 }
Example #2
0
 public GamingGroupSaver(
     IDataContext dataContext,
     INemeStatsEventTracker eventTracker,
     IPlayerSaver playerSaver)
 {
     this.dataContext = dataContext;
     this.eventTracker = eventTracker;
     this.playerSaver = playerSaver;
 }
Example #3
0
 public GamingGroupSaver(
     IDataContext dataContext,
     INemeStatsEventTracker eventTracker,
     IPlayerSaver playerSaver,
     IGamingGroupContextSwitcher gamingGroupContextSwitcher)
 {
     _dataContext  = dataContext;
     _eventTracker = eventTracker;
     _playerSaver  = playerSaver;
     _gamingGroupContextSwitcher = gamingGroupContextSwitcher;
 }
Example #4
0
 public PlayedGameCreator(
     IDataContext applicationDataContext,
     INemeStatsEventTracker playedGameTracker,
     INemesisRecalculator nemesisRecalculator,
     IChampionRecalculator championRecalculator, ISecuredEntityValidator <Player> securedEntityValidatorForPlayer, ISecuredEntityValidator <GameDefinition> securedEntityValidatorForGameDefinition)
 {
     this.dataContext                             = applicationDataContext;
     this.playedGameTracker                       = playedGameTracker;
     this.nemesisRecalculator                     = nemesisRecalculator;
     this.championRecalculator                    = championRecalculator;
     this.securedEntityValidatorForPlayer         = securedEntityValidatorForPlayer;
     this.securedEntityValidatorForGameDefinition = securedEntityValidatorForGameDefinition;
 }
Example #5
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;
 }
Example #6
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;
 }
 public PlayedGameEventHandler(
     IDataContext dataContext,
     INemeStatsEventTracker playedGameEventTracker,
     IAchievementProcessor achievementProcessor,
     IChampionRecalculator championRecalculator,
     INemesisRecalculator nemesisRecalculator,
     IGamingGroupChampionRecalculator gamingGroupChampionRecalculator,
     IRollbarClient rollbar) : base(dataContext)
 {
     _playedGameEventTracker          = playedGameEventTracker;
     _achievementProcessor            = achievementProcessor;
     _championRecalculator            = championRecalculator;
     _nemesisRecalculator             = nemesisRecalculator;
     _gamingGroupChampionRecalculator = gamingGroupChampionRecalculator;
     _rollbar = rollbar;
 }
Example #8
0
 public PlayedGameSaver(
     IDataContext applicationDataContext,
     INemeStatsEventTracker playedGameTracker,
     INemesisRecalculator nemesisRecalculator,
     IChampionRecalculator championRecalculator,
     ISecuredEntityValidator securedEntityValidator,
     IPointsCalculator pointsCalculator,
     IBusinessLogicEventBus eventBus, 
     ILinkedPlayedGameValidator linkedPlayedGameValidator, IApplicationLinker applicationLinker) : base(eventBus)
 {
     _dataContext = applicationDataContext;
     _playedGameTracker = playedGameTracker;
     _nemesisRecalculator = nemesisRecalculator;
     _championRecalculator = championRecalculator;
     _securedEntityValidator = securedEntityValidator;
     _pointsCalculator = pointsCalculator;
     _linkedPlayedGameValidator = linkedPlayedGameValidator;
     _applicationLinker = applicationLinker;
 }
Example #9
0
 public PlayerSaver(IDataContext dataContext, INemeStatsEventTracker eventTracker, INemesisRecalculator nemesisRecalculator)
 {
     _dataContext = dataContext;
     _eventTracker = eventTracker;
     _nemesisRecalculator = nemesisRecalculator;
 }
Example #10
0
 public GameDefinitionSaver(IDataContext dataContext, INemeStatsEventTracker eventTracker, IBoardGameGeekGameDefinitionCreator boardGameGeekGameDefinitionAttacher)
 {
     _dataContext  = dataContext;
     _eventTracker = eventTracker;
     _boardGameGeekGameDefinitionCreator = boardGameGeekGameDefinitionAttacher;
 }
Example #11
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));
        }
 public GameDefinitionSaver(IDataContext dataContext, INemeStatsEventTracker eventTracker, IBoardGameGeekGameDefinitionCreator boardGameGeekGameDefinitionAttacher)
 {
     this.dataContext = dataContext;
     this.eventTracker = eventTracker;
     boardGameGeekGameDefinitionCreator = boardGameGeekGameDefinitionAttacher;
 }
        public virtual void FixtureSetUp()
        {
            //create a stub for this only since we don't want the slowdown of all of the universal analytics event tracking
            eventTrackerStub = MockRepository.GenerateStub<IEventTracker>();
            eventTrackerStub.Expect(stub => stub.TrackEvent(Arg<IUniversalAnalyticsEvent>.Is.Anything))
                .Repeat.Any();
             
            playedGameTracker = new UniversalAnalyticsNemeStatsEventTracker(eventTrackerStub, eventFactory);

            using (NemeStatsDbContext nemeStatsDbContext = new NemeStatsDbContext())
            {
                CleanUpTestData();

                testUserWithDefaultGamingGroup = SaveApplicationUser(
                    nemeStatsDbContext,
                    testApplicationUserNameForUserWithDefaultGamingGroup,
                    "*****@*****.**");
                testUserWithDefaultGamingGroupAndNoInvites = SaveApplicationUser(
                    nemeStatsDbContext,
                    testApplicationUserNameForUserWithDefaultGamingGroupAndNoInvites,
                    "*****@*****.**");
                testUserWithOtherGamingGroup = SaveApplicationUser(
                    nemeStatsDbContext,
                    testApplicationUserNameForUserWithOtherGamingGroup,
                    "*****@*****.**");
                testUserWithThirdGamingGroup = SaveApplicationUser(
                    nemeStatsDbContext,
                    testApplicationUserNameForUserWithThirdGamingGroup, 
                    "*****@*****.**");

                using (NemeStatsDataContext dataContext = new NemeStatsDataContext())
                {
                    testGamingGroup = SaveGamingGroup(dataContext, testGamingGroup1Name, testUserWithDefaultGamingGroup);
                    testUserWithDefaultGamingGroup = UpdateDatefaultGamingGroupOnUser(testUserWithDefaultGamingGroup, testGamingGroup, dataContext);
                    testOtherGamingGroup = SaveGamingGroup(dataContext, testGamingGroup2Name, testUserWithOtherGamingGroup);
                    testUserWithOtherGamingGroup = UpdateDatefaultGamingGroupOnUser(testUserWithOtherGamingGroup, testOtherGamingGroup, dataContext);
                    testThirdGamingGroup = SaveGamingGroup(dataContext, testGamingGroup3Name, testUserWithThirdGamingGroup);
                    testUserWithThirdGamingGroup = UpdateDatefaultGamingGroupOnUser(testUserWithThirdGamingGroup,
                        testThirdGamingGroup, dataContext);

                    testBoardGameGeekGameDefinition = SaveBoardGameGeekGameDefinition(dataContext);

                    testGameDefinition = SaveGameDefinition(nemeStatsDbContext, testGamingGroup.Id, testGameName, testBoardGameGeekGameDefinition.Id);
                    testGameDefinition2 = SaveGameDefinition(nemeStatsDbContext, testGamingGroup.Id, testGameName2);
                    testGameDefinitionWithOtherGamingGroupId = SaveGameDefinition(nemeStatsDbContext, testOtherGamingGroup.Id, testGameNameForGameWithOtherGamingGroupId);
                    gameDefinitionWithNoChampion = SaveGameDefinition(nemeStatsDbContext, testThirdGamingGroup.Id,
                        gameDefinitionWithNoChampionName);
                    anotherTestGameDefinitionWithOtherGamingGroupId = SaveGameDefinition(nemeStatsDbContext,
                        testOtherGamingGroup.Id, testGameNameForAnotherGameWithOtherGamingGroupId);
                    SavePlayers(nemeStatsDbContext, testGamingGroup.Id, testOtherGamingGroup.Id);
                }

                using(NemeStatsDataContext dataContext = new NemeStatsDataContext())
                {
                    CreatePlayedGames(dataContext);
                }
            }
        }