public void InvalidOnderhoudsopdrachtAfmeldenTest()
        {
            // Arrange
            var onderhoudsopdrachtServiceMock = new Mock <IOnderhoudsopdrachtService>(MockBehavior.Strict);

            onderhoudsopdrachtServiceMock.Setup(x => x.OnderhoudsopdrachtAfmelden(It.IsAny <OnderhoudAfmeldenCommand>()));

            var logServiceMock = new Mock <ILogService>(MockBehavior.Strict);

            logServiceMock.Setup(x => x.Log(It.IsAny <LogMessage>()));
            logServiceMock.Setup(x => x.LogException(It.IsAny <LogMessage>()));

            var controller = new OnderhoudController(onderhoudsopdrachtServiceMock.Object, logServiceMock.Object);

            controller.ModelState.AddModelError("error", "testerror");

            // Act
            var result = controller.OnderhoudsopdrachtAfmelden(new OnderhoudAfmeldenCommand());

            // Assert
            onderhoudsopdrachtServiceMock.Verify(x => x.OnderhoudsopdrachtAfmelden(It.IsAny <OnderhoudAfmeldenCommand>()), Times.Never());

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult));

            var invalidRequest = (result as BadRequestObjectResult).Value as InvalidRequest;

            Assert.AreEqual("Request bevat: 1 fouten", invalidRequest.Message);

            logServiceMock.Verify(x => x.Log(It.IsAny <LogMessage>()), Times.Once());
            logServiceMock.Verify(x => x.LogException(It.IsAny <LogMessage>()), Times.Never());
        }
        public void ValidOnderhoudsopdrachtAfmeldenDomainServiceExceptionTest()
        {
            // Arrange
            var onderhoudsopdrachtServiceMock = new Mock <IOnderhoudsopdrachtService>(MockBehavior.Strict);

            onderhoudsopdrachtServiceMock.Setup(x => x.OnderhoudsopdrachtAfmelden(It.IsAny <OnderhoudAfmeldenCommand>())).Throws <Exception>();

            var logServiceMock = new Mock <ILogService>(MockBehavior.Strict);

            logServiceMock.Setup(x => x.Log(It.IsAny <LogMessage>()));
            logServiceMock.Setup(x => x.LogException(It.IsAny <LogMessage>()));

            var controller = new OnderhoudController(onderhoudsopdrachtServiceMock.Object, logServiceMock.Object);

            // Act
            var result = controller.OnderhoudsopdrachtAfmelden(new OnderhoudAfmeldenCommand());

            // Assert
            onderhoudsopdrachtServiceMock.Verify(x => x.OnderhoudsopdrachtAfmelden(It.IsAny <OnderhoudAfmeldenCommand>()), Times.Once());

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult));

            var invalidRequest = (result as BadRequestObjectResult).Value as InvalidRequest;

            Assert.AreEqual("Er ging iets mis. Onderhoud niet afgemeld.", invalidRequest.Message);
            Assert.AreEqual(0, invalidRequest.InvalidProperties.Count());

            logServiceMock.Verify(x => x.Log(It.IsAny <LogMessage>()), Times.Never());
            logServiceMock.Verify(x => x.LogException(It.IsAny <LogMessage>()), Times.Once());
        }
        public void ValidOnderhoudsopdrachtAfmeldenTest()
        {
            // Arrange
            var logServiceMock = new Mock <ILogService>(MockBehavior.Strict);

            logServiceMock.Setup(x => x.Log(It.IsAny <LogMessage>()));
            logServiceMock.Setup(x => x.LogException(It.IsAny <LogMessage>()));

            var onderhoudsopdrachtServiceMock = new Mock <IOnderhoudsopdrachtService>(MockBehavior.Strict);

            onderhoudsopdrachtServiceMock.Setup(x => x.OnderhoudsopdrachtAfmelden(It.IsAny <OnderhoudAfmeldenCommand>()));

            var controller = new OnderhoudController(onderhoudsopdrachtServiceMock.Object, logServiceMock.Object);

            // Act
            var result = controller.OnderhoudsopdrachtAfmelden(new OnderhoudAfmeldenCommand());

            // Assert
            onderhoudsopdrachtServiceMock.Verify(x => x.OnderhoudsopdrachtAfmelden(It.IsAny <OnderhoudAfmeldenCommand>()), Times.Once());

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(OkResult));

            logServiceMock.Verify(x => x.Log(It.IsAny <LogMessage>()), Times.Never());
            logServiceMock.Verify(x => x.LogException(It.IsAny <LogMessage>()), Times.Never());
        }