Thank you for your response.

You are correct.

Upon reviewing your answer, the issue I'm having is less with DbCommand
than with the DbParameterCollection.  I'm using Moq and when I try to
mock/fake the DbCommand and set up the DbParameterCollection using a
variety of standard techniques, Moq pitches a fit.

However, your answer combined with a review of the DbParameterCollection
class gave me an idea.  I'm going to give it a shot and see if it works.

Sincerely,
Robert

2018-04-05 20:38 GMT-04:00 Alexander Zaytsev <haz...@gmail.com>:

> DbCommand is an abstract class. It should be testable the same way as
> the IDbCommand interface.
>
> The reason to change is that interfaces are immutable (at least in
> Microsoft's point of view on BCL) - once set it cannot have methods added
> or removed. The abstract classes are more fluid and can have additional
> methods (if the method itself is not abstract). The particular functions we
> were interested from abstract classes are the *Async methods which were
> added to the class hierarchy, but not to the interfaces.
>
> Best Regards,
> Alexander
>
> On Fri, Apr 6, 2018 at 10:51 AM, TheNephalim <robert.eberh...@gmail.com>
> wrote:
>
>> I was writing some unit tests for a custom type and everything was fine
>> until I got to NullSafeSet:
>>
>>         public void NullSafeSet(DbCommand cmd, object value, int index,
>> ISessionImplementor session) {
>>             if (value == null) {
>>                 ((IDataParameter)cmd.Parameters[index]).Value =
>> DBNull.Value;
>>             } else {
>>                 var yes = (bool)value;
>>                 ((IDataParameter)cmd.Parameters[index]).Value = yes ?
>> "Y" : "N";
>>             }
>>         }
>>
>> It appears that on change NH-3431 there was a mass replace of the usage
>> of System.Data classes to System.Data.Common classes.  The code moved from
>> interfaces in the function signatures to concrete classes.  This makes it
>> not possible to test this method, as far as I can tell, without actually
>> trying to instantiate an instance of a command to pass into the method.
>>
>> Does anyone have an idea of why this choice was made?  It is what it is
>> at this point.  I'm just curious as to the reasoning.
>>
>> - Robert
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to nhusers+unsubscr...@googlegroups.com.
>> To post to this group, send email to nhusers@googlegroups.com.
>> Visit this group at https://groups.google.com/group/nhusers.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "nhusers" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/nhusers/39RnNkXgz78/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> nhusers+unsubscr...@googlegroups.com.
> To post to this group, send email to nhusers@googlegroups.com.
> Visit this group at https://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nhusers+unsubscr...@googlegroups.com.
To post to this group, send email to nhusers@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to