Exemple #1
0
        public void WhenTransferDateIsFuture_ThenValidationPasses()
        {
            var transfer = new MakeTransfer {
                Date = new DateTime(2016, 12, 12)
            };
            var validator = new DateNotPastValidator();
            var actual    = validator.IsValid(transfer);

            Assert.AreEqual(true, actual);
        }
        public bool WhenTransferDateIsPast_ThenValidatorFails(int offset)
        {
            var now          = new DateTime(2016, 12, 12, 11, 11, 00);
            var transferDate = now.AddDays(offset);
            var transfer     = new Transfer {
                Date = transferDate
            };

            return(DateNotPastValidator.IsValid(transfer, () => now));
        }
Exemple #3
0
        public void WhenTransferDateIsPast_ThenValidatorFails(int offset, bool expected)
        {
            // Given
            var sut = new DateNotPastValidator(_presentDate);
            var cmd = new MakeTransfer {
                Date = _presentDate.AddDays(offset)
            };

            // When
            var result = sut.IsValid(cmd);

            // Then
            Assert.AreEqual(expected, result);
        }
Exemple #4
0
        public void valid_when_date_is_in_the_past_should_be_false()
        {
            // Arrange
            //var fake = new Mock<IDateTimeService>();
            //fake.SetupGet(x => x.UtcNow).Returns(presentDate);

            //var sut = new DateNotPastValidator(fake.Object);
            var sut = new DateNotPastValidator(presentDate);

            var cmd = new MakeTransfer {
                Date = presentDate.AddDays(-1)
            };

            // Act

            var actual = sut.IsValid(cmd);

            // Assert
            Assert.False(actual);
        }