Example #1
0
        public void ThrowIfInvalid_EntityIsInvalid_Exception()
        {
            var target = new EntityValidator <Entity>(new Entity
            {
                RequiredTitle    = "Awesome title 1234567890",
                NonRequiredTitle = "Awesome nit-required title 1234567890",
                Year             = 3020
            });

            Assert.Throws <EntityInvalidException>(() => target.ThrowIfInvalid());
        }
Example #2
0
        public void Valid_EntityIsValid_Ok()
        {
            var target = new EntityValidator <Entity>(new Entity
            {
                RequiredTitle    = "Awesome",
                NonRequiredTitle = null,
                Year             = 2020
            });

            Assert.True(target.Valid());

            target.ThrowIfInvalid();
        }