Ejemplo n.º 1
0
        public void ApplyTo_SinglePassingConstraints_Success()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(5));

            Assert.That(matches(subject, 6), Is.True);
        }
        public void ApplyTo_SinglePassingConstraints_Success()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(5));

            Assert.That(matches(subject, 6), Is.True);
        }
Ejemplo n.º 3
0
        public void WriteMessageTo_SingleFailingConstraint_ContainsConstraints()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(5));

            Assert.That(getMessage(subject, 4), Does.StartWith(TextMessageWriter.Pfx_Expected + "greater than 5"));
        }
Ejemplo n.º 4
0
        public void WriteMessageTo_SingleFailingConstraint_ContainsTheOffender()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(5));

            Assert.That(getMessage(subject, 4), Does.Contain("Specifically: greater than 5"));
        }
        public void ApplyTo_SingleFailingConstraints_Failure()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(5));

            Assert.That(matches(subject, 4), Is.False);
        }
Ejemplo n.º 6
0
 public NoOptimalChangeConstraint()
 {
     Delegate = new ConjunctionConstraint(
         Must.Have.Property(nameof(OptimalChangeSolution.IsSolution), Is.False),
         Is.Empty,
         Must.Have.Property(nameof(OptimalChangeSolution.Count), Is.EqualTo(0)));
 }
Ejemplo n.º 7
0
        public void ApplyTo_SingleFailingConstraints_Failure()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(5));

            Assert.That(matches(subject, 4), Is.False);
        }
Ejemplo n.º 8
0
 public NoChangeConstraint(Money remainder)
 {
     Delegate = new ConjunctionConstraint(
         Must.Have.Property(nameof(ChangeSolution.IsSolution), Is.False),
         Is.Empty,
         Must.Have.Property(nameof(ChangeSolution.Count), Is.EqualTo(0)),
         Must.Have.Property(nameof(ChangeSolution.Remainder), Is.EqualTo(remainder)));
 }
Ejemplo n.º 9
0
 public OptimalChangeConstraint(QDenomination[] denominations)
 {
     Delegate = new ConjunctionConstraint(
         Must.Have.Property(nameof(OptimalChangeSolution.IsSolution), Is.True),
         new ConstrainedEnumerable(
             denominations.Select(d => new QuantifiedDenominationConstraint(d))
             ));
 }
Ejemplo n.º 10
0
        public void WriteMessageTo_FailingConstraint_ActualContainsActual()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(1),
                Is.GreaterThan(5));

            Assert.That(getMessage(subject, 4),
                        Does.Contain(TextMessageWriter.Pfx_Actual + "4")
                        );
        }
Ejemplo n.º 11
0
        public void ApplyTo_PassingConstraint_Success()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(1),
                Is.GreaterThan(5));

            Assert.That(matches(subject, 6), Is.True);

            Assert.That(getMessage(subject, 6), Is.Empty);
        }
Ejemplo n.º 12
0
 public PartialChangeConstraint(Money remainder, uint totalCount, QDenomination[] denominations)
 {
     Delegate = new ConjunctionConstraint(
         Must.Have.Property(nameof(ChangeSolution.IsSolution), Is.True),
         Must.Have.Property(nameof(ChangeSolution.IsPartial), Is.True),
         Must.Have.Property(nameof(ChangeSolution.Remainder), Is.EqualTo(remainder)),
         Must.Have.Property(nameof(ChangeSolution.TotalCount), Is.EqualTo(totalCount)),
         new ConstrainedEnumerable(
             denominations.Select(d => new QuantifiedDenominationConstraint(d))
             ));
 }
 public QuantifiedDenominationConstraint(uint quantity, decimal denominationValue)
 {
     Delegate = new ConjunctionConstraint(
         Must.Have.Property(nameof(QuantifiedDenomination.Quantity), Is.EqualTo(quantity)),
         Must.Have.Property(nameof(QuantifiedDenomination.Denomination), Must.Have.Property(nameof(Denomination.Value), Is.EqualTo(denominationValue))));
 }
        public void ApplyTo_NoConstraints_Success()
        {
            var subject = new ConjunctionConstraint();

            Assert.That(matches(subject, new object()), Is.True);
        }
        public void WriteMessageTo_FailingConstraint_ActualContainsActual()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(1),
                Is.GreaterThan(5));

            Assert.That(getMessage(subject, 4),
                Does.Contain(TextMessageWriter.Pfx_Actual + "4")
            );
        }
        public void WriteMessageTo_SingleFailingConstraint_ContainsTheOffender()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(5));

            Assert.That(getMessage(subject, 4), Does.Contain("Specifically: greater than 5"));
        }
Ejemplo n.º 17
0
        public void ApplyTo_AllNullContraints_Success()
        {
            var subject = new ConjunctionConstraint(null, null);

            Assert.That(matches(subject, new object()), Is.True);
        }
Ejemplo n.º 18
0
        public void ApplyTo_EmptyConstraints_Success()
        {
            var subject = new ConjunctionConstraint(new Constraint[0]);

            Assert.That(matches(subject, new object()), Is.True);
        }
        public void WriteMessageTo_SingleFailingConstraint_ContainsConstraints()
        {
            var subject = new ConjunctionConstraint(
                Is.GreaterThan(5));

            Assert.That(getMessage(subject, 4), Does.StartWith(TextMessageWriter.Pfx_Expected + "greater than 5"));
        }