public override void SetUp() { base.SetUp(); expectedGamingGroup = new GamingGroup() { Id = currentUser.CurrentGamingGroupId }; autoMocker.Get <IDataContext>().Expect(mock => mock.Save(Arg <GamingGroup> .Is.Anything, Arg <ApplicationUser> .Is.Anything)) .Return(expectedGamingGroup); expectedPlayer = new Player(); autoMocker.Get <IPlayerSaver>().Expect(mock => mock.Save(Arg <Player> .Is.Anything, Arg <ApplicationUser> .Is.Anything)).Return(expectedPlayer); expectedUserGamingGroup = new UserGamingGroup { ApplicationUserId = currentUser.Id, GamingGroupId = expectedGamingGroup.Id }; autoMocker.Get <IDataContext>().Expect(mock => mock.Save <UserGamingGroup>(Arg <UserGamingGroup> .Is.Anything, Arg <ApplicationUser> .Is.Anything)) .Return(expectedUserGamingGroup); appUserRetrievedFromFindMethod = new ApplicationUser() { Id = currentUser.Id }; autoMocker.Get <IDataContext>().Expect(mock => mock.FindById <ApplicationUser>(Arg <ApplicationUser> .Is.Anything)) .Return(appUserRetrievedFromFindMethod); autoMocker.Get <IDataContext>().Expect(mock => mock.Save(Arg <ApplicationUser> .Is.Anything, Arg <ApplicationUser> .Is.Anything)) .Return(new ApplicationUser()); }
public override void SetUp() { base.SetUp(); expectedGamingGroup = new GamingGroup() { Id = currentUser.CurrentGamingGroupId }; autoMocker.Get<IDataContext>().Expect(mock => mock.Save(Arg<GamingGroup>.Is.Anything, Arg<ApplicationUser>.Is.Anything)) .Return(expectedGamingGroup); expectedPlayer = new Player(); autoMocker.Get<IPlayerSaver>().Expect(mock => mock.CreatePlayer( Arg<CreatePlayerRequest>.Is.Anything, Arg<ApplicationUser>.Is.Anything, Arg<bool>.Is.Anything)).Return(expectedPlayer); expectedUserGamingGroup = new UserGamingGroup { ApplicationUserId = currentUser.Id, GamingGroupId = expectedGamingGroup.Id }; autoMocker.Get<IDataContext>().Expect(mock => mock.Save<UserGamingGroup>(Arg<UserGamingGroup>.Is.Anything, Arg<ApplicationUser>.Is.Anything)) .Return(expectedUserGamingGroup); appUserRetrievedFromFindMethod = new ApplicationUser() { Id = currentUser.Id }; autoMocker.Get<IDataContext>().Expect(mock => mock.FindById<ApplicationUser>(Arg<ApplicationUser>.Is.Anything)) .Return(appUserRetrievedFromFindMethod); autoMocker.Get<IDataContext>().Expect(mock => mock.Save(Arg<ApplicationUser>.Is.Anything, Arg<ApplicationUser>.Is.Anything)) .Return(new ApplicationUser()); }
private void AddUserGamingGroupRecord(ApplicationUser currentUser, GamingGroup newGamingGroup) { UserGamingGroup userGamingGroup = new UserGamingGroup { ApplicationUserId = currentUser.Id, GamingGroupId = newGamingGroup.Id }; this.dataContext.Save(userGamingGroup, currentUser); }
private void AssociateUserWithNewGamingGroup(int gamingGroupId, ApplicationUser userFromDatabase) { UserGamingGroup userGamingGroup = new UserGamingGroup { ApplicationUserId = userFromDatabase.Id, GamingGroupId = gamingGroupId }; this.dataContext.Save(userGamingGroup, userFromDatabase); userFromDatabase.CurrentGamingGroupId = gamingGroupId; this.dataContext.Save(userFromDatabase, userFromDatabase); }
private void AddNewGamingGroupAssociation(GamingGroupInvitation invitation) { UserGamingGroup userGamingGroup = dataContext.GetQueryable <UserGamingGroup>() .FirstOrDefault( ugg => ugg.ApplicationUserId == invitation.RegisteredUserId && ugg.GamingGroupId == invitation.GamingGroupId); if (userGamingGroup == null) { var newGamingGroupAssociation = new UserGamingGroup { ApplicationUserId = invitation.RegisteredUserId, GamingGroupId = invitation.GamingGroupId }; //ApplicationUser is not used when saving new entities -- just has to be not-null this.dataContext.Save(newGamingGroupAssociation, new ApplicationUser()); } }
private void AddNewGamingGroupAssociation(GamingGroupInvitation invitation) { var userGamingGroup = dataContext.GetQueryable<UserGamingGroup>() .FirstOrDefault( ugg => ugg.ApplicationUserId == invitation.RegisteredUserId && ugg.GamingGroupId == invitation.GamingGroupId); if (userGamingGroup == null) { var newGamingGroupAssociation = new UserGamingGroup { ApplicationUserId = invitation.RegisteredUserId, GamingGroupId = invitation.GamingGroupId }; //ApplicationUser is not used when saving new entities -- just has to be not-null dataContext.Save(newGamingGroupAssociation, new ApplicationUser()); } }
private void AssociateUserWithNewGamingGroup(int gamingGroupId, ApplicationUser userFromDatabase) { var userGamingGroup = new UserGamingGroup { ApplicationUserId = userFromDatabase.Id, GamingGroupId = gamingGroupId }; dataContext.Save(userGamingGroup, userFromDatabase); userFromDatabase.CurrentGamingGroupId = gamingGroupId; dataContext.Save(userFromDatabase, userFromDatabase); }
private void AddUserGamingGroupRecord(ApplicationUser currentUser, GamingGroup newGamingGroup) { var userGamingGroup = new UserGamingGroup { ApplicationUserId = currentUser.Id, GamingGroupId = newGamingGroup.Id }; this.dataContext.Save(userGamingGroup, currentUser); }
public void LocalSetUp() { _autoMocker = new RhinoAutoMocker <PlayerRetriever>(); _currentUser = new ApplicationUser { Id = "some user id", }; var currentUserGamingGroup1 = new UserGamingGroup { GamingGroupId = _currentUserGamingGroupId1, ApplicationUserId = _currentUser.Id }; var currentUserGamingGroup2 = new UserGamingGroup { GamingGroupId = _currentUserGamingGroupId2, ApplicationUserId = _currentUser.Id }; var validPlayer1 = new Player { Id = _playerIdInFirstGamingGroupWithRegisteredUser, GamingGroupId = _currentUserGamingGroupId1, ApplicationUserId = "some non-null value", User = new ApplicationUser { Email = _expectedPlayer1Email } }; var validPlayer2 = new Player { Id = _playerIdInSecondGamingGroupWithRegisteredUser, GamingGroupId = _currentUserGamingGroupId2, ApplicationUserId = "some non-null value", User = new ApplicationUser { Email = _expectedPlayer2Email } }; var playerInGamingGroupButWithoutARegisteredUser = new Player { Id = _playerIdInSecondGamingGroupWithOutRegisteredUser, GamingGroupId = _currentUserGamingGroupId2 }; var playerNotInGamingGroup = new Player { Id = _playerIdNotInGamingGroup, GamingGroupId = -1, User = new ApplicationUser { Email = "*****@*****.**" } }; var expectedUserGamingGroups = new List <UserGamingGroup> { currentUserGamingGroup1, currentUserGamingGroup2 }.AsQueryable(); _autoMocker.Get <IDataContext>() .Expect(mock => mock.GetQueryable <UserGamingGroup>()) .Return(expectedUserGamingGroups); var expectedPlayers = new List <Player> { validPlayer1, validPlayer2, playerInGamingGroupButWithoutARegisteredUser, playerNotInGamingGroup }.AsQueryable(); _autoMocker.Get <IDataContext>() .Expect(mock => mock.GetQueryable <Player>()) .Return(expectedPlayers); _allPotentialPlayerIds = expectedPlayers.Select(x => x.Id).ToList(); }