Esempio n. 1
0
        public void Setup()
        {
            GamingInfo _gi = new GamingInfo()
            {
                GameId       = 1, GameTitle = "Halo", GameDescription = "Good Game", ReleaseDate = DateTime.Today,
                GamePlatform = 1, GameCategory = 1, GamePrice = 10
            };

            _dbContext.GamingInfo.Add(_gi);
            _dbContext.SaveChanges();

            BusinessGames _bg = new BusinessGames()
            {
                BusinessId = 1, GameId = 1
            };

            _dbContext.BusinessGames.Add(_bg);
            _dbContext.SaveChanges();

            GamingPlatform _pl = new GamingPlatform()
            {
                PlatformId = 1, PlatformName = "SNES"
            };

            _dbContext.GamingPlatform.Add(_pl);
            _dbContext.SaveChanges();

            GamingCategory _ca = new GamingCategory()
            {
                CategoryId = 1, CategoryName = "Puzzle"
            };

            _dbContext.GamingCategory.Add(_ca);
            _dbContext.SaveChanges();
        }
Esempio n. 2
0
        public async Task <IActionResult> PostBusinessGame([FromBody] BusinessGames businessGamingInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            businessGamingInfo.BusinessId = UserTempStorage.id;
            //hello
            _context.BusinessGames.Add(businessGamingInfo);
            await _context.SaveChangesAsync();



            //return CreatedAtAction("GetBusinessGames", new { id = businessGamingInfo.GameId }, businessGamingInfo);
            return(CreatedAtAction("GetBusinessGames", new { id = businessGamingInfo.GameId }, businessGamingInfo));
        }
Esempio n. 3
0
        public async Task Check_PostBusinessGame_GetID()
        {
            // Arrange
            var controller = new GameController(_dbContext);

            UserTempStorage.id = 1;


            BusinessGames businessGamingInfo = new BusinessGames();

            businessGamingInfo.GameId = 2;

            // Act
            IActionResult addBusinessGame = await controller.PostBusinessGame(businessGamingInfo);

            CreatedAtActionResult results = addBusinessGame as CreatedAtActionResult;

            string var = results.RouteValues["id"].ToString();

            //string var = results.RouteValues["id"].ToString();
            // Assert
            Assert.AreEqual(var, "2");
        }