public virtual ActionResult Details(int id, ApplicationUser currentUser) { GamingGroupSummary gamingGroupSummary = GetGamingGroupSummary(id); var viewModel = new GamingGroupPublicViewModel { Id = gamingGroupSummary.Id, Name = gamingGroupSummary.Name, GameDefinitionSummaries = gamingGroupSummary.GameDefinitionSummaries .Select(summary => gameDefinitionSummaryViewModelBuilder.Build(summary, currentUser)) .OrderByDescending(summary => summary.TotalNumberOfGamesPlayed) .ToList(), Players = gamingGroupSummary.Players .Select(playerWithNemesis => playerWithNemesisViewModelBuilder.Build(playerWithNemesis, currentUser)).ToList(), PlayedGames = new PlayedGamesViewModel { PlayedGameDetailsViewModels = gamingGroupSummary.PlayedGames .Select(playedGame => playedGameDetailsViewModelBuilder.Build(playedGame, currentUser)).ToList(), PanelTitle = string.Format("Last {0} Played Games", gamingGroupSummary.PlayedGames.Count), UserCanEdit = currentUser.CurrentGamingGroupId == gamingGroupSummary.Id, ShowSearchLinkInResultsHeader = false }, PublicDetailsView = new GamingGroupPublicDetailsViewModel { GamingGroupId = gamingGroupSummary.Id, PublicDescription = gamingGroupSummary.PublicDescription, Website = gamingGroupSummary.PublicGamingGroupWebsite } }; return(View(MVC.GamingGroup.Views.Details, viewModel)); }
public void ItReturnsTheGamingGroupSummary() { GamingGroupSummary actualGamingGroup = AutoMocker.ClassUnderTest.GetGamingGroupDetails(_filter); Assert.AreEqual(_expectedGamingGroup.Id, actualGamingGroup.Id); Assert.AreEqual(_expectedGamingGroup.Name, actualGamingGroup.Name); Assert.AreEqual(_expectedGamingGroup.DateCreated, actualGamingGroup.DateCreated); }
internal virtual GamingGroupSummary GetGamingGroupSummary(int gamingGroupId) { GamingGroupSummary gamingGroupSummary = this.gamingGroupRetriever.GetGamingGroupDetails( gamingGroupId, MAX_NUMBER_OF_RECENT_GAMES); return(gamingGroupSummary); }
public void ItReturnsTheGamingGroupSummary() { GamingGroupSummary actualGamingGroup = gamingGroupRetriever.GetGamingGroupDetails(gamingGroupId, 0); Assert.AreEqual(expectedGamingGroup.Id, actualGamingGroup.Id); Assert.AreEqual(expectedGamingGroup.Name, actualGamingGroup.Name); Assert.AreEqual(expectedGamingGroup.OwningUserId, actualGamingGroup.OwningUserId); Assert.AreEqual(expectedGamingGroup.DateCreated, actualGamingGroup.DateCreated); }
public void ItReturnsAllActivePlayersInTheGamingGroup() { List <PlayerWithNemesis> expectedPlayers = new List <PlayerWithNemesis>(); AutoMocker.Get <IPlayerRetriever>().Expect(mock => mock.GetAllPlayersWithNemesisInfo(gamingGroupId, filter.DateRangeFilter)) .Return(expectedPlayers); GamingGroupSummary actualGamingGroup = AutoMocker.ClassUnderTest.GetGamingGroupDetails(filter); Assert.AreSame(expectedPlayers, actualGamingGroup.Players); }
public void ItReturnsAllActivePlayersInTheGamingGroup() { List <PlayerWithNemesis> expectedPlayers = new List <PlayerWithNemesis>(); playerRetrieverMock.Expect(mock => mock.GetAllPlayersWithNemesisInfo(gamingGroupId)) .Return(expectedPlayers); GamingGroupSummary actualGamingGroup = gamingGroupRetriever.GetGamingGroupDetails(gamingGroupId, 0); Assert.AreSame(expectedPlayers, actualGamingGroup.Players); }
private List <PlayedGameDetailsViewModel> BuildPlayedGameDetailsViewModels(GamingGroupSummary gamingGroupSummary, ApplicationUser currentUser) { int totalGames = gamingGroupSummary.PlayedGames.Count; List <PlayedGameDetailsViewModel> details = new List <PlayedGameDetailsViewModel>(totalGames); for (int i = 0; i < totalGames; i++) { details.Add(playedGameDetailsViewModelBuilder.Build(gamingGroupSummary.PlayedGames[i], currentUser)); } return(details); }
public void ItReturnsTheSpecifiedNumberOfPlayedGamesForTheGamingGroup() { List <PlayedGame> playedGames = new List <PlayedGame>(); AutoMocker.Get <IPlayedGameRetriever>().Expect(mock => mock.GetRecentGames(filter.NumberOfRecentGamesToShow, filter.GamingGroupId, filter.DateRangeFilter)) .Return(playedGames); GamingGroupSummary actualGamingGroup = AutoMocker.ClassUnderTest.GetGamingGroupDetails(filter); Assert.AreSame(playedGames, actualGamingGroup.PlayedGames); }
public void ItReturnsTheSpecifiedNumberOfPlayedGamesForTheGamingGroup() { int numberOfGames = 135; List <PlayedGame> playedGames = new List <PlayedGame>(); playedGameRetriever.Expect(mock => mock.GetRecentGames(numberOfGames, gamingGroupId)) .Return(playedGames); GamingGroupSummary actualGamingGroup = gamingGroupRetriever.GetGamingGroupDetails(gamingGroupId, numberOfGames); Assert.AreSame(playedGames, actualGamingGroup.PlayedGames); }
public GamingGroupSummary GetGamingGroupDetails(GamingGroupFilter filter) { var gamingGroup = _dataContext.FindById <GamingGroup>(filter.GamingGroupId); var summary = new GamingGroupSummary { Id = gamingGroup.Id, DateCreated = gamingGroup.DateCreated, Name = gamingGroup.Name, PublicDescription = gamingGroup.PublicDescription, PublicGamingGroupWebsite = gamingGroup.PublicGamingGroupWebsite }; return(summary); }
public override void SetUp() { base.SetUp(); gamingGroupSummary = new GamingGroupSummary() { PlayedGames = new List <PlayedGame>() }; gamingGroupViewModel = new GamingGroupViewModel(); autoMocker.Get <IGamingGroupRetriever>().Expect(mock => mock.GetGamingGroupDetails( currentUser.CurrentGamingGroupId, GamingGroupController.MAX_NUMBER_OF_RECENT_GAMES)) .Repeat.Once() .Return(gamingGroupSummary); autoMocker.Get <IGamingGroupViewModelBuilder>().Expect(mock => mock.Build(gamingGroupSummary, currentUser)) .Return(gamingGroupViewModel); }
public override void SetUp() { base.SetUp(); _gamingGroupSummary = new GamingGroupSummary { Id = 1, Name = "some gaming group name", DateCreated = DateTime.MaxValue, PublicDescription = "some public description", PublicGamingGroupWebsite = "https://website.com" }; _dateRangeFilter = new BasicDateRangeFilter(); autoMocker.ClassUnderTest.Expect(mock => mock.GetGamingGroupSummary( Arg <int> .Is.Anything, Arg <IDateRangeFilter> .Is.Anything)) .Repeat.Once() .Return(_gamingGroupSummary); }
public override void SetUp() { base.SetUp(); gamingGroupSummary = new GamingGroupSummary() { PlayedGames = new List <PlayedGame>() }; _gamingGroupViewModel = new GamingGroupViewModel(); dateRangeFilter = new BasicDateRangeFilter(); autoMocker.ClassUnderTest.Expect(mock => mock.GetGamingGroupSummary( Arg <int> .Is.Anything, Arg <IDateRangeFilter> .Is.Anything)) .Repeat.Once() .Return(gamingGroupSummary); autoMocker.Get <IGamingGroupViewModelBuilder>().Expect(mock => mock.Build(gamingGroupSummary, currentUser)) .Return(_gamingGroupViewModel); }
public GamingGroupSummary GetGamingGroupDetails(GamingGroupFilter filter) { var gamingGroup = dataContext.FindById <GamingGroup>(filter.GamingGroupId); var summary = new GamingGroupSummary { Id = gamingGroup.Id, DateCreated = gamingGroup.DateCreated, Name = gamingGroup.Name, OwningUserId = gamingGroup.OwningUserId, PublicDescription = gamingGroup.PublicDescription, PublicGamingGroupWebsite = gamingGroup.PublicGamingGroupWebsite }; summary.PlayedGames = playedGameRetriever.GetRecentGames(filter.NumberOfRecentGamesToShow, filter.GamingGroupId, filter.DateRangeFilter); summary.Players = playerRetriever.GetAllPlayersWithNemesisInfo(filter.GamingGroupId, filter.DateRangeFilter); summary.GameDefinitionSummaries = gameDefinitionRetriever.GetAllGameDefinitions(filter.GamingGroupId, filter.DateRangeFilter); summary.OwningUser = dataContext.GetQueryable <ApplicationUser>().First(user => user.Id == gamingGroup.OwningUserId); return(summary); }
public GamingGroupSummary GetGamingGroupDetails(int gamingGroupId, int maxNumberOfGamesToRetrieve) { GamingGroup gamingGroup = dataContext.FindById <GamingGroup>(gamingGroupId); GamingGroupSummary summary = new GamingGroupSummary { Id = gamingGroup.Id, DateCreated = gamingGroup.DateCreated, Name = gamingGroup.Name, OwningUserId = gamingGroup.OwningUserId, PublicDescription = gamingGroup.PublicDescription, PublicGamingGroupWebsite = gamingGroup.PublicGamingGroupWebsite }; summary.PlayedGames = playedGameRetriever.GetRecentGames(maxNumberOfGamesToRetrieve, gamingGroupId); summary.Players = playerRetriever.GetAllPlayersWithNemesisInfo(gamingGroupId); summary.GameDefinitionSummaries = gameDefinitionRetriever.GetAllGameDefinitions(gamingGroupId); summary.OwningUser = dataContext.GetQueryable <ApplicationUser>().First(user => user.Id == gamingGroup.OwningUserId); return(summary); }
public GamingGroupViewModel Build(GamingGroupSummary gamingGroupSummary, ApplicationUser currentUser = null) { List <PlayedGameDetailsViewModel> details = BuildPlayedGameDetailsViewModels(gamingGroupSummary, currentUser); List <PlayerWithNemesisViewModel> playerWithNemesisList = (from PlayerWithNemesis playerWithNemesis in gamingGroupSummary.Players select playerWithNemesisViewModelBuilder.Build(playerWithNemesis, currentUser)).ToList(); var viewModel = new GamingGroupViewModel() { Id = gamingGroupSummary.Id, OwningUserId = gamingGroupSummary.OwningUserId, Name = gamingGroupSummary.Name, OwningUserName = gamingGroupSummary.OwningUser.UserName, Players = playerWithNemesisList, GameDefinitionSummaries = gamingGroupSummary.GameDefinitionSummaries .Select(game => gameDefinitionSummaryViewModelBuilder.Build(game, currentUser)) .OrderByDescending(game => game.TotalNumberOfGamesPlayed) .ToList(), PlayedGames = new PlayedGamesViewModel { PlayedGameDetailsViewModels = details, PanelTitle = string.Format("Last {0} Played Games", details.Count), UserCanEdit = currentUser != null && currentUser.CurrentGamingGroupId == gamingGroupSummary.Id, GamingGroupId = gamingGroupSummary.Id }, PublicDetailsView = new GamingGroupPublicDetailsViewModel { GamingGroupId = gamingGroupSummary.Id, PublicDescription = gamingGroupSummary.PublicDescription, Website = gamingGroupSummary.PublicGamingGroupWebsite } }; return(viewModel); }
public void ItReturnsAllGameDefinitionsForTheGamingGroup() { GamingGroupSummary actualGamingGroup = gamingGroupRetriever.GetGamingGroupDetails(gamingGroupId, 0); Assert.AreSame(gameDefinitionSummaries, actualGamingGroup.GameDefinitionSummaries); }
public void ItReturnsAllGameDefinitionsForTheGamingGroup() { GamingGroupSummary actualGamingGroup = AutoMocker.ClassUnderTest.GetGamingGroupDetails(filter); Assert.AreSame(gameDefinitionSummaries, actualGamingGroup.GameDefinitionSummaries); }
public void ItReturnsTheOwningUserOnTheGameDefinition() { GamingGroupSummary actualGamingGroup = AutoMocker.ClassUnderTest.GetGamingGroupDetails(filter); Assert.NotNull(actualGamingGroup.OwningUser); }
public void SetUp() { playerWithNemesisViewModelBuilderMock = MockRepository.GenerateMock <IPlayerWithNemesisViewModelBuilder>(); playedGameDetailsViewModelBuilderMock = MockRepository.GenerateMock <IPlayedGameDetailsViewModelBuilder>(); gameDefinitionSummaryViewModelBuilderMock = MockRepository.GenerateMock <IGameDefinitionSummaryViewModelBuilder>(); transformer = new GamingGroupViewModelBuilder( playedGameDetailsViewModelBuilderMock, playerWithNemesisViewModelBuilderMock, gameDefinitionSummaryViewModelBuilderMock); players = new List <PlayerWithNemesis>() { new PlayerWithNemesis() { PlayerId = 1 }, new PlayerWithNemesis() { PlayerId = 2 } }; gameDefinitionSummaries = new List <GameDefinitionSummary> { new GameDefinitionSummary { Id = 1 }, new GameDefinitionSummary { Id = 2 } }; playedGames = new List <PlayedGame>(); ApplicationUser owningUser = new ApplicationUser() { Id = "owning user user Id", Email = "*****@*****.**", UserName = "******" }; ApplicationUser registeredUser = new ApplicationUser() { Email = "*****@*****.**", Id = "registered user id", UserName = "******" }; GamingGroupInvitation invitation = new GamingGroupInvitation() { DateRegistered = DateTime.UtcNow, RegisteredUserId = "registered user id", RegisteredUser = registeredUser }; gamingGroupSummary = new GamingGroupSummary() { Id = 1, Name = "gaming group", OwningUserId = owningUser.Id, OwningUser = owningUser, GamingGroupInvitations = new List <GamingGroupInvitation>() { invitation }, Players = players, GameDefinitionSummaries = gameDefinitionSummaries, PlayedGames = playedGames }; playedGameDetailsViewModelBuilderMock.Expect(mock => mock.Build( Arg <PlayedGame> .Is.Anything, Arg <ApplicationUser> .Is.Anything)) .Return(new PlayedGameDetailsViewModel()); currentUser = new ApplicationUser(); foreach (PlayerWithNemesis playerWithNemesis in players) { playerWithNemesisViewModelBuilderMock.Expect(mock => mock.Build(playerWithNemesis, this.currentUser)) .Return(new PlayerWithNemesisViewModel() { PlayerId = playerWithNemesis.PlayerId }); } foreach (GameDefinitionSummary summary in gameDefinitionSummaries) { gameDefinitionSummaryViewModelBuilderMock.Expect(mock => mock.Build(summary, currentUser)) .Return(new GameDefinitionSummaryViewModel { Id = summary.Id }); } viewModel = transformer.Build(gamingGroupSummary, currentUser); }
public void ItReturnsTheOwningUserOnTheGameDefinition() { GamingGroupSummary actualGamingGroup = gamingGroupRetriever.GetGamingGroupDetails(gamingGroupId, 0); Assert.NotNull(actualGamingGroup.OwningUser); }