2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using AndcultureCode . CSharp . Extensions . Tests . Stubs ;
5
- using AndcultureCode . CSharp . Testing . Tests ;
6
5
using Shouldly ;
7
6
using Xunit ;
8
7
using Xunit . Abstractions ;
9
8
10
9
namespace AndcultureCode . CSharp . Extensions . Tests
11
10
{
12
- public class TypeExtensionsTests : BaseUnitTest
11
+ public class TypeExtensionsTests : BaseExtensionsTest
13
12
{
14
13
#region Constructor
15
14
@@ -95,6 +94,20 @@ public void GetPublicPropertyInfo_When_Property_Does_Not_Exist_Then_Returns_Null
95
94
96
95
#region GetPublicPropertyValue
97
96
97
+ [ Fact ]
98
+ public void GetPublicPropertyValue_When_Src_Is_Null_Then_Returns_Null ( )
99
+ {
100
+ // Arrange
101
+ var propertyName = nameof ( TypeExtensionsTestStub . TEST_STRING_PROPERTY ) ;
102
+ TypeExtensionsTestStub instance = null ;
103
+
104
+ // Act
105
+ var result = instance . GetPublicPropertyValue ( propertyName ) ;
106
+
107
+ // Assert
108
+ result . ShouldBeNull ( ) ;
109
+ }
110
+
98
111
[ Fact ]
99
112
public void GetPublicPropertyValue_When_Property_Exists_Then_Returns_Value ( )
100
113
{
@@ -318,20 +331,12 @@ public void GetTypeName_Type_Overload_Given_InstanceOf_Object_Returns_AssemblyQu
318
331
319
332
#region HasPublicProperty
320
333
321
- private class HasPublicPropertyTestStub
322
- {
323
- public string TEST_STRING_PROPERTY { get ; set ; }
324
- private string TEST_PRIVATE_STRING_PROPERTY { get ; set ; }
325
- public static string TEST_STATIC_STRING = "TEST_STATIC_STRING" ;
326
- public const string TEST_CONST_STRING = "TEST_CONST_STRING" ;
327
- }
328
-
329
334
[ Fact ]
330
335
public void HasPublicProperty_When_Called_With_Public_PropertyName_Then_Returns_True ( )
331
336
{
332
337
// Arrange
333
- var type = typeof ( HasPublicPropertyTestStub ) ;
334
- var propertyName = nameof ( HasPublicPropertyTestStub . TEST_STRING_PROPERTY ) ;
338
+ var type = typeof ( TypeExtensionsTestStub ) ;
339
+ var propertyName = nameof ( TypeExtensionsTestStub . TEST_STRING_PROPERTY ) ;
335
340
336
341
// Act
337
342
var result = type . HasPublicProperty ( propertyName ) ;
@@ -344,7 +349,7 @@ public void HasPublicProperty_When_Called_With_Public_PropertyName_Then_Returns_
344
349
public void HasPublicProperty_When_Called_With_NonExisting_PropertyName_Then_Returns_False ( )
345
350
{
346
351
// Arrange
347
- var type = typeof ( HasPublicPropertyTestStub ) ;
352
+ var type = typeof ( TypeExtensionsTestStub ) ;
348
353
var propertyName = Random . String ( ) ;
349
354
350
355
// Act
@@ -358,8 +363,8 @@ public void HasPublicProperty_When_Called_With_NonExisting_PropertyName_Then_Ret
358
363
public void HasPublicProperty_When_Called_For_Static_Value_Then_Returns_False ( )
359
364
{
360
365
// Arrange
361
- var type = typeof ( HasPublicPropertyTestStub ) ;
362
- var propertyName = nameof ( HasPublicPropertyTestStub . TEST_STATIC_STRING ) ;
366
+ var type = typeof ( TypeExtensionsTestStub ) ;
367
+ var propertyName = nameof ( TypeExtensionsTestStub . TEST_STATIC_STRING ) ;
363
368
364
369
// Act
365
370
var result = type . HasPublicProperty ( propertyName ) ;
@@ -372,8 +377,8 @@ public void HasPublicProperty_When_Called_For_Static_Value_Then_Returns_False()
372
377
public void HasPublicProperty_When_Called_For_Const_Value_Then_Returns_False ( )
373
378
{
374
379
// Arrange
375
- var type = typeof ( HasPublicPropertyTestStub ) ;
376
- var propertyName = nameof ( HasPublicPropertyTestStub . TEST_CONST_STRING ) ;
380
+ var type = typeof ( TypeExtensionsTestStub ) ;
381
+ var propertyName = nameof ( TypeExtensionsTestStub . TEST_CONST_STRING ) ;
377
382
378
383
// Act
379
384
var result = type . HasPublicProperty ( propertyName ) ;
@@ -386,7 +391,7 @@ public void HasPublicProperty_When_Called_For_Const_Value_Then_Returns_False()
386
391
public void HasPublicProperty_When_Called_For_Private_Property_Then_Returns_False ( )
387
392
{
388
393
// Arrange
389
- var type = typeof ( HasPublicPropertyTestStub ) ;
394
+ var type = typeof ( TypeExtensionsTestStub ) ;
390
395
var propertyName = "TEST_PRIVATE_STRING_PROPERTY" ;
391
396
392
397
// Act
0 commit comments