예제 #1
0
        public void Remove_ShouldCallInner_AndTap_WhenLoggerIsGiven_AndIdIsGiven()
        {
            // Arrange
            const int id = 7;

            _mockInner.Setup(u => u.Remove(id));
            _mockTap.Setup(u => u.Remove(id));

            var subject = new RepositoryTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object);

            // Act
            subject.Remove(id);

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
예제 #2
0
        public void Remove_ShouldDoNothing_WhenIdIsGiven_AndTapThrowsException()
        {
            // Arrange
            const int id = 7;

            _mockInner.Setup(u => u.Remove(id));
            _mockTap
            .Setup(u => u.Remove(id))
            .Throws(new InvalidOperationException());

            var subject = new RepositoryTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object);

            // Act
            subject.Remove(id);

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
예제 #3
0
        public void Remove_ShouldCallInner_AndTap_WhenLoggerIsGiven_AndEntityIsGiven()
        {
            // Arrange
            var person = new FakeEntity <int> {
                Id = 7, Name = "Tiffany"
            };

            _mockInner.Setup(u => u.Remove(person));
            _mockTap.Setup(u => u.Remove(person));

            var subject = new RepositoryTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object);

            // Act
            subject.Remove(person);

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
예제 #4
0
        public void Remove_ShouldLogException_WhenLoggerIsGiven_AndIdIsGiven_AndTapThrowsException()
        {
            // Arrange
            const int id = 7;

            _mockInner.Setup(u => u.Remove(id));
            _mockTap
            .Setup(u => u.Remove(id))
            .Throws(new InvalidOperationException());
            _mockLogger.Setup(l => l.Log(LogLevel.Warning, 0, It.IsAny <object>(), It.IsAny <InvalidOperationException>(), It.IsAny <Func <object, Exception, string> >()));

            var subject = new RepositoryTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object);

            // Act
            subject.Remove(id);

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
예제 #5
0
        public void Remove_ShouldSkipTap_WhenLoggerIsGiven_AndIdIsGiven_AndInnerThrowsException()
        {
            // Arrange
            const int id = 7;

            _mockInner
            .Setup(u => u.Remove(id))
            .Throws(new InvalidOperationException());

            var subject = new RepositoryTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object);

            // Act
            Action action = () => subject.Remove(id);

            // Assert
            action.Should().Throw <InvalidOperationException>();

            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
예제 #6
0
        public void Remove_ShouldDoNothing_WhenEntityIsGiven_AndTapThrowsException()
        {
            // Arrange
            var person = new FakeEntity <int> {
                Id = 7, Name = "Tiffany"
            };

            _mockInner.Setup(u => u.Remove(person));
            _mockTap
            .Setup(u => u.Remove(person))
            .Throws(new InvalidOperationException());

            var subject = new RepositoryTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object);

            // Act
            subject.Remove(person);

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }