Moq consente agli sviluppatori di simulare membri protetti. Stavo cercando la stessa funzionalità in Rhino.Mocks ma non riesco a trovarlo.Come imitare i membri virtuali protetti con Rhino.Mocks?
Ecco un esempio della pagina Moq Quick Start su come simulare il metodo protetto.
// at the top of the test fixture
using Moq.Protected()
// in the test
var mock = new Mock<CommandBase>();
mock.Protected()
.Setup<int>("Execute")
.Returns(5);
// if you need argument matching, you MUST use ItExpr rather than It
// planning on improving this for vNext
mock.Protected()
.Setup<string>("Execute",
ItExpr.IsAny<string>())
.Returns(true);
Fammi sapere se sto inseguendo qualcosa che non esce.
È potrebbe voler controllare questo link http://geekswithblogs.net/MattRobertsBlog/archive/2008/12/16/how-to-make-a-quotprotectedquot-method-available-for-quotpartialquot-mocking-and-again.aspx – juharr
Non è proprio una soluzione adatta - dover cambiare la tua classe originale per esporre un metodo internamente ad altre classi m Si sta alterando il tuo design per far fronte ai test. Cattivo odore per me –