Skip to content

Commit

Permalink
Issue-4823 - CodeReview changes implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
berkarslan-xo committed Sep 9, 2021
1 parent 9523448 commit ad085f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,11 @@ public Analyzer GetCustomAnalyzer()
var analyzerType = Reflection.CreateType(customAnalyzerType);

// If parameterless ctor exists, use that; if not, pass the Lucene Version.
if (analyzerType.GetConstructor(Type.EmptyTypes) != null)
if (analyzerType?.GetConstructor(Type.EmptyTypes) != null)
{
analyzer = Reflection.CreateInstance(analyzerType) as Analyzer;
}
else if (analyzerType.GetConstructor(new Type[] { typeof(Lucene.Net.Util.Version) }) != null)
else if (analyzerType?.GetConstructor(new Type[] { typeof(Lucene.Net.Util.Version) }) != null)
{
analyzer = Reflection.CreateInstance(analyzerType, new object[] { Constants.LuceneVersion }) as Analyzer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public void CreateInstance_WithArgs_WorksCorrectly()
{
// Arrange
var typeToCreate = typeof(StringBuilder);
var argToPass = new object[] { 1 };
var argToPass = new object[] { "one" };

// Act
var result = Reflection.CreateInstance(typeToCreate, argToPass) as StringBuilder;
var result = (StringBuilder)Reflection.CreateInstance(typeToCreate, argToPass);

// Assert
Assert.AreEqual(1, result.Capacity);
Assert.AreEqual("one", result.ToString());
}

[Test]
Expand All @@ -27,10 +27,10 @@ public void CreateInstance_WithoutArgs_WorksCorrectly()
var typeToCreate = typeof(StringBuilder);

// Act
var result = Reflection.CreateInstance(typeToCreate) as StringBuilder;
var result = (StringBuilder)Reflection.CreateInstance(typeToCreate);

// Assert
Assert.AreEqual(16, result.Capacity);
Assert.AreEqual(string.Empty, result.ToString());
}
}
}

0 comments on commit ad085f3

Please sign in to comment.