Beispiel #1
0
        public void UpdateExceptionTest()
        {
            //arrange
            Mock <IDatabaseManager> mockDbManager = new Mock <IDatabaseManager>();

            mockDbManager.Setup(m => m.UpdateHomeAbout(It.IsAny <AboutDto>())).Throws(new Exception());

            AboutDto testDto = new AboutDto {
                Id = 1, Value = "test"
            };

            _aboutManager = new AboutManager(mockDbManager.Object);

            //Act
            Assert.Throws <Exception>(() => _aboutManager.Update(testDto));

            mockDbManager.Verify(m => m.UpdateHomeAbout(It.IsAny <AboutDto>()), Times.Exactly(1));
        }
Beispiel #2
0
        public void UpdateTest()
        {
            //arrange
            Mock <IDatabaseManager> mockDbManager = new Mock <IDatabaseManager>();

            mockDbManager.Setup(m => m.UpdateHomeAbout(It.IsAny <AboutDto>())).Returns(true);

            AboutDto testDto = new AboutDto {
                Id = 1, Value = "test"
            };

            _aboutManager = new AboutManager(mockDbManager.Object);

            //Act
            AboutDto resultDto = _aboutManager.Update(testDto);

            //Assert
            Assert.AreEqual(testDto.Id, resultDto.Id);
            Assert.AreEqual(testDto.Value, resultDto.Value);
        }