← Back to team overview

nunit-core team mailing list archive

[Bug 600627] [NEW] Assertion message formatted poorly by PropertyConstraint

 

Public bug reported:

When I place an EqualConstraint with a tolerance inside a
PropertyConstraint, the error message fails to format the tolerance.

So this is only a formatting issue, the test gives the correct result.

The following code reproduces the bug.

This was observed in NUnit version 2.5.5.10112
The code is compiled in Visual Studio 2010 targeting .NET 4.0 framework

        public class C { public decimal d { get; set; } }

	[TestFixture]
	public class T
	{
		[Test]
		public void PropertyConstraintTest()
		{
			var c = new C { d = 100.0m };
			// Write the error message 
			// Expected: 105m +/- 0.1m
			// But was:  100m
			//Assert.That(c.d, new EqualConstraint(105m).Within(0.1m));

			// Writes the error message
			// Expected: property d equal to 105m +/- <NUnit.Framework.Constraints.Tolerance>
			// But was:  100m
			Assert.That(c, new PropertyConstraint("d", new EqualConstraint(105m).Within(0.1m)));

		}
	}

** Affects: nunitv2
     Importance: Undecided
         Status: New

-- 
Assertion message formatted poorly by PropertyConstraint 
https://bugs.launchpad.net/bugs/600627
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.

Status in NUnit V2 Test Framework: New

Bug description:
When I place an EqualConstraint with a tolerance inside a PropertyConstraint, the error message fails to format the tolerance.

So this is only a formatting issue, the test gives the correct result.

The following code reproduces the bug.

This was observed in NUnit version 2.5.5.10112
The code is compiled in Visual Studio 2010 targeting .NET 4.0 framework

	public class C { public decimal d { get; set; } }

	[TestFixture]
	public class T
	{
		[Test]
		public void PropertyConstraintTest()
		{
			var c = new C { d = 100.0m };
			// Write the error message 
			// Expected: 105m +/- 0.1m
			// But was:  100m
			//Assert.That(c.d, new EqualConstraint(105m).Within(0.1m));

			// Writes the error message
			// Expected: property d equal to 105m +/- <NUnit.Framework.Constraints.Tolerance>
			// But was:  100m
			Assert.That(c, new PropertyConstraint("d", new EqualConstraint(105m).Within(0.1m)));

		}
	}





Follow ups

References