public void ReceiveBestelling_WithCompleteEvent_ShouldAddBevestigdeBestellingToDatabase() { // Arrange BevestigdeBestelling insertParam = null; var bestellingMock = new Mock <IBestellingDataMapper>(); bestellingMock.Setup(repo => repo.Insert(It.IsAny <BevestigdeBestelling>())).Returns(insertParam) .Callback <BevestigdeBestelling>(entity => { insertParam = entity; insertParam.Id = 1; }); var artikelMock = new Mock <IArtikelDataMapper>(); artikelMock.Setup(dm => dm.GetById(It.IsAny <int>())).Returns(new ArtikelEntity() { AfbeeldingUrl = "test" }); BevestigdeBestelling expected = new BevestigdeBestellingBuilder().SetDummy().Create(); var eventmessage = new BestellingGeplaatstEvent(Mapper.Map <CommonModels.DsBestelService.Models.Bestelling>(expected), ""); var listener = new EventListener(artikelMock.Object, null, bestellingMock.Object); // Act listener.ReceiveBestellingGeplaatstEvent(eventmessage); // Assert Assert.AreEqual(expected.BestelStatus, insertParam.BestelStatus); }
public void Insert_Should_InsertArtikel_When_NieuwArtikel_IsGiven() { // Arrange BevestigdeBestelling bevestigdeBestelling = new BevestigdeBestellingBuilder().SetDummy().Create(); // Act _target.Insert(bevestigdeBestelling); BevestigdeBestelling result = _target.GetByFactuurnummer(bevestigdeBestelling.Factuurnummer); // Assert Assert.IsNotNull(result); Assert.IsTrue(bevestigdeBestelling.IsEqual(result)); }
public void GetByFactuurnummer_Should_ReturnBevestigdeBestellingWithCertainId_When_Factuurnummer_IsGiven() { // Arrange BevestigdeBestelling bevestigdeBestelling = new BevestigdeBestellingBuilder().SetDummy().Create(); _context.BevestigdeBestellingen.Add(bevestigdeBestelling); _context.SaveChanges(); // Act BevestigdeBestelling result = _target.GetByFactuurnummer(bevestigdeBestelling.Factuurnummer); // Assert Assert.IsNotNull(result); Assert.IsTrue(bevestigdeBestelling.IsEqual(result)); }
public void Update_ShouldUpdateBevestigdeBestelling_When_AnUpdatedBevestigdeBestelling_IsGiven() { // Arrange BevestigdeBestelling bevestigdeBestelling = new BevestigdeBestellingBuilder().SetDummy().Create(); BevestigdeBestelling bevestigdeBestellingUpdate = bevestigdeBestelling; bevestigdeBestellingUpdate.BestelStatus = BestelStatus.Goedgekeurd; _target.Insert(bevestigdeBestelling); // Act _target.Update(bevestigdeBestellingUpdate); BevestigdeBestelling result = _target.GetByFactuurnummer(bevestigdeBestellingUpdate.Factuurnummer); // Assert Assert.IsNotNull(result); Assert.IsTrue(result.IsEqual(bevestigdeBestellingUpdate)); }
public void ReceiveUpdateBestelling_WithCompleteBestelling_ShouldUpdateBestelling() { // Arrange long bestellingId = 10; BevestigdeBestelling bestelling = new BevestigdeBestellingBuilder() .SetDummy() .SetId(bestellingId) .SetBestelRegels(new List <BevestigdeBestelRegel> { new BevestigdeBestelRegel { PrijsExclBtw = 10m, PrijsInclBtw = 10.10m } }) .SetFactuurTotaalExclBtw(42m) .SetFactuurTotaalInclBtw(42.42m) .Create(); var mock = new Mock <IBestellingDataMapper>(); var artikelMock = new Mock <IArtikelDataMapper>(); BevestigdeBestelling result = null; mock.Setup(repo => repo.GetById(bestellingId)).Returns(bestelling); mock.Setup(repo => repo.Update(It.IsAny <BevestigdeBestelling>())) .Callback <BevestigdeBestelling>(b => result = b); var updatedBestelling = new DsBestelServiceBestelling { Id = bestellingId, BestelStatus = DsBestelServiceBestelStatus.Goedgekeurd }; var eventmessage = new BestelStatusBijgewerktEvent(updatedBestelling, ""); var listener = new EventListener(artikelMock.Object, null, mock.Object); // Act listener.ReceiveBestelStatusBijgewerktEvent(eventmessage); // Assert mock.VerifyAll(); Assert.AreEqual(bestelling, result); }
public void Delete(BevestigdeBestelling entity) { throw new InvalidOperationException("Deleting a bestelling is not allowed."); }
public void Update(BevestigdeBestelling entity) { _context.BevestigdeBestellingen.Update(entity); _context.SaveChanges(); }
public BevestigdeBestelling Insert(BevestigdeBestelling entity) { _context.BevestigdeBestellingen.Add(entity); _context.SaveChanges(); return(entity); }
public static bool IsEqual(this BevestigdeBestelling entity, BevestigdeBestelling comparable) { if (entity.Id != comparable.Id) { return(false); } if (entity.Factuurnummer != comparable.Factuurnummer) { return(false); } if (entity.Klantnummer != comparable.Klantnummer) { return(false); } if (entity.FactuurTotaalExclBtw != comparable.FactuurTotaalExclBtw) { return(false); } if (entity.FactuurTotaalInclBtw != comparable.FactuurTotaalInclBtw) { return(false); } if (entity.BestelStatus != comparable.BestelStatus) { return(false); } if (entity.Besteldatum != comparable.Besteldatum) { return(false); } if (entity.BestelRegels.Count != comparable.BestelRegels.Count) { return(false); } var entityCatList = entity.BestelRegels.OrderBy(x => x.Artikelnummer); var comparableCatList = comparable.BestelRegels.OrderBy(x => x.Artikelnummer); for (int i = 0; i < entity.BestelRegels.Count; ++i) { if (entityCatList.ElementAt(i)?.Id != comparableCatList.ElementAt(i)?.Id) { return(false); } if (entityCatList.ElementAt(i)?.Artikelnummer != comparableCatList.ElementAt(i)?.Artikelnummer) { return(false); } if (entityCatList.ElementAt(i)?.Naam != comparableCatList.ElementAt(i)?.Naam) { return(false); } if (entityCatList.ElementAt(i)?.Aantal != comparableCatList.ElementAt(i)?.Aantal) { return(false); } if (entityCatList.ElementAt(i)?.PrijsExclBtw != comparableCatList.ElementAt(i)?.PrijsExclBtw) { return(false); } if (entityCatList.ElementAt(i)?.PrijsInclBtw != comparableCatList.ElementAt(i)?.PrijsInclBtw) { return(false); } if (entityCatList.ElementAt(i)?.RegelTotaalExclBtw != comparableCatList.ElementAt(i)?.RegelTotaalExclBtw) { return(false); } if (entityCatList.ElementAt(i)?.RegelTotaalInclBtw != comparableCatList.ElementAt(i)?.RegelTotaalInclBtw) { return(false); } } return(true); }