Esempio n. 1
0
        public void ValidationReturnsMultipleErrorCountWhenDatesAreNotCorrect()
        {
            var model = new PostViewModel
            {
                ValidFrom  = DateTime.UtcNow.AddDays(-1),
                ValidUntil = DateTime.UtcNow.AddDays(-4),
            };

            var errorsCount = model.Validate(null).Count();

            Assert.True(errorsCount > 1);
        }
Esempio n. 2
0
        public void ValidationPassesWhenValidFromDateIsGreaterThanCurrentDateAndValidUntilDateIsGreaterThanValidFromDate()
        {
            var model = new PostViewModel
            {
                ValidFrom  = DateTime.UtcNow,
                ValidUntil = DateTime.UtcNow.AddDays(1),
            };

            var errorsCount = model.Validate(null).Count();

            Assert.Equal(0, errorsCount);
        }
Esempio n. 3
0
        public void ValidationFailsWhenCurrentDateIsGreaterThanValidFromDate()
        {
            var model = new PostViewModel
            {
                ValidFrom  = DateTime.UtcNow.AddDays(-1),
                ValidUntil = DateTime.UtcNow.AddDays(3),
            };

            var errorsCount = model.Validate(null).Count();

            Assert.True(errorsCount > 0);
        }