Instead of writing
var serialNoRow = Isolate.Fake.Instance<Elite_Lock_Record>(); Isolate.WhenCalled(()=>serialNoRow.IncarnationID_UID).WillReturn(100); Isolate.WhenCalled(()=>serialNoRow.LockType).WillReturn(lockType); Isolate.WhenCalled(()=>serialNoRow.CodePractice).WillReturn(codePractice); Isolate.WhenCalled(()=>serialNoRow.Software).WillReturn(software); Isolate.WhenCalled(()=>serialNoRow.RunningNumber).WillReturn(runningNumber);
I want to be able to write
Isolate.WhenCalled(()=>serialNoRow).SetProperty( { IncarnationID_UID=100, LockType= lockType, CodePractice= codePractice .. });
The idea is to reduce the time I type Isolate.WhenCall, WillReturn etc. Not sure whether this is possible or not
var fakesRow = Isolate.Fake.Instance<Elite_Lock_Record>(); fakesRow.IncarnationID_UID = 100; fakesRow.LockType = lockType; fakesRow.CodePractice = codePractice; fakesRow.Software = software; fakesRow.RunningNumber = runningNumber;
Hi Soon Hui, Nice idea, like property initializers in C#. I don't think this will work, because of the compiler, but we can get to a syntax that will. Do you find you need this often? Thanks,
Yes, quite often. In my application I often have to mock the data inside a [url=msdn.microsoft.com/en-us/library/system.data.datatable.aspx]datatable[/url] just to simulate the data access layer. So if I have 5 columns, I need to repeat all those statements 5 times. [/quote]
With the latest version this can be done using True Properties var fakesRow = Isolate.Fake.Instance<Elite_Lock_Record>(); fakesRow.IncarnationID_UID = 100; fakesRow.LockType = lockType; fakesRow.CodePractice = codePractice; fakesRow.Software = software; fakesRow.RunningNumber = runningNumber;
Good idea, but I afraid fakesRow.IncarnationID_UID = 100; might not work if IncarnatioID_UID is a get only properties... any idea to get around this?