public void Insert_ShouldInsertKlant() { // Arrange Klant klant = new KlantBuilder().SetDummy().Create(); var dataMapper = new KlantDataMapper(_context); // Act dataMapper.Insert(klant); Klant result = dataMapper.GetById(klant.Id); // Assert Assert.IsNotNull(result); Assert.IsTrue(klant.IsEqual(result)); }
public void GetById_ShouldReturnKlant_When_ExistingIdIsGiven() { // Arrange Klant klant = new KlantBuilder().SetDummy().Create(); _context.Klanten.Add(klant); _context.SaveChanges(); var dataMapper = new KlantDataMapper(_context); // Act Klant result = dataMapper.GetById(klant.Id); // Assert Assert.IsNotNull(result); Assert.IsTrue(klant.IsEqual(result)); }
public void Find_ShouldReturnKlantMatchingACertainPredicate_When_PredicateIsGiven() { // Arrange Klant klant1 = new KlantBuilder().SetDummy().Create(); Klant klant2 = new KlantBuilder().SetDummy().SetEmail("*****@*****.**").Create(); _context.Klanten.Add(klant1); _context.Klanten.Add(klant2); _context.SaveChanges(); var dataMapper = new KlantDataMapper(_context); // Act List <Klant> result = dataMapper.Find(x => x.Email.Contains("worst")).ToList(); // Assert Assert.AreEqual(1, result.Count); Assert.IsTrue(klant2.IsEqual(result[0])); }
public void HandleVoegKlantToe_ShouldCallDataMapperInsert() { // Arrange Klant klant = new KlantBuilder().SetDummy().Create(); var command = new VoegKlantToeCommand(klant, ""); Klant insertParam = null; _klantDataMapperMock.Setup(repo => repo.Insert(It.IsAny <Klant>())).Returns(klant) .Callback <Klant>(entity => { insertParam = entity; }); _eventPublisherMock.Setup(p => p.Publish(It.IsAny <KlantToegevoegdEvent>())); // Act var result = _target.HandleVoegKlantToe(command); // Assert _klantDataMapperMock.VerifyAll(); Assert.IsNotNull(result); Assert.IsTrue(klant.IsEqual(klant)); }