Tôi đang sử dụng một phần mở rộng điều khiển, và tôi đã cố gắng để thử nó bằng cách sử FakeItEasy (v 1.7.4) như thế này:có thể giả lập/giả mạo một phương pháp mở rộng không?
A.CallTo(() => controller.RenderView(A<string>.Ignored,A<object>.Ignored,null)).Returns("");
nhưng tôi nhận được lỗi này:
System.NullReferenceException : Object reference not set to an instance of an object.
at System.Object.GetType()
at FakeItEasy.Creation.ProxyGeneratorSelector.MethodCanBeInterceptedOnInstance(MethodInfo method, Object callTarget, ref String failReason)
at FakeItEasy.Configuration.DefaultInterceptionAsserter.AssertThatMethodCanBeInterceptedOnInstance(MethodInfo method, Object callTarget)
at FakeItEasy.Configuration.FakeConfigurationManager.CallTo(Expression`1 callSpecification)
Ngoài ra, nếu bạn muốn có một tùy chọn miễn phí, Nốt ruồi cũng cho phép chế nhạo các phương pháp tĩnh: http: // nghiên cứu .microsoft.com/vi-us/projects/pex/ –
Điều này có thể đến với FakeItEasy. Làm thế nào sớm, tôi không chắc chắn - https://github.com/FakeItEasy/FakeItEasy/issues/90 –