public void IsSatisfiedBy_ConstructorEmpty_Success()
        {
            var entity        = new MustComplyEntity();
            var specification = new MustComplyWithMetadataSpecificationBase <MustComplyEntity>();

            Assert.IsFalse(specification.IsSatisfiedBy(entity));
            Assert.AreEqual(specification.SpecificationResult.GetErrors().Count, 1);
        }
        public void IsSatisfiedBy_CustomErrorCodeConstructors_CustomErrorCodeOnError()
        {
            var entity        = new MustComplyEntity();
            var specification = new MustComplyWithMetadataSpecificationBase <MustComplyEntity>(5, 6, 7);

            Assert.IsFalse(specification.IsSatisfiedBy(entity));
            Assert.IsTrue(specification.SpecificationResult.GetErrors().Any(x => x.ErrorCode == 5));
        }
        public void IsSatisfiedBy_CustomErrorCodeConstructors_CustomErrorCodeOnError()
        {
            var entity = new MustComplyEntity();
            var specification = new MustComplyWithMetadataSpecificationBase<MustComplyEntity>(5, 6, 7);

            Assert.IsFalse(specification.IsSatisfiedBy(entity));
            Assert.IsTrue(specification.SpecificationResult.GetErrors().Any(x => x.ErrorCode == 5));
        }
        public void IsSatisfiedBy_ConstructorEmpty_Success()
        {
            var entity = new MustComplyEntity();
            var specification = new MustComplyWithMetadataSpecificationBase<MustComplyEntity>();

            Assert.IsFalse(specification.IsSatisfiedBy(entity));
            Assert.AreEqual(specification.SpecificationResult.GetErrors().Count, 1);
        }
        public void IsStisfiedby_ConstrctorEmpty_Succes()
        {
            var entity = new MustComplyEntity();
            var specification = new MustComplyWithMetadataSpecificationBase<MustComplyEntity>();
            entity.Name = "dwqqdw";
            entity.NameMinLength = "kdqop";

            Assert.IsTrue(specification.IsSatisfiedBy(entity));
        }
        public void IsStisfiedby_ConstrctorEmpty_Succes()
        {
            var entity        = new MustComplyEntity();
            var specification = new MustComplyWithMetadataSpecificationBase <MustComplyEntity>();

            entity.Name          = "dwqqdw";
            entity.NameMinLength = "kdqop";

            Assert.IsTrue(specification.IsSatisfiedBy(entity));
        }
        public void IsSatisfiedBy_CustomErrors_CustomErrorWithCustomCodeAndMsg()
        {
            var    myErrors      = new Dictionary <Type, DomainSpecificationError>();
            string customMessage = "Minha Mensagem";
            int    customCode    = 10;

            myErrors.Add(typeof(RequiredAttribute), new DomainSpecificationError(customCode, customMessage));

            var specification = new MustComplyWithMetadataSpecificationBase <MustComplyEntity>(myErrors);

            Assert.IsFalse(specification.IsSatisfiedBy(new MustComplyEntity()));
            Assert.IsTrue(specification.SpecificationResult.GetErrors().Any(x => x.ErrorCode == customCode));
            Assert.IsTrue(specification.SpecificationResult.GetErrors().Any(x => x.NotSatisfiedReason == customMessage));
        }
        public void IsSatisfiedBy_CustomErrors_CustomErrorWithCustomCodeAndMsg()
        {
            var myErrors = new Dictionary<Type, DomainSpecificationError>();
            string customMessage = "Minha Mensagem";
            int customCode = 10;

            myErrors.Add(typeof(RequiredAttribute), new DomainSpecificationError(customCode, customMessage));

            var specification = new MustComplyWithMetadataSpecificationBase<MustComplyEntity>(myErrors);

            Assert.IsFalse(specification.IsSatisfiedBy(new MustComplyEntity()));
            Assert.IsTrue(specification.SpecificationResult.GetErrors().Any(x => x.ErrorCode == customCode));
            Assert.IsTrue(specification.SpecificationResult.GetErrors().Any(x => x.NotSatisfiedReason == customMessage));
        }