chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Hi,

I tried using the IsCloseTo check with a float property and can't seem to get it to work. This may be more of a feature request, to make it support other data types. I don't know.

When I try running the below class the 'double property' works but the 'int property' and 'float property' don't. They fail with

TypeMock Verification: Call to TestDriver+TargetClass.set_IntProperty() Parameter: 1
value <4> is not is range 5 +/- 2

and

TypeMock Verification: Call to TestDriver+TargetClass.set_FloatProperty() Parameter: 1
value <0.4> is not is range 0.5 +/- 0.2

[TestFixture]
public class TestDriver
{
   [Test]
   public void DoubleTest () {
      Mock mock = MockManager.Mock(typeof(TargetClass));
      TargetClass target = new TargetClass();

      mock.ExpectSet("DoubleProperty").Args(Check.IsCloseTo(0.5, 0.2));
      target.DoubleProperty = 0.4;
   }

   [Test]
   public void IntTest () {
      Mock mock = MockManager.Mock(typeof(TargetClass));
      TargetClass target = new TargetClass();

      mock.ExpectSet("IntProperty").Args(Check.IsCloseTo(5, 2));
      target.IntProperty = 4;
   }

   [Test]
   public void FloatTest () {
      Mock mock = MockManager.Mock(typeof(TargetClass));
      TargetClass target = new TargetClass();

      mock.ExpectSet("FloatProperty").Args(Check.IsCloseTo(0.5, 0.2));
      target.FloatProperty = 0.4F;
   }

   public class TargetClass {
      
      public double DoubleProperty { set { } }
      public int IntProperty { set { } }
      public float FloatProperty { set { } }
   }
}


I'm using .net 1.1 and TypeMock 3.01

Thanks,

Colin Gravill
asked by cgravill (1.2k points)

2 Answers

0 votes
Hi Colin,

It is true that the IsCloseTo was only meant for doubles.
It might be a good idea to support int and floats.

I will add this as a future feature.
answered by scott (32k points)
0 votes
Hi,
This request is now implemented and works in version 3.1
answered by scott (32k points)
...