File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -998,13 +998,22 @@ public void ExpectGetAndExpectSetMatchArguments()
998998 target . VerifyAll ( ) ;
999999 }
10001000
1001+ #nullable enable
10011002 [ Fact ]
10021003 public void ArgumentNullMatchProperCtor ( )
10031004 {
10041005 var target = new Mock < Foo > ( null ) ;
10051006 Assert . Null ( target . Object . Bar ) ;
10061007 }
10071008
1009+ [ Fact ]
1010+ public void ParamsArrayContainsNullMatchProperCtor ( )
1011+ {
1012+ var target = new Mock < Foo > ( new Bar ? [ ] { null } ) ;
1013+ Assert . Null ( target . Object . Bar ) ;
1014+ }
1015+ #nullable disable
1016+
10081017 [ Fact ]
10091018 public void DistinguishesSameMethodsWithDifferentGenericArguments ( )
10101019 {
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ public Mock()
139139 /// var mock = new Mock<MyProvider>(someArgument, 25);
140140 /// </code>
141141 /// </example>
142- public Mock ( params object [ ] args )
142+ public Mock ( params object ? [ ] ? args )
143143 : this ( MockBehavior . Default , args )
144144 {
145145 }
@@ -154,7 +154,7 @@ public Mock(params object[] args)
154154 /// </code>
155155 /// </example>
156156 public Mock ( MockBehavior behavior )
157- : this ( behavior , new object [ 0 ] )
157+ : this ( behavior , Array . Empty < object ? > ( ) )
158158 {
159159 }
160160
@@ -168,14 +168,11 @@ public Mock(MockBehavior behavior)
168168 /// The mock will try to find the best match constructor given the constructor arguments,
169169 /// and invoke that to initialize the instance. This applies only to classes, not interfaces.
170170 /// </remarks>
171- public Mock ( MockBehavior behavior , params object [ ] args )
171+ public Mock ( MockBehavior behavior , params object ? [ ] ? args )
172172 {
173173 Guard . IsMockable ( typeof ( T ) ) ;
174174
175- if ( args == null )
176- {
177- args = new object [ ] { null } ;
178- }
175+ args ??= new object ? [ ] { null } ;
179176
180177 this . additionalInterfaces = new List < Type > ( ) ;
181178 this . behavior = behavior ;
You can’t perform that action at this time.
0 commit comments