Example #1
0
        public Bestelling Insert(Bestelling entity)
        {
            if (entity.Klantnummer == 0)
            {
                throw new ArgumentNullException();
            }

            _context.Bestellingen.Add(entity);
            _context.SaveChanges();
            return(entity);
        }
        public void GetAll_ShouldReturnAllArtikelen()
        {
            // Arrange
            Bestelling bestelling1 = new BestellingBuilder().SetDummy().Create();
            Bestelling bestelling2 = new BestellingBuilder().SetDummy().Create();

            _context.Bestellingen.Add(bestelling1);
            _context.Bestellingen.Add(bestelling2);
            _context.SaveChanges();

            var dataMapper = new BestellingDataMapper(_context);

            // Act
            List <Bestelling> result = dataMapper.GetAll().ToList();

            // Assert
            Assert.AreEqual(2, result.Count);
            Assert.IsTrue(bestelling1.IsEqual(result[0]));
            Assert.IsTrue(bestelling2.IsEqual(result[1]));
        }
Example #3
0
        private void SeedDatabase()
        {
            _context.Artikelen.AddRange(new List <Artikel>
            {
                new Artikel
                {
                    Artikelnummer   = 1,
                    Leveranciercode = "abc-123-xyz",
                    Naam            = "Fietsband",
                    Prijs           = 12.95m,
                    LeverbaarTot    = new DateTime(2018, 10, 11)
                }
            });

            _context.SaveChanges();
        }
        private void SeedDatabase()
        {
            _dbContext.Bestellingen.AddRange(new List <Bestelling>
            {
                _bestellingBuilder.SetDummy()
                .SetFactuurnummer(1)
                .SetBestelStatus(BestelStatus.Geplaatst)
                .Create(),

                _bestellingBuilder.SetDummy()
                .SetFactuurnummer(2)
                .SetBestelStatus(BestelStatus.Goedgekeurd)
                .Create()
            });

            _dbContext.SaveChanges();
        }
        public void GetById_ShouldReturnArtikelOfId()
        {
            var artikel = new Artikel
            {
                Artikelnummer   = 1,
                Leveranciercode = "1-abc-2",
                LeverbaarTot    = new DateTime(2018, 11, 10),
                Naam            = "Fietsband",
                Prijs           = 10.99m
            };

            _bestelContext.Artikelen.Add(artikel);
            _bestelContext.SaveChanges();

            var result = _target.GetById(1);

            Assert.AreEqual(artikel.Artikelnummer, result.Artikelnummer);
            Assert.AreEqual(artikel.Leveranciercode, result.Leveranciercode);
            Assert.AreEqual(artikel.LeverbaarTot, result.LeverbaarTot);
            Assert.AreEqual(artikel.Naam, result.Naam);
            Assert.AreEqual(artikel.Prijs, result.Prijs);
        }
        private void SeedDatabase()
        {
            _context.Artikelen.AddRange(new List <Artikel>
            {
                new Artikel
                {
                    Artikelnummer   = 1,
                    Leveranciercode = "BAT-001-H ",
                    Naam            = "Batavus Heren Fiets Blauw",
                    Prijs           = 799.00m,
                },
                new Artikel
                {
                    Artikelnummer   = 2,
                    Leveranciercode = "POC-BL-009",
                    Naam            = "POC Blauwe Fietshelm",
                    Prijs           = 117.9m,
                }
            });

            _context.SaveChanges();
        }
 public Artikel Insert(Artikel entity)
 {
     _context.Artikelen.Add(entity);
     _context.SaveChanges();
     return(entity);
 }