From f03e544fb5aefb901ab104f7f90b1c00ec55e6e3 Mon Sep 17 00:00:00 2001 From: Thibaud DESODT Date: Tue, 7 Nov 2017 07:20:24 +0100 Subject: [PATCH] Get rid of ReSharper warnings "possible NullReferenceException" in tests On Type.GetMethod(), in net45 and net46 only --- test/Serilog.Tests/MethodOverloadConventionTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/Serilog.Tests/MethodOverloadConventionTests.cs b/test/Serilog.Tests/MethodOverloadConventionTests.cs index 523ec05ba..6b098a44a 100644 --- a/test/Serilog.Tests/MethodOverloadConventionTests.cs +++ b/test/Serilog.Tests/MethodOverloadConventionTests.cs @@ -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); } @@ -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); @@ -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 @@ -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); @@ -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 @@ -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));