Exemplo n.º 1
0
        public void ShouldBeValidWhenStatusIsNull()
        {
            // Arrange
            var    attr          = new StatusValidationAttribute();
            object invalidStatus = null;

            // Act
            var isValid = attr.IsValid(invalidStatus);

            // Assert
            Assert.True(isValid);
        }
Exemplo n.º 2
0
        public void ShouldUseStatusHelperToValidate()
        {
            // Arrange
            var statusHelperMock = new Mock <StatusHelper>(MockBehavior.Strict);
            var attr             = new StatusValidationAttribute(statusHelperMock.Object);
            var status           = "Asd";
            var expected         = false;

            statusHelperMock.Setup(i => i.IsValid(status)).Returns(expected);

            // Act
            var actual = attr.IsValid(status);

            // Assert
            Assert.Equal(expected, actual);
            statusHelperMock.Verify(i => i.IsValid(status), Times.Once());
        }