public void AddAsync_Should_ThrowArgumentException_When_ElementWithThisIdExist()
        {
            var boardGame      = new BoardGame(Guid.NewGuid(), "test", 15);
            var existingEntity = new Persistence.Entities.BoardGame
            {
                Id = boardGame.Id
            };

            _testContext.BoardGames.Add(existingEntity);
            _testContext.SaveChanges();

            Func <Task> act = async() =>
            {
                await _sut.BoardGameRepository.AddAsync(boardGame, _cancellationToken);

                await _sut.SaveChangesAsync(_cancellationToken);
            };

            act.Should().Throw <ArgumentException>();
        }
Exemple #2
0
        public void AddAsync_Should_ThrowArgumentException_When_ElementWithThisIdExist()
        {
            var rental         = new Rental(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), 15);
            var existingEntity = new Persistence.Entities.Rental
            {
                Id = rental.Id
            };

            _testContext.Rentals.Add(existingEntity);
            _testContext.SaveChanges();

            Func <Task> act = async() =>
            {
                await _sut.RentalRepository.AddAsync(rental, _cancellationToken);

                await _sut.SaveChangesAsync(_cancellationToken);
            };

            act.Should().Throw <ArgumentException>();
        }
Exemple #3
0
        public void AddAsync_Should_ThrowArgumentException_When_ElementWithThisIdExist()
        {
            var client         = new Client(Guid.NewGuid(), "mat", "szym", "123456", "*****@*****.**");
            var existingEntity = new Persistence.Entities.Client
            {
                Id = client.Id
            };

            _testContext.Clients.Add(existingEntity);
            _testContext.SaveChanges();

            Func <Task> act = async() =>
            {
                await _sut.ClientRepository.AddAsync(client, _cancellationToken);

                await _sut.SaveChangesAsync(_cancellationToken);
            };

            act.Should().Throw <ArgumentException>();
        }