public void KlantController_MaakNieuweKlant_Fails() { // Arrange var target = new KlantController(null, null); // Act IActionResult result = target.MaakNieuweKlant(null); // Assert Assert.IsInstanceOfType(result, typeof(BadRequestResult)); }
public void KlantController_MaakNieuweKlant_Success() { // Arrange var repoMock = new Mock <IRepository>(MockBehavior.Strict); repoMock.Setup(r => r.Insert(It.IsAny <Klant>())); var pubMock = new Mock <IEventPublisher>(MockBehavior.Strict); pubMock.Setup(p => p.Publish(It.IsAny <KlantIsAangemaaktEvent>())); var target = new KlantController(repoMock.Object, pubMock.Object); var command = new MaakNieuweKlantCommand(); // Act IActionResult result = target.MaakNieuweKlant(command); // Assert Assert.IsInstanceOfType(result, typeof(OkResult)); repoMock.Verify(r => r.Insert(It.IsAny <Klant>()), Times.Once()); pubMock.Verify(p => p.Publish(It.IsAny <KlantIsAangemaaktEvent>()), Times.Once()); }