How to translate C# 'readonly' keyword into D

o3o orfeo.davia at gmail.com
Mon Feb 4 05:35:23 PST 2013


On Monday, 4 February 2013 at 10:26:55 UTC, simendsjo wrote:
> [cut]
> So.. Every method you call through a const instance must also 
> be const, otherwise you have the ability to change something 
> that should be a constant.
Thanks simendsjo, now I get it...

So, let me continue the example (I remove "const" for 
simplicity)...
I would like check that bar.gun() call fun() function from IFoo

unittest {
      auto foo = new Mock<IFoo>(); //Will not compile.Mock doesn't 
(yet) exist
      auto bar = new Bar(foo);
      bar.gun();
      foo.Received().fun(); // pass if 'fun' was called
}

void main() {}

In other words, I need a mock object like nsubstitute 
(http://nsubstitute.github.com/help/getting-started/) or moq 
(http://code.google.com/p/moq/)

In your old post 
http://forum.dlang.org/thread/il29hs$2svt$1@digitalmars.com
you were asking for mocking frameworks...do you found any 
solution?
Thanks


More information about the Digitalmars-d-learn mailing list