views:

203

answers:

1

I have two classes. I would like to verify that the properties are called on one of the classes.

public classA  
{  
    public IBInterface Foo {get;set;}  
    public LoadData()    
    {  
      Foo.Save(1.23456, 1.23456);  
    }  
}  

public classB : IBInterface   
{  
    public decimal ApplePrice {get; set;}    
    public decimal OrangePrice {get;  set;}    

    public void Save(decimal param1, decimal param2)  
    {  
        this.ApplePrice = param1;  
        this.OrangePrice = param2;  
    }
}  

I would like to use Rhino Mocks(AAA syntax) to verify that ApplePrice and OrangePrice were set correctly.

I assume I should begin like so but how do I verify that ApplePrice and OrangePrice have been set?

var mockInterfaceB = mockery.DynamicMock();
ClassA a = new ClassA();
a.Foo = mockInterfaceB;
a.LoadData();

+2  A: 
Jay
Sorry for the confusion - what I need is a unit test(I meant to write interaction not integration)Can you tell me how I would assert against the Apple and Orange properties, if the method does the following:>>public LoadData() { Foo.ApplePrice = -1; Foo.OrangePrice = -2; } What I need to know is how to verify that a property was set? Thanks again!
guazz
@guazz I added the test case in response to your comment.
Jay