This is a brain storming question. Any comments would be appreciated.
Recently I've observed a few source frameworks with a pattern similar to each other.
mock.Setup(framework => framework.DownloadExists("2.0.0.0"))
.Returns(true)
.AtMostOnce();
Bind<IService>().To<RedImpl>().WhenMemberHas<RedAttribute>();
HasManyToMany(x => x.Products)
.Cascade.All()
.Table("StoreProduct");
I've noticed that they are all related to some sort of configuration. And it is more convenient to use compared to normal property-setting configuration.
I can tell I like this style, but can't figure out exactly why.
Can anyone tell me what advantage it has and when this style would be useful? Also, Is there a name for such a style? How is this implemented under the hood? If there is a tutorial on how to write Moq-styled, that would be much appreciated.
Update
Thanks for all the help. Now that I know this style is called Fluent Interface, is there any tutorial on how to create a sample Fluent interface?