Moq, Ninject, NHibernate-style free library?

This is a brainstorm. Any comments would be appreciated.

Recently, I noticed several source frameworks with similar patterns.

Moq

mock.Setup(framework => framework.DownloadExists("2.0.0.0"))
    .Returns(true)
    .AtMostOnce();

Ninject

Bind<IService>().To<RedImpl>().WhenMemberHas<RedAttribute>();

and Free NHibernate

   HasManyToMany(x => x.Products)
     .Cascade.All()
     .Table("StoreProduct");

I noticed that they are all related to some kind of configuration. And it’s more convenient to use compared to the usual property setting configuration.

I can say that I like this style, but I can’t understand why.

Can someone tell me what good it is and when this style will be useful? Also, is there a name for this style? How is this done under the hood? If there is a tutorial on how to write a Moq style, that would be very appreciated.

Update

. , , Fluent Interface, - , Fluent?

+3
3

Fluent Interface http://www.martinfowler.com/bliki/FluentInterface.html

, , . , , , , .

, Builder , .

+4

, .

+2

DSL ( ). , .

, IoC xml - , , , .

+2

Source: https://habr.com/ru/post/1777208/


All Articles