あなたの例では、テスト対象のクラスの機能をテストしているように見えるので、RhinoMocksは必要ありません。代わりに、単純な単体テストを実行します。
[Test]
public void SomeTest()
{
var sc = new SomeClass();
// Instantiate SomeClass as sc object
sc.SomeMethod();
// Call SomeMethod in the sc object.
Assert.That(sc.SomeProp, Is.True );
// Assert that the property is true...
// or change to Is.False if that's what you're after...
}
他のクラスに依存するクラスがある場合は、モックをテストする方がはるかに興味深いです。あなたの例では、次のように述べています。
//ここで_someArgを使用してファイル、wcf、db操作を実行します
つまり、他のクラスがSomeClass
のプロパティを設定することを期待します。これは、モックテストの方が理にかなっています。例:
public class MyClass {
ISomeClass _sc;
public MyClass(ISomeClass sc) {
_sc = sc;
}
public MyMethod() {
sc.SomeProp = true;
}
}
必要なテストは次のようになります。
[Test]
public void MyMethod_ShouldSetSomeClassPropToTrue()
{
MockRepository mocks = new MockRepository();
ISomeClass someClass = mocks.StrictMock<ISomeClass>();
MyClass classUnderTest = new MyClass(someClass);
someClass.SomeProp = true;
LastCall.IgnoreArguments();
// Expect the property be set with true.
mocks.ReplayAll();
classUndertest.MyMethod();
// Run the method under test.
mocks.VerifyAll();
}