Skip to content

Commit c848a9b

Browse files
author
Mat Jones
committed
address code review comments
1 parent f66d91b commit c848a9b

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

test/AndcultureCode.CSharp.Extensions.Tests/TypeExtensionsTests.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using AndcultureCode.CSharp.Extensions.Tests.Stubs;
5-
using AndcultureCode.CSharp.Testing.Tests;
65
using Shouldly;
76
using Xunit;
87
using Xunit.Abstractions;
98

109
namespace AndcultureCode.CSharp.Extensions.Tests
1110
{
12-
public class TypeExtensionsTests : BaseUnitTest
11+
public class TypeExtensionsTests : BaseExtensionsTest
1312
{
1413
#region Constructor
1514

@@ -95,6 +94,20 @@ public void GetPublicPropertyInfo_When_Property_Does_Not_Exist_Then_Returns_Null
9594

9695
#region GetPublicPropertyValue
9796

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+
98111
[Fact]
99112
public void GetPublicPropertyValue_When_Property_Exists_Then_Returns_Value()
100113
{
@@ -318,20 +331,12 @@ public void GetTypeName_Type_Overload_Given_InstanceOf_Object_Returns_AssemblyQu
318331

319332
#region HasPublicProperty
320333

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-
329334
[Fact]
330335
public void HasPublicProperty_When_Called_With_Public_PropertyName_Then_Returns_True()
331336
{
332337
// 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);
335340

336341
// Act
337342
var result = type.HasPublicProperty(propertyName);
@@ -344,7 +349,7 @@ public void HasPublicProperty_When_Called_With_Public_PropertyName_Then_Returns_
344349
public void HasPublicProperty_When_Called_With_NonExisting_PropertyName_Then_Returns_False()
345350
{
346351
// Arrange
347-
var type = typeof(HasPublicPropertyTestStub);
352+
var type = typeof(TypeExtensionsTestStub);
348353
var propertyName = Random.String();
349354

350355
// Act
@@ -358,8 +363,8 @@ public void HasPublicProperty_When_Called_With_NonExisting_PropertyName_Then_Ret
358363
public void HasPublicProperty_When_Called_For_Static_Value_Then_Returns_False()
359364
{
360365
// 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);
363368

364369
// Act
365370
var result = type.HasPublicProperty(propertyName);
@@ -372,8 +377,8 @@ public void HasPublicProperty_When_Called_For_Static_Value_Then_Returns_False()
372377
public void HasPublicProperty_When_Called_For_Const_Value_Then_Returns_False()
373378
{
374379
// 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);
377382

378383
// Act
379384
var result = type.HasPublicProperty(propertyName);
@@ -386,7 +391,7 @@ public void HasPublicProperty_When_Called_For_Const_Value_Then_Returns_False()
386391
public void HasPublicProperty_When_Called_For_Private_Property_Then_Returns_False()
387392
{
388393
// Arrange
389-
var type = typeof(HasPublicPropertyTestStub);
394+
var type = typeof(TypeExtensionsTestStub);
390395
var propertyName = "TEST_PRIVATE_STRING_PROPERTY";
391396

392397
// Act

0 commit comments

Comments
 (0)