0
두 번째 주장은 결코 아래 단위 테스트에서 실행되지 않습니다 :모의 작업을 설정할 때 Moq에서 네임 스페이스를 무시합니까?
namespace Foo {
public class MyClass {
}
}
namespace Bar {
public class MyClass {
}
}
namespace Quux {
public interface IRepo {
object Get<T>() where T : new();
}
}
namespace Tests {
[TestFixture]
public class MyTests {
private Mock<Quux.IRepo> repo = new Mock<Quux.IRepo>();
[SetUp]
public void Setup() {
repo.Setup(r => r.Get<Foo.MyClass>()).Returns(new Object());
repo.Setup(r => r.Get<Bar.MyClass>()).Returns(new Object());
}
[Test]
public void Test() {
Assert.IsNotNull(repo.Object.Get<Foo.MyClass>());
Assert.IsNotNull(repo.Object.Get<Bar.MyClass>()); // Never reached.
}
}
}
는 대한 설정을 덮어 <Bar.MyClass>()을 가져 오기 설정처럼 보이는 받기 <Foo.MyClass>(). 이것은 Moq이 설정시 Foo와 Bar 네임 스페이스를 무시한다는 것을 의미합니까? <T>()을 얻으시겠습니까? MyClass 클래스의 이름을 바꾸지 않고 IRepo를 구현하지 않고이 방법을 사용할 수 있습니까? 저는 Moq 3.1.416.3을 사용하고 있습니다.
업데이트 : 다음 릴리스에서는 fixed 인 것처럼 보입니다.
입니다. 나는 기회가있을 때 그것을보고 할 것이다. –
문제가보고 되었음 : http://code.google.com/p/moq/issues/detail?id=187 –