public void ShouldBeAbleToAddGameStatistics() { var game = ObjectMother.CreateGame(); _gameRepository.Add(game); var gameStatistics = ObjectMother.CreateGameStatistics(game); _gameStatisticsRepository.Add(gameStatistics); Assert.AreNotEqual(0, gameStatistics.Id); }
public void ShouldBeAbleToAddPlayerGameStatistics() { var game = ObjectMother.CreateGame(); _gameRepository.Add(game); var player = ObjectMother.CreatePlayer(); _playerRepository.Add(player); var playerGameStatistics = ObjectMother.CreatePlayerGameStatistics(game, player); _playerGameStatisticsRepository.Add(playerGameStatistics); Assert.AreNotEqual(0, playerGameStatistics.Id); }
public void TestAddGames_ShouldAddGame() { var options = new DbContextOptionsBuilder <GameDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new GameDbContext(options); SeedData(context); var repository = new GameRepository(context); var game = new Game() { Id = 3, Title = "fdf", Price = 13m, Rating = 2, Description = "dsdqsfdfsfsdsd", Platform = "ds", Manufacturer = new Manufacturer() { Name = "ivfdan" }, ReleaseDate = DateTime.UtcNow.AddDays(12), Image = new byte[] { 1, 1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1 } }; repository.Add(game); var expectedResult = context.Games.Count(); Assert.Equal(expectedResult, repository.Count()); }
public void Should_be_able_to_add_player_rivalry_statistics() { var game = ObjectMother.CreateGame(); _gameRepository.Add(game); var player = ObjectMother.CreatePlayer(); var affectedPlayer = ObjectMother.CreatePlayer(); _playerRepository.Add(player); _playerRepository.Add(affectedPlayer); var hole = ObjectMother.CreateHole(Int32.MaxValue); _holeRepository.Add(hole); var shotType = ObjectMother.CreateShotType(); _shotTypeRepository.Add(shotType); var playerRivalryStatistics = ObjectMother.CreatePlayerRivalryStatistics(game, player, affectedPlayer, hole, shotType); _playerRivalryStatisticsRepository.Add(playerRivalryStatistics); Assert.AreNotEqual(0, playerRivalryStatistics.Id); }
public void Should_be_able_to_add_game() { var game = ObjectMother.CreateGame(); _repository.Add(game); Assert.AreNotEqual(0, game.Id); }
public void DoesNotAddDuplicateGame() { var game = new Game { Name = "Game 1" }; var gameRepository = new GameRepository(_fixture.Context); gameRepository.Add(game); gameRepository.Add(game); var result = gameRepository.GetAll(); Assert.Equal(1, result.Count()); Assert.Equal(game, result.First()); }
private async Task CreateGame(string gameName, List <Player> players) { var game = new Game(gameName, players); Logger.Debug($"Added game {game}"); GameRepository.Add(game); await UpdateGamesList(); }
[HttpPost()] //only two same name method can be created in one controller and one should be HTTPGET one HTTPPOST. public ActionResult Create(Game game) { if (!ModelState.IsValid) { return(View(game)); } repository.Add(game); repository.SaveChanges(); return(RedirectToAction("Index")); }
protected override void Create() { Console.Write("Enter the name of the boardgame you would like to add: "); var gameName = Console.ReadLine(); // call to add to the db var newGame = new Game(); newGame.Description = gameName; _gameRepo.Add(newGame); Console.WriteLine(gameName + " has been added to the library!"); Console.WriteLine(); }
public IActionResult Post(Game game) { var currentUserProfile = GetCurrentUserProfile(); if (currentUserProfile.UserTypeId != 1) { return(Unauthorized()); } _gameRepository.Add(game); return(Ok()); }
public IActionResult Create(Game newGame, IFormCollection collection) { try { _gameRepo.Add(newGame); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public IActionResult Privacy() { var game1 = new Game { Year = 2012, Title = "Mount and Blade", Platform = "PC", Genre = "Strategy" }; _gameRepo.Add(game1); return(View()); }
public ActionResult Create(GameViewModel gameVM) { if (ModelState.IsValid) { Game game = gameVM.ToModel(); game.playDatetime = DateTime.Now; repo.Add(game); repo.Save(); currentGames.Add(game.id); return(RedirectToAction("Game", new { game.id })); } return(View(gameVM)); }
private void btnAdd_Click(object sender, EventArgs e) { try { service.Add(txtAddGame.Text, txtAddDescreption.Text, decimal.Parse(txtaddPrice.Text), txtaddSystem.Text, DateTime.Parse(mskaddRelease.Text), (int)(cmbAddCategory.SelectedValue), (int)(cmbAddAuthor.SelectedValue), fileName); dataGridView1.DataSource = service.TakeList(); service.TextboxCmbBoxEraser(groupBox1); } catch (Exception) { MessageBox.Show("Please check values you entered!"); } }
public void AddGame() { var game = new Game { Name = "Game 1" }; var gameRepository = new GameRepository(_fixture.Context); var result = gameRepository.Add(game); Assert.NotNull(result); Assert.Equal(game, result); }
public async Task Add_BasicTest() { // Arrange var testGame = new GameModel() { GameId = _fixture.Create <int>(), GameName = _fixture.Create <string>(), PublisherName = _fixture.Create <string>() }; var testPublisher = new PublisherModel() { PublisherId = _fixture.Create <int>(), PublisherName = testGame.PublisherName }; var publisherDbSet = CreateDbSetMock(new List <PublisherModel>() { testPublisher }); _videoGameContextMock.Setup(x => x.Games.Add(It.IsAny <GameModel>())); _videoGameContextMock.Setup(x => x.SaveChangesAsync(It.IsAny <CancellationToken>())); _videoGameContextMock.Setup(x => x.Publishers).Returns(publisherDbSet.Object); // Act var gameResult = await _gameRepo.Add(testGame); // Assert _videoGameContextMock.Verify(x => x.Games.Add(It.IsAny <GameModel>()), Times.Once); _videoGameContextMock.Verify(x => x.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once); Assert.AreEqual(testGame.GameId, gameResult.GameId); Assert.AreEqual(testGame.GameName, gameResult.GameName); Assert.AreEqual(testPublisher.PublisherId, gameResult.PublisherId); // Should've automatically mapped Id based on name Assert.AreEqual(testPublisher.PublisherName, gameResult.PublisherName); }
private Game AddandGetTestGame() { var game = new Game { igdbID = 23434, Title = "Test Game", }; game.GameCategories.Add(new GameCategory { ID = 11, Description = "Real Time Strategy (RTS)" }); using (var gameRepo = new GameRepository(DataContextCreator.CreateTestContext())) { gameRepo.Add(game); gameRepo.SaveChanges(); } return(game); }
public void Add_WasDataAdded_ActualEqualsExpected() { var expectedGame = new Game { GameCategories = new List <GameCategory> { new GameCategory { ID = 12, Description = "Role-playing (RPG)" } }, igdbID = 243242, Title = "Best Test Game", }; Game actualGame; using (var gameRepo = new GameRepository(DataContextCreator.CreateTestContext())) { gameRepo.Add(expectedGame); gameRepo.SaveChanges(); actualGame = gameRepo.GetById(expectedGame.ID); } AssertGamesEqual(expectedGame, actualGame); }
public async Task <IActionResult> Create([Bind("Id,Title,Price,Rating,ReleaseDate,Platform,Description,Image,ManufacturerId")] Game game, int[] Genres, IFormFile Image) { var modelState = ModelState.IsValid; ViewBag.ModelState = modelState; if (ModelState.IsValid) { //Here we fill the connection table between games and genres. if (Genres != null) { foreach (var genreId in Genres) { var genre = _context.Genres.Find(genreId); var gameGenre = new GameGenreConnection() { Game = game, Genre = genre }; _context.GameGenreConnection.Add(gameGenre); } } //Here we add the image of the game. using (var stream = new MemoryStream()) { await Image.CopyToAsync(stream); game.Image = stream.ToArray(); } _gameRepository.Add(game); return(RedirectToAction(nameof(Index))); } ViewData["ManufacturerId"] = new SelectList(_context.Manufacturers, "Id", "Name", game.ManufacturerId); return(RedirectToAction("Create", "Games")); }
public void Should_be_able_to_add_score() { var game = ObjectMother.CreateGame(); _gameRepository.Add(game); var player = ObjectMother.CreatePlayer(); _playerRepository.Add(player); var shotType = ObjectMother.CreateShotType(); _shotTypeRepository.Add(shotType); var hole = ObjectMother.CreateHole(Int32.MaxValue); _holeRepository.Add(hole); var shot = ObjectMother.CreateShot(game, player, shotType, hole); _shotRepository.Add(shot); Assert.AreNotEqual(0, shot.Id); }
public bool Create(GameDTO entity) { return(repository.Add(ObjectMapper.Mapper.Map <Game>(entity))); }
public BingoMutation(UserRepository userRepository, GameRepository gameRepository, IChat chat) { //USERS----------------------------------------- Field <UserType>("createUser", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <UserInputType> > { Name = "input" }), resolve: context => { return(userRepository.Add(context.GetArgument <User>("input"))); }); Field <UserType>("updateUser", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }, new QueryArgument <NonNullGraphType <UserInputType> > { Name = "input" } ), resolve: context => { var id = context.GetArgument <long>("id"); var user = context.GetArgument <User>("input"); return(userRepository.Update(id, user)); }); Field <UserType>("deleteUser", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { return(userRepository.Remove(context.GetArgument <long>("id"))); }); //GAMES----------------------------------------- Field <GameType>("createGame", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <GameInputType> > { Name = "input" }), resolve: context => { return(gameRepository.Add(context.GetArgument <Game>("input"))); }); Field <GameType>("updateGame", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }, new QueryArgument <NonNullGraphType <GameInputType> > { Name = "input" } ), resolve: context => { var id = context.GetArgument <long>("id"); var game = context.GetArgument <Game>("input"); var updated = gameRepository.Update(id, game).Result; return(chat.AddGame(updated)); }); Field <GameType>("updateGameSync", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }, new QueryArgument <NonNullGraphType <GameInputType> > { Name = "input" } ), resolve: context => { var id = context.GetArgument <long>("id"); var game = context.GetArgument <Game>("input"); game.Id = id; return(gameRepository.UpdateSync(id, game)); }); Field <GameType>("deleteGame", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { return(gameRepository.Remove(context.GetArgument <long>("id"))); }); Field <GameType>("joinAGame", arguments: new QueryArguments(new QueryArgument <StringGraphType> { Name = "link" }), resolve: context => { var link = context.GetArgument <string>("link"); Game game = gameRepository.GameByLink(link); if (game != null) { game.PlayersNumber = game.PlayersNumber + 1; var updated = gameRepository.UpdateSync(game.Id, game); return(chat.AddGame(updated)); } return(null); }); Field <GameType>("quitTheGame", arguments: new QueryArguments(new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); Game game = gameRepository.Find(id); if (game != null) { if (game.PlayersNumber > 0) { game.PlayersNumber = game.PlayersNumber - 1; } var updated = gameRepository.UpdateSync(game.Id, game); return(chat.AddGame(updated)); } return(null); }); //MESSAGES----------------------------------------- Field <GameType>("addGame", arguments: new QueryArguments(new QueryArgument <GameInputType> { Name = "game" }), resolve: context => { return(chat.AddGame(context.GetArgument <Game>("game"))); }); }
public void Onpost() { _repository.Add(new GameItemModel()); }
public async Task <ActionResult <Game> > PostGame(Game game) { await _repository.Add(game); return(CreatedAtAction("GetGame", new { id = game.Id }, game)); }