New syntax for configuration of property setters
See original GitHub issueI have simple class
public class Simple
{
public virtual int VirtualProperty { get; set; }
}
When i run (FakeItEasy.1.13.1)
var strict = A.Fake<Simple>(options => options.Strict());
A.CallTo(() => strict.VirtualProperty).CallsBaseMethod();
strict.VirtualProperty = 999;
I get an error Call to non configured method “set_VirtualProperty” of strict fake.
And I have to
var strict = A.Fake<Simple>(options => options.Strict());
A.CallTo(strict).Where(a => a.Method.Name == "get_VirtualProperty").CallsBaseMethod();
A.CallTo(strict).Where(a => a.Method.Name == "set_VirtualProperty").CallsBaseMethod();
strict.VirtualProperty = 999;
Does CallBaseMethod () works for virtual property? What am I doing wrong
Update
The proposed syntax is:
A.CallToSet(() => foo.Bar)…
A.CallToSet(() => foo.Bar).To(42)…
A.CallToSet(() => foo.Bar["the answer"]).To(42)…
A.CallToSet(() => foo.Bar).To(() => A<int>.That.IsGreaterThan(0)))…
A.CallToSet(() => …).WithAnyArguments()…
A.CallToSet(() => …).WhenArgumentsMatch(call => …)…
These methods would allow configuration of the call in the same way that is currently provided by
A.CallTo(foo).Where(a => a.Method.Name == "set_Foo" ... )...
Issue Analytics
- State:
- Created 10 years ago
- Comments:132 (121 by maintainers)
Top Results From Across the Web
Property getters and setters
Accessor properties are represented by “getter” and “setter” methods. In an object literal they are denoted by get and set :.
Read more >Guide to @ConfigurationProperties in Spring Boot
A quick and practical guide to @ConfigurationProperties annotation in Spring Boot.
Read more >Init only setters - C# 9.0 draft feature specifications
This feature specification describes the rules for 'init' only setters in properties. These can be set only as part of an instantiation, ...
Read more >Immutable @ConfigurationProperties - java
So your actual code without any setter is now fine : @ConstructorBinding @ConfigurationProperties(prefix = "example") public final class ...
Read more >Learn C# Properties: Getters and Setters at Intermediate ...
"To create a property, use the same syntax as for fields, but add a get; to generate a getter and a set; to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How about: