-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Constructor Info Invoke with CreateInstance (#646)
+semver:patch
- Loading branch information
1 parent
0eafff9
commit 9675ab5
Showing
3 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using NUnit.Framework; | ||
using FluentNHibernate.Utils; | ||
|
||
namespace FluentNHibernate.Testing.Utils; | ||
|
||
[TestFixture] | ||
public class ExtensionsTests | ||
{ | ||
class PublicConstructor | ||
{ | ||
public PublicConstructor() { } | ||
} | ||
|
||
class PrivateConstructor | ||
{ | ||
private PrivateConstructor() { } | ||
} | ||
|
||
class ConstructorWithArguments | ||
{ | ||
private ConstructorWithArguments(int number) { } | ||
} | ||
|
||
[Test] | ||
public void CanInitialiseClass() | ||
{ | ||
var type = typeof(PublicConstructor); | ||
var result = type.InstantiateUsingParameterlessConstructor(); | ||
|
||
Assert.That(result, Is.InstanceOf<PublicConstructor>()); | ||
} | ||
|
||
[Test] | ||
public void CanInitialiseClassWithPrivateConstructor() | ||
{ | ||
var type = typeof(PrivateConstructor); | ||
var result = type.InstantiateUsingParameterlessConstructor(); | ||
|
||
Assert.That(result, Is.InstanceOf<PrivateConstructor>()); | ||
} | ||
|
||
[Test] | ||
public void ClassWithoutParameterlessConstructorThrowsException() | ||
{ | ||
var type = typeof(ConstructorWithArguments); | ||
Assert.Throws<MissingConstructorException>(() => type.InstantiateUsingParameterlessConstructor()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters