public ArtikelEntity Insert(ArtikelEntity entity) { InsertCategoryIfNonExistent(entity); _context.ArtikelEntities.Add(entity); _context.SaveChanges(); return(entity); }
private void SeedDatabase() { var date = new DateTime(2018, 11, 10, 10, 42, 00); var bestellingen = new List <BevestigdeBestelling> { _bestellingBuilder.SetDummy() .SetFactuurnummer(1) .SetBestelStatus(BestelStatus.Geplaatst) .Create(), _bestellingBuilder.SetDummy() .SetFactuurnummer(2) .SetBestelStatus(BestelStatus.Goedgekeurd) .SetBesteldatum(date) .Create(), _bestellingBuilder.SetDummy() .SetFactuurnummer(3) .SetBestelStatus(BestelStatus.Goedgekeurd) .SetBesteldatum(date.AddMinutes(1)) .Create(), _bestellingBuilder.SetDummy() .SetFactuurnummer(4) .SetBestelStatus(BestelStatus.Goedgekeurd) .SetBesteldatum(date.AddDays(10)) .Create(), }; _dbContext.AddRange(bestellingen); _dbContext.SaveChanges(); }
public void GetByFactuurnummer_ShouldReturnSessionByFactuurNummer() { var session = new MagazijnSessionEntity { Factuurnummer = 10, MedewerkerEmail = "medewerker" }; _context.MagazijnSessions.Add(session); _context.SaveChanges(); var result = _target.GetByFactuurnummer(session.Factuurnummer); Assert.AreEqual(session.Id, result.Id); Assert.AreEqual(session.Factuurnummer, result.Factuurnummer); Assert.AreEqual(session.MedewerkerEmail, result.MedewerkerEmail); }
public void GetAll_ShouldReturnAllArtikelen() { // Arrange BevestigdeBestelling bevestigdeBestelling1 = new BevestigdeBestellingBuilder().SetDummy().Create(); BevestigdeBestelling bevestigdeBestelling2 = new BevestigdeBestellingBuilder().SetDummy().Create(); _context.BevestigdeBestellingen.Add(bevestigdeBestelling1); _context.BevestigdeBestellingen.Add(bevestigdeBestelling2); _context.SaveChanges(); // Act List <BevestigdeBestelling> result = _target.GetAll().OrderBy(r => r.Besteldatum).ToList(); // Assert Assert.AreEqual(2, result.Count); Assert.IsTrue(bevestigdeBestelling1.IsEqual(result[0])); Assert.IsTrue(bevestigdeBestelling2.IsEqual(result[1])); }
public void GetAllArtikelenFromDatabase() { // Arrange ArtikelEntity artikel1 = new ArtikelEntityBuilder().SetDummy().Create(); ArtikelEntity artikel2 = new ArtikelEntityBuilder().SetDummy().SetArtikelnummer(2).Create(); _context.ArtikelEntities.Add(artikel1); _context.ArtikelEntities.Add(artikel2); _context.SaveChanges(); // Act List <ArtikelEntity> result = _target.GetAll().ToList(); // Assert Assert.AreEqual(2, result.Count); Assert.IsTrue(artikel1.IsEqual(result[0])); Assert.IsTrue(artikel2.IsEqual(result[1])); }
public void GetAllKlanten_ShouldReturnKlanten() { // Arrange Klant klant = new KlantBuilder().SetDummy().Create(); klant.Adres = new AdresBuilder().SetDummy().Create(); Klant klant2 = new KlantBuilder().SetDummy().Create(); klant2.Adres = new AdresBuilder().SetDummy().Create(); _context.KlantEntities.Add(klant); _context.KlantEntities.Add(klant2); _context.SaveChanges(); // Act var result = _target.GetAll().ToList(); // Assert Assert.AreEqual(2, result.Count); Assert.AreEqual(1, result[0].Id); Assert.AreEqual(2, result[1].Id); }
private void ConfigureDatabase(IServiceCollection services) { DbContextOptions <BffContext> options = new DbContextOptionsBuilder <BffContext>() .UseNpgsql(Environment.GetEnvironmentVariable("DB_CONNECTION_STRING") ?? throw new InvalidOperationException()) .Options; services.AddSingleton(options); using (var context = new BffContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var klanten = Mapper.Map <List <Klant> >(DummyKlanten.Klanten); context.KlantEntities.AddRange(klanten); context.SaveChanges(); } }
public BevestigdeBestelling Insert(BevestigdeBestelling entity) { _context.BevestigdeBestellingen.Add(entity); _context.SaveChanges(); return(entity); }
public Klant Insert(Klant entity) { _context.KlantEntities.Add(entity); _context.SaveChanges(); return(entity); }
public MagazijnSessionEntity Insert(MagazijnSessionEntity entity) { _context.MagazijnSessions.Add(entity); _context.SaveChanges(); return(entity); }