public void SutIsBehaviorExpectation()
        {
            // Arrange
            // Act
            var sut = new EmptyGuidBehaviorExpectation();

            // Assert
            Assert.IsAssignableFrom <IBehaviorExpectation>(sut);
        }
        public void VerifyNullCommandThrows()
        {
            // Arrange
            var sut = new EmptyGuidBehaviorExpectation();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Verify(null));
        }
Пример #3
0
        public void VerifyNullCommandThrows()
        {
            // Fixture setup
            var sut = new EmptyGuidBehaviorExpectation();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Verify(null));
            // Teardown
        }
Пример #4
0
        public void SutIsBehaviorExpectation()
        {
            // Fixture setup
            // Exercise system
            var sut = new EmptyGuidBehaviorExpectation();

            // Verify outcome
            Assert.IsAssignableFrom <IBehaviorExpectation>(sut);
            // Teardown
        }
        public void VerifySuccedsWhenCommandThrowsCorrectException()
        {
            // Arrange
            var cmd = new DelegatingGuardClauseCommand
            {
                OnExecute     = v => { throw new ArgumentException(); },
                RequestedType = typeof(Guid)
            };
            var sut = new EmptyGuidBehaviorExpectation();

            // Act & Assert
            Assert.Null(Record.Exception(() =>
                                         sut.Verify(cmd)));
        }
Пример #6
0
        public void VerifySuccedsWhenCommandThrowsCorrectException()
        {
            // Fixture setup
            var cmd = new DelegatingGuardClauseCommand
            {
                OnExecute     = v => { throw new ArgumentException(); },
                RequestedType = typeof(Guid)
            };
            var sut = new EmptyGuidBehaviorExpectation();

            // Exercise system and verify outcome
            Assert.DoesNotThrow(() =>
                                sut.Verify(cmd));
            // Teardown
        }
        public void VerifyThrowsWhenCommandDoesNotThrow()
        {
            // Arrange
            var expected = new Exception();
            var cmd      = new DelegatingGuardClauseCommand
            {
                OnCreateException = v => v == "\"Guid.Empty\"" ? expected : new Exception(),
                RequestedType     = typeof(Guid)
            };
            var sut = new EmptyGuidBehaviorExpectation();
            // Act & Assert
            var result = Assert.Throws <Exception>(() =>
                                                   sut.Verify(cmd));

            Assert.Equal(expected, result);
        }
Пример #8
0
        public void VerifyThrowsWhenCommandDoesNotThrow()
        {
            // Fixture setup
            var expected = new Exception();
            var cmd      = new DelegatingGuardClauseCommand
            {
                OnCreateException = v => v == "\"Guid.Empty\"" ? expected : new Exception(),
                RequestedType     = typeof(Guid)
            };
            var sut = new EmptyGuidBehaviorExpectation();
            // Exercise system and verify outcome
            var result = Assert.Throws <Exception>(() =>
                                                   sut.Verify(cmd));

            Assert.Equal(expected, result);
            // Teardown
        }
        public void VerifyDoesNothingWhenRequestedTypeIsNotGuid(Type type)
        {
            // Arrange
            var executeInvoked = false;
            var mockCommand    = new DelegatingGuardClauseCommand {
                OnExecute = v => executeInvoked = true
            };

            mockCommand.RequestedType = type;

            var sut = new EmptyGuidBehaviorExpectation();

            // Act
            sut.Verify(mockCommand);
            // Assert
            Assert.False(executeInvoked);
        }
Пример #10
0
        public void VerifyDoesNothingWhenRequestedTypeIsNotGuid(Type type)
        {
            // Fixture setup
            var executeInvoked = false;
            var mockCommand    = new DelegatingGuardClauseCommand {
                OnExecute = v => executeInvoked = true
            };

            mockCommand.RequestedType = type;

            var sut = new EmptyGuidBehaviorExpectation();

            // Exercise system
            sut.Verify(mockCommand);
            // Verify outcome
            Assert.False(executeInvoked);
            // Teardown
        }
        public void VerifyThrowsWhenCommandThrowsUnexpectedException()
        {
            // Arrange
            var expectedInner = new Exception();
            var expected      = new Exception();
            var cmd           = new DelegatingGuardClauseCommand
            {
                OnExecute = v => { throw expectedInner; },
                OnCreateExceptionWithInner = (v, e) => v == "\"Guid.Empty\"" && expectedInner.Equals(e) ? expected : new Exception(),
                RequestedType = typeof(Guid)
            };
            var sut = new EmptyGuidBehaviorExpectation();
            // Act & Assert
            var result = Assert.Throws <Exception>(() =>
                                                   sut.Verify(cmd));

            Assert.Equal(expected, result);
        }
        public void VerifyCorrectlyInvokesExecuteWhenRequestedTypeIsGuid()
        {
            // Arrange
            var mockVerified = false;
            var mockCommand  = new DelegatingGuardClauseCommand
            {
                OnExecute         = v => mockVerified = Guid.Empty.Equals(v),
                OnCreateException = v => new InvalidOperationException(),
                RequestedType     = typeof(Guid)
            };

            var sut = new EmptyGuidBehaviorExpectation();

            // Act
            try
            {
                sut.Verify(mockCommand);
            }
            catch (InvalidOperationException) { }
            // Assert
            Assert.True(mockVerified);
        }