/// <summary>
        /// Create a new instance of a test case
        /// </summary>
        /// <param name="sutXml"></param>
        /// <param name="ctrXml"></param>
        /// <returns></returns>
        public TestCase Instantiate(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)
        {
            if (sutXml == null)
                throw new ArgumentNullException("sutXml");
            if (ctrXml == null)
                throw new ArgumentNullException("ctrXml");

            ITestCaseBuilder builder = null;

            //Look for registration ...
            var registration = registrations.FirstOrDefault(reg => sutXml.GetType()==reg.SystemUnderTestType && ctrXml.GetType() == reg.ConstraintType);
            if (registration == null)
                throw new ArgumentException(string.Format("'{0}' is not an expected type for a constraint with a system-under-test '{1}'.", ctrXml.GetType().Name, sutXml.GetType().Name));

            //Apply the chooser if needed
            if (registration.Builder == null)
                registration.Chooser.Choose(sutXml, ctrXml);

            //Get Builder and initiate it
            builder = registration.Builder;
            builder.Setup(sutXml, ctrXml, configuration);

            //Build
            builder.Build();
            NUnitCtr.Constraint ctr = builder.GetConstraint();
            var sut = builder.GetSystemUnderTest();

            //Apply negation if needed
            if (ctrXml.Not)
                ctr = new NUnitCtr.NotConstraint(ctr);

            return new TestCase(sut, ctr);
        }
Exemple #2
0
        /// <summary>
        /// Create a new instance of a test case
        /// </summary>
        /// <param name="sutXml"></param>
        /// <param name="ctrXml"></param>
        /// <returns></returns>
        public TestCase Instantiate(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)
        {
            if (sutXml == null)
            {
                throw new ArgumentNullException("sutXml");
            }
            if (ctrXml == null)
            {
                throw new ArgumentNullException("ctrXml");
            }

            ITestCaseBuilder builder = null;

            //Look for registration ...
            var registration = registrations.FirstOrDefault(reg => sutXml.GetType() == reg.SystemUnderTestType && ctrXml.GetType() == reg.ConstraintType);

            if (registration == null)
            {
                throw new ArgumentException(string.Format("'{0}' is not an expected type for a constraint with a system-under-test '{1}'.", ctrXml.GetType().Name, sutXml.GetType().Name));
            }

            //Apply the chooser if needed
            if (registration.Builder == null)
            {
                registration.Chooser.Choose(sutXml, ctrXml);
            }

            //Get Builder and initiate it
            builder = registration.Builder;
            builder.Setup(sutXml, ctrXml, configuration, variables);

            //Build
            builder.Build();
            NUnitCtr.Constraint ctr = builder.GetConstraint();
            var sut = builder.GetSystemUnderTest();

            //Apply negation if needed
            if (ctrXml.Not)
            {
                ctr = new NUnitCtr.NotConstraint(ctr);
            }

            return(new TestCase(sut, ctr));
        }
Exemple #3
0
 public void SetUp()
 {
     theConstraint = new NotConstraint( new EqualConstraint(null) );
     expectedDescription = "not null";
     stringRepresentation = "<not <equal null>>";
 }
Exemple #4
0
        /// <summary>
        /// Resolve a constraint that has been recognized by applying
        /// any pending operators and returning the resulting Constraint.
        /// </summary>
        /// <returns>A constraint that incorporates all pending operators</returns>
        private Constraint Resolve(Constraint constraint)
        {
            while (ops.Count > 0)
                switch ((Op)ops.Pop())
                {
                    case Op.Not:
                        constraint = new NotConstraint(constraint);
                        break;
                    case Op.All:
                        constraint = new AllItemsConstraint(constraint);
                        break;
					case Op.Some:
						constraint = new SomeItemsConstraint(constraint);
						break;
					case Op.None:
						constraint = new NoItemConstraint(constraint);
						break;
					case Op.Prop:
						constraint = new PropertyConstraint( (string)opnds.Pop(), constraint );
						break;
                }

            return constraint;
        }
Exemple #5
0
        /// <summary>
        /// Resolve a constraint that has been recognized by applying
        /// any pending operators and returning the resulting Constraint.
        /// </summary>
        /// <param name="constraint">The root constraint</param>
        /// <returns>A constraint that incorporates all pending operators</returns>
        private Constraint Resolve(Constraint constraint)
        {
            while (ops.Count > 0)
                switch ((Op)ops.Pop())
                {
                    case Op.Not:
                        constraint = new NotConstraint(constraint);
                        break;
                    case Op.All:
                        constraint = new AllItemsConstraint(constraint);
                        break;
                    case Op.Some:
                        constraint = new SomeItemsConstraint(constraint);
                        break;
                }

            return constraint;
        }