我赞成这一解决办法:
但是,即使我把我的图布都改为。 具体说来,第一种经验是:
这里是独一无二的娱乐:
using System;
using NUnit.Framework; using Rhino.Mocks;
namespace FirstMonoClassLibrary { [TestFixture] public class TestingRhinoMocks { Sut _systemUnderTest; IFoo _dependency;
[SetUp]
public void Setup()
{
_dependency = MockRepository.GenerateMock<IFoo>();
_dependency.Expect(x => x.GetValue()).Return(1);
_systemUnderTest = new Sut(_dependency);
iii
[Test]
public void Test()
{
_dependency.Stub(x => x.GetValue()).Return(2);
var value = _systemUnderTest.GetValueFromDependency();
Assert.AreEqual(2, value); // Fails says it s 1
iii
iii
public interface IFoo
{
int GetValue();
iii
public class Sut
{
private readonly IFoo _foo;
public Sut(IFoo foo)
{
_foo = foo;
iii
public int GetValueFromDependency()
{
return _foo.GetValue();
iii
iii
iii