How to translate C# 'readonly' keyword into D

rumbu rumbu at rumbu.ro
Mon Feb 4 07:25:40 PST 2013


First, AFAIK, there is no equivalent of C# "readonly" in D, 
despite the fact that D uses 3 keywords for various kinds of 
immutability.

Second, here you can find a  mocking library for D: 
http://www.dsource.org/projects/dmocks/wiki/DMocks



On Monday, 4 February 2013 at 13:35:24 UTC, o3o wrote:
> 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