-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to express using SDHP when playing with Exception and FaultContract ? #134
Comments
Hi, What do you think about new assertions like:
Or
Or
|
I vote for '..DueTo...'. Clear intent orientation, vs the other ones that are more 'descriptive' |
DueTo(). I like it! |
I really like the |
Fine for me too ! Due To... I really like... |
For me the If that sounds good? |
Yeah... Bloody WCF! |
Best is to try find a generic way that cover also the special case of WCF. |
Hi there, My first exploration of the code lead me to understand, the 'generic solution' could be a bit 'hot' to implement. To publish a new idiom to nFluent the following pattern should be followed: From my understanding, the only way to add new Idioms as an exploration of the templated type, such as ExceptionDetail when dealing with this It could be feasible by reflecting the inner type and generate the Idioms on the fly, then compile it on the fly again, and then executing when the test run goes thru it. Stays to find a way to express that when writing the code (user side) since it is not known at the time executing as below :
Well, T4 lib could be used to generate the code on the fly, a dynamic assembly could be emitted using the magic of .Net, Stays to express 'a' way for the user to bypass the compiler with (late-binding) : 'dynamic' maybe ? Well pretty hot and generic and may be not completely feasible, but a Test framework must be 100% testable and this solution could not guaranty that because all uses-cases are not known in advance! Going back from Pluton to Earth : a pragmatic way to address the bloody use case of WCF is probably to manage the 'special case' of the bloody WCF :-( |
Following my previous post, and to address with a pragmatic way the special case of FaultContract, I propose the following derived from Could look like this:
This will cover the Default behavior when no custom FaultContract has been defined. 80% of the Use Cases... In case of Custom made Fault Contract the InnerException**_ is not forcibly exposed_**, this depends of the custom implementation. When the dev is going off the beaten track, he can write its custom 'Check' or simply write more verbose code than with nFluent. What's your mind ? |
Hi there,
Consider that piece of code:
try { wcfContractInstance.Raise(); } catch(FaultException fex) { Check.That(fex.Detail.Message).IsEqualTo("Invalid Call."); }
The SHDP is currently limited to the exception itself (inner 'templated' object properties stays hidden to the user:
Check.ThatCode ( () => wcfContractInstance.Raise() ).Throws(FaultException);
What solution could be found to enrich NFluent keeping the SDHP ?
Proposition:
Check.ThatCode ( () => wcfContractInstance.Raise() ).Throws(FaultException).WithInnerType().Message.IsEqualTo("Invalid Call.");
Where WithInnerType(): gives you access to all properties the dev wanna check.
This case was identified with a FaultContract coming from WCF, but it applies also to any Templated Exception.
Thanks.
The text was updated successfully, but these errors were encountered: