Ejemplo n.º 1
0
        public bool Delete(int id)
        {
            var db_val = _db_Context.Goods.FirstOrDefault(x => x.Id == id);

            if (db_val != null)
            {
                _db_Context.Goods.Remove(db_val);
                _db_Context.ChangeTracker.DetectChanges();
                _db_Context.SaveChanges();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public void CreateGame()
        {
            var newGame   = _gameGenerator.Get();
            int gameCount = _gameRepository.Get().Count;

            var createdGame = _gameRepository.Create(newGame);

            createdGame.Should()
            .NotBeNull("a game should be created").And
            .BeAssignableTo <Game>("it should inherit the Game class").And
            .BeEquivalentTo(newGame, "it should contain the same properties as the game we sent to the repository");

            _context.SaveChanges();

            _gameRepository.Get().Count.Should().BeGreaterThan(gameCount, "the transaction was commited");
        }
Ejemplo n.º 3
0
        public void Create()
        {
            var newReview = _reviewGenerator.Get();
            var game      = _context.Games.FirstOrDefault();

            newReview.Subject   = game;
            newReview.SubjectId = game.Id;
            var reviewCount = _reviewRepository.Get().Count;

            var createdReview = _reviewRepository.Create(newReview);

            createdReview.Should()
            .NotBeNull("a new review is expected").And
            .BeAssignableTo <Review>("it should be a Review object").And
            .BeEquivalentTo(newReview, "it should have the same properties as the one we sent");

            _context.SaveChanges();

            _reviewRepository.Get().Count.Should().BeGreaterThan(reviewCount, "a new review shouldve been added to the collection");
        }
Ejemplo n.º 4
0
 public void DeleteAll()
 {
     db_context.Goods.RemoveRange(db_context.Goods);
     db_context.Colors.RemoveRange(db_context.Colors);
     db_context.SaveChanges();
 }