Skip to content

Commit

Permalink
Get rid of ReSharper warnings "possible NullReferenceException" in tests
Browse files Browse the repository at this point in the history
On Type.GetMethod(), in net45 and net46 only
  • Loading branch information
Thibaud DESODT committed Nov 7, 2017
1 parent 3cd376c commit f03e544
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/Serilog.Tests/MethodOverloadConventionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void ValidateWriteEventLogMethods(Type loggerType)
//handle silent logger special case i.e. no result validation
if (loggerType == typeof(SilentLogger))
return;

EvaluateSingleResult(level, sink);
}

Expand Down Expand Up @@ -177,6 +177,7 @@ public void ValidateBindMessageTemplateMethods(Type loggerType)
{
var method = loggerType.GetMethod("BindMessageTemplate");

Assert.NotNull(method);
Assert.Equal(method.ReturnType, typeof(bool));
Assert.True(method.IsPublic);

Expand Down Expand Up @@ -219,7 +220,7 @@ public void ValidateBindMessageTemplateMethods(Type loggerType)
//silentlogger is always false
if (loggerType == typeof(SilentLogger))
return;

Assert.True(result as bool?);

//test null arg path
Expand All @@ -238,6 +239,7 @@ public void ValidateBindPropertyMethods(Type loggerType)
{
var method = loggerType.GetMethod("BindProperty");

Assert.NotNull(method);
Assert.Equal(method.ReturnType, typeof(bool));
Assert.True(method.IsPublic);

Expand Down Expand Up @@ -274,7 +276,7 @@ public void ValidateBindPropertyMethods(Type loggerType)
//silentlogger will always be false
if (loggerType == typeof(SilentLogger))
return;

Assert.True(result as bool?);

//test null arg path/ invalid property name
Expand All @@ -293,6 +295,7 @@ public void ValidateIsEnabledMethods(Type loggerType)
{
var method = loggerType.GetMethod("IsEnabled");

Assert.NotNull(method);
Assert.True(method.IsPublic);
Assert.Equal(method.ReturnType, typeof(bool));

Expand Down

0 comments on commit f03e544

Please sign in to comment.